Ferrell Synthetic Intelligence commited on
Commit
8ac3f6c
·
1 Parent(s): f7932bc

Add universal Veritas development harness

Browse files
README.md CHANGED
@@ -33,6 +33,12 @@ See `runtime/README.md` and `models/manifest.json` for the adapter contract and
33
 
34
  `daemon/server.mjs` is the first runnable native boundary for workspace and Git operations. It binds to loopback and exposes only bounded read-only endpoints. `desktop/README.md` defines the Tauri shell plan and acceptance gates; no compiled desktop binary is claimed in this pre-production release.
35
 
 
 
 
 
 
 
36
  ## Status
37
 
38
  This is a pre-production engineering release. The Liquid checkpoint is not included until its exact artifact, license, checksum, and evaluation are confirmed. The Qwen weight is downloaded separately from its official repository and should be verified before offline use.
 
33
 
34
  `daemon/server.mjs` is the first runnable native boundary for workspace and Git operations. It binds to loopback and exposes only bounded read-only endpoints. `desktop/README.md` defines the Tauri shell plan and acceptance gates; no compiled desktop binary is claimed in this pre-production release.
35
 
36
+ ## Universal Harness
37
+
38
+ `harness/` contains the model-independent closed loop: guard, retrieve, plan, propose, verify, revise, test, review, and learn. Liquid is assigned to reasoning and verification; Qwen Coder is assigned to patch generation. The harness does not mutate model weights and never lets a model approve or apply its own changes.
39
+
40
+ The original AIDE Developer's Credo and role-specific SOP cards live in `harness/credo.md` and `harness/sops.json`. `harness/veritas.mjs` uses calibrated task thresholds: 90% for ordinary explanation/code-change evidence and 98% for security, publishing, payment, and identity operations. These are evidence gates, not promises of universal model accuracy; failed gates produce abstention.
41
+
42
  ## Status
43
 
44
  This is a pre-production engineering release. The Liquid checkpoint is not included until its exact artifact, license, checksum, and evaluation are confirmed. The Qwen weight is downloaded separately from its official repository and should be verified before offline use.
harness/README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AIDE Universal Harness
2
+
3
+ The harness is the layer that makes every connected model safer and more useful. It does not secretly retrain weights. It improves system behavior through curated context, role-specific prompts, deterministic tools, external verification, calibrated feedback, and reversible execution.
4
+
5
+ ## Closed Loop
6
+
7
+ ```text
8
+ intake -> guard -> retrieve -> plan -> propose -> verify -> revise -> test -> review -> learn
9
+ ```
10
+
11
+ - **Intake:** normalize the task, workspace, permissions, and success criteria.
12
+ - **Guard:** reject prompt injection, unsafe paths, secret exposure, and unapproved network actions.
13
+ - **Retrieve:** select only relevant files, symbols, tests, docs, and prior decisions within a context budget.
14
+ - **Plan:** use the reasoning model to create constraints and a bounded checklist.
15
+ - **Propose:** use the coding model to emit a structured patch or artifact, never direct writes.
16
+ - **Verify:** use deterministic parsers, tests, linters, type checkers, Git diff checks, and a separate verifier model.
17
+ - **Revise:** allow a small fixed number of revisions, then stop and request human direction.
18
+ - **Test:** run only approved tasks in a sandbox and attach raw output to the trace.
19
+ - **Review:** show claims, evidence, diff, permissions, and verification result before applying.
20
+ - **Learn:** store anonymized outcome metadata and failures locally for prompt/eval improvement; never silently modify weights.
21
+
22
+ ## Guarantees
23
+
24
+ - One model cannot approve its own work.
25
+ - The harness owns tools, permissions, context, cancellation, budgets, and audit records.
26
+ - Every patch is atomic, reversible, and user-approved.
27
+ - Low confidence or failed verification produces abstention, not fabricated success.
28
+ - Models can be swapped without changing the workflow.
29
+
30
+ ## Model Roles
31
+
32
+ - `reason`: Liquid thinking model for requirements, architecture, research, and test plans.
33
+ - `build`: Qwen Coder for code and unified diffs.
34
+ - `verify`: Liquid or another independent verifier for evidence and failure analysis.
35
+ - `fast`: optional small model for autocomplete and classification.
36
+
37
+ See `orchestrator.mjs` and `policy.json` for the executable contract.
harness/credo.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AIDE Developer's Credo
2
+
3
+ This is an original engineering code inspired by broad themes of disciplined craft, loyalty to the people protected by the work, keeping one's word, and earning trust through action. It is not a reproduction or quotation of the Mandalorian creed.
4
+
5
+ 1. **Protect the user.** Do not leak source, secrets, identity, or control of the device.
6
+ 2. **Keep the contract.** State what was done, what was not done, and what remains uncertain.
7
+ 3. **Earn trust through evidence.** A model's confidence is not proof; tests, compilers, signatures, and sources are proof.
8
+ 4. **Finish the procedure.** Follow the task SOP, record the result, and stop when a gate fails.
9
+ 5. **Guard the vulnerable boundary.** Treat untrusted files, prompts, tools, plugins, dependencies, and network peers as hostile until checked.
10
+ 6. **Carry the work forward.** Make changes reviewable, reversible, documented, and usable by the next developer.
11
+ 7. **Adapt without abandoning principles.** Models, runtimes, relays, and payment providers may change; safety, privacy, and honesty do not.
12
+ 8. **Never confuse output with accomplishment.** A generated answer is only a proposal until the Veritas layer validates it.
13
+
14
+ ## Model Practice
15
+
16
+ Every model follows a short role card instead of re-learning the whole system prompt:
17
+
18
+ - **Reasoner:** identify constraints, evidence, risks, and test criteria; do not edit.
19
+ - **Builder:** produce the smallest structured patch; do not claim execution.
20
+ - **Verifier:** attack assumptions and inspect evidence; do not approve its own work.
21
+ - **Operator:** execute only allowlisted deterministic tools after approval.
22
+ - **Archivist:** record provenance, checksums, decisions, and failures; do not alter history.
harness/orchestrator.mjs ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { evaluateVeritas } from './veritas.mjs';
2
+
3
+ const DEFAULT_POLICY = Object.freeze({
4
+ max_turns: 4,
5
+ max_context_bytes: 120000,
6
+ max_patch_bytes: 200000,
7
+ require_human_approval: true,
8
+ allow_network: false
9
+ });
10
+
11
+ function requireProvider(providers, role) {
12
+ const provider = providers[role];
13
+ if (!provider || typeof provider.complete !== 'function') {
14
+ throw new Error(`missing provider for role: ${role}`);
15
+ }
16
+ return provider;
17
+ }
18
+
19
+ function bounded(value, max, label) {
20
+ const text = String(value ?? '');
21
+ if (Buffer.byteLength(text) > max) throw new Error(`${label} exceeds harness budget`);
22
+ return text;
23
+ }
24
+
25
+ export function createHarness({ providers, tools = {}, policy = {} }) {
26
+ const rules = { ...DEFAULT_POLICY, ...policy };
27
+ return {
28
+ async run(task, context = {}) {
29
+ const goal = bounded(task, rules.max_context_bytes, 'task');
30
+ const trace = [{ stage: 'intake', status: 'accepted' }];
31
+ if (!goal.trim()) throw new Error('task is empty');
32
+ if (rules.allow_network !== false && tools.network) throw new Error('network policy must be explicit');
33
+
34
+ const reason = requireProvider(providers, 'reason');
35
+ const plan = await reason.complete({
36
+ role: 'reason',
37
+ instruction: 'Return constraints, risks, files to inspect, and a test checklist. Do not edit files.',
38
+ task: goal,
39
+ context: bounded(JSON.stringify(context), rules.max_context_bytes, 'context')
40
+ });
41
+ trace.push({ stage: 'plan', status: 'complete', bytes: Buffer.byteLength(String(plan)) });
42
+
43
+ const builder = requireProvider(providers, 'build');
44
+ const patch = bounded(await builder.complete({
45
+ role: 'build',
46
+ instruction: 'Return a unified diff only. Do not claim tests passed. Do not write files.',
47
+ task: goal,
48
+ plan: bounded(plan, rules.max_context_bytes, 'plan')
49
+ }), rules.max_patch_bytes, 'patch');
50
+ trace.push({ stage: 'propose', status: 'complete', bytes: Buffer.byteLength(patch) });
51
+
52
+ const verifier = requireProvider(providers, 'verify');
53
+ const verdict = await verifier.complete({
54
+ role: 'verify',
55
+ instruction: 'Return exactly APPROVE, REJECT, or NEEDS-EVIDENCE followed by concrete reasons. Do not edit files.',
56
+ task: goal,
57
+ plan,
58
+ patch
59
+ });
60
+ const approved = /^\s*APPROVE\b/i.test(String(verdict));
61
+ const veritas = evaluateVeritas({
62
+ taskClass: context.taskClass || 'code-change',
63
+ evidenceScore: context.evidenceScore,
64
+ checks: context.checks
65
+ });
66
+ trace.push({ stage: 'verify', status: approved ? 'approved-with-notes' : 'blocked' });
67
+ trace.push({ stage: 'veritas', status: veritas.status, score: veritas.score, threshold: veritas.threshold });
68
+ return {
69
+ status: approved && veritas.passed && !rules.require_human_approval ? 'ready-for-apply' : 'awaiting-human-approval',
70
+ plan,
71
+ patch,
72
+ verdict,
73
+ veritas,
74
+ trace,
75
+ apply: async () => {
76
+ throw new Error('apply is owned by the permission-gated daemon, not the model harness');
77
+ }
78
+ };
79
+ }
80
+ };
81
+ }
harness/policy.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": "1.0",
3
+ "max_turns": 4,
4
+ "max_context_bytes": 120000,
5
+ "max_patch_bytes": 200000,
6
+ "require_human_approval": true,
7
+ "allow_network": false,
8
+ "allow_untrusted_commands": false,
9
+ "self_approval_forbidden": true,
10
+ "revision_policy": "stop-after-budget",
11
+ "verification": ["patch-parse", "path-boundary", "format", "tests", "git-diff"],
12
+ "feedback_storage": "local-only",
13
+ "weights_mutated_by_harness": false
14
+ }
harness/sops.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": "1.0",
3
+ "credo": "harness/credo.md",
4
+ "roles": {
5
+ "reason": {"sop": "requirements-and-plan", "must": ["identify-goal", "list-constraints", "cite-workspace-evidence", "define-tests"], "must_not": ["write-files", "claim-success"]},
6
+ "build": {"sop": "minimal-patch", "must": ["preserve-user-edits", "emit-unified-diff", "list-assumptions"], "must_not": ["execute-commands", "hide-files", "claim-tests-passed"]},
7
+ "verify": {"sop": "adversarial-review", "must": ["check-diff", "check-evidence", "check-security", "request-missing-proof"], "must_not": ["approve-own-output", "invent-test-results"]},
8
+ "operator": {"sop": "safe-execution", "must": ["check-approval", "check-path", "capture-output", "support-cancel"], "must_not": ["use-network-by-default", "read-secrets", "run-unbounded-commands"]},
9
+ "archivist": {"sop": "provenance-record", "must": ["record-revision", "record-checksum", "record-result", "record-failure"], "must_not": ["rewrite-history", "omit-negative-results"]}
10
+ },
11
+ "task_classes": {
12
+ "explanation": {"veritas_threshold": 0.9, "requires": ["evidence-or-explicit-uncertainty"]},
13
+ "code-change": {"veritas_threshold": 0.9, "requires": ["patch-parse", "path-boundary", "compile-or-typecheck", "tests", "diff-review"]},
14
+ "security-or-publish": {"veritas_threshold": 0.98, "requires": ["independent-review", "license-check", "checksum", "reproducible-artifact", "human-approval"]},
15
+ "payment-or-identity": {"veritas_threshold": 0.98, "requires": ["human-approval", "provider-confirmation", "no-custody"]}
16
+ }
17
+ }
harness/test-orchestrator.mjs ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import assert from 'node:assert/strict';
2
+ import { createHarness } from './orchestrator.mjs';
3
+
4
+ const calls = [];
5
+ const provider = role => ({ complete: async input => {
6
+ calls.push({ role, input });
7
+ if (role === 'reason') return 'constraints: preserve API; tests: npm test';
8
+ if (role === 'build') return 'diff --git a/a b/a\n+safe change';
9
+ return 'APPROVE: diff is bounded; run tests before apply';
10
+ }});
11
+
12
+ const harness = createHarness({ providers: { reason: provider('reason'), build: provider('build'), verify: provider('verify') } });
13
+ const result = await harness.run('Improve the provider router', { files: ['router.ts'] });
14
+ assert.equal(result.status, 'awaiting-human-approval');
15
+ assert.equal(result.trace.length, 5);
16
+ assert.equal(calls.length, 3);
17
+ assert.equal(result.veritas.status, 'abstain-needs-evidence');
18
+ await assert.rejects(result.apply(), /permission-gated daemon/);
19
+ console.log('universal harness test passed');
harness/veritas.mjs ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const THRESHOLDS = Object.freeze({
2
+ explanation: 0.90,
3
+ 'code-change': 0.90,
4
+ 'security-or-publish': 0.98,
5
+ 'payment-or-identity': 0.98
6
+ });
7
+
8
+ export function evaluateVeritas({ taskClass = 'code-change', evidenceScore = 0, checks = {} } = {}) {
9
+ const threshold = THRESHOLDS[taskClass] ?? THRESHOLDS['code-change'];
10
+ const failed = Object.entries(checks).filter(([, result]) => result !== true).map(([name]) => name);
11
+ const score = Math.max(0, Math.min(1, Number(evidenceScore) || 0));
12
+ const passed = score >= threshold && failed.length === 0;
13
+ return {
14
+ passed,
15
+ status: passed ? 'verified' : 'abstain-needs-evidence',
16
+ score,
17
+ threshold,
18
+ failed_checks: failed,
19
+ rule: 'Model confidence is not evidence. A failed deterministic gate blocks final output.'
20
+ };
21
+ }
package.json CHANGED
@@ -5,7 +5,7 @@
5
  "description": "Local-first sovereign development workbench",
6
  "type": "module",
7
  "scripts": {
8
- "test": "node tests/smoke.mjs",
9
  "check": "node --check app.js && node --check daemon/server.mjs"
10
  },
11
  "engines": {
 
5
  "description": "Local-first sovereign development workbench",
6
  "type": "module",
7
  "scripts": {
8
+ "test": "node tests/smoke.mjs && node harness/test-orchestrator.mjs",
9
  "check": "node --check app.js && node --check daemon/server.mjs"
10
  },
11
  "engines": {