@agentikos/omega-os 0.19.38 → 0.19.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/bootstrap/lib/common.sh +19 -10
  2. package/bootstrap/templates/aisb/architect.md +27 -1
  3. package/bootstrap/templates/aisb/construct.md +27 -1
  4. package/bootstrap/templates/aisb/keymaker.md +27 -1
  5. package/bootstrap/templates/aisb/link.md +27 -1
  6. package/bootstrap/templates/aisb/lmc-protocol.md +27 -1
  7. package/bootstrap/templates/aisb/merovingian.md +27 -1
  8. package/bootstrap/templates/aisb/morpheus.md +27 -1
  9. package/bootstrap/templates/aisb/neo.md +27 -1
  10. package/bootstrap/templates/aisb/niobe.md +27 -1
  11. package/bootstrap/templates/aisb/oracle.md +27 -1
  12. package/bootstrap/templates/aisb/pythia.md +36 -0
  13. package/bootstrap/templates/aisb/seraph.md +27 -1
  14. package/bootstrap/templates/aisb/smith.md +27 -1
  15. package/bootstrap/templates/aisb/zion.md +27 -1
  16. package/omega/Agentik_Engine/omega_engine/__init__.py +1 -1
  17. package/omega/Agentik_Engine/omega_engine/__pycache__/__init__.cpython-313.pyc +0 -0
  18. package/omega/Agentik_Engine/omega_engine/__pycache__/cli.cpython-313.pyc +0 -0
  19. package/omega/Agentik_Engine/omega_engine/__pycache__/paperclip_bridge.cpython-313.pyc +0 -0
  20. package/omega/Agentik_Engine/omega_engine/__pycache__/prompt_audit.cpython-313.pyc +0 -0
  21. package/omega/Agentik_Engine/omega_engine/__pycache__/tmux.cpython-313.pyc +0 -0
  22. package/omega/Agentik_Engine/omega_engine/__pycache__/tui.cpython-313.pyc +0 -0
  23. package/omega/Agentik_Engine/omega_engine/cli.py +39 -0
  24. package/omega/Agentik_Engine/omega_engine/paperclip_bridge.py +110 -0
  25. package/omega/Agentik_Engine/omega_engine/prompt_audit.py +395 -0
  26. package/omega/Agentik_Engine/omega_engine/tmux.py +61 -26
  27. package/omega/Agentik_Engine/omega_engine/tui.py +293 -86
  28. package/omega/Agentik_Engine/pyproject.toml +1 -1
  29. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313-pytest-8.4.2.pyc +0 -0
  30. package/omega/Agentik_Engine/tests/__pycache__/test_install_ux.cpython-313.pyc +0 -0
  31. package/omega/Agentik_Engine/tests/__pycache__/test_paperclip_status.cpython-313-pytest-8.4.2.pyc +0 -0
  32. package/omega/Agentik_Engine/tests/__pycache__/test_paperclip_status.cpython-313.pyc +0 -0
  33. package/omega/Agentik_Engine/tests/__pycache__/test_prompt_audit.cpython-313-pytest-8.4.2.pyc +0 -0
  34. package/omega/Agentik_Engine/tests/__pycache__/test_prompt_audit.cpython-313.pyc +0 -0
  35. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_palette.cpython-313-pytest-8.4.2.pyc +0 -0
  36. package/omega/Agentik_Engine/tests/__pycache__/test_tmux_palette.cpython-313.pyc +0 -0
  37. package/omega/Agentik_Engine/tests/__pycache__/test_tui_runtime.cpython-313-pytest-8.4.2.pyc +0 -0
  38. package/omega/Agentik_Engine/tests/__pycache__/test_tui_runtime.cpython-313.pyc +0 -0
  39. package/omega/Agentik_Engine/tests/test_install_ux.py +87 -2
  40. package/omega/Agentik_Engine/tests/test_paperclip_status.py +142 -0
  41. package/omega/Agentik_Engine/tests/test_prompt_audit.py +281 -0
  42. package/omega/Agentik_Engine/tests/test_tmux_palette.py +94 -0
  43. package/omega/Agentik_Engine/tests/test_tui_runtime.py +156 -0
  44. package/omega/Agentik_SSOT/VERSION +1 -1
  45. package/omega/Agentik_SSOT/docs/AUDIT-V0.19.39.md +161 -0
  46. package/omega/Agentik_SSOT/docs/AUDIT-V0.19.40.md +163 -0
  47. package/omega/Agentik_SSOT/rules/audit-gates.md +189 -0
  48. package/omega/Agentik_SSOT/rules/constitution.md +7 -0
  49. package/omega/Agentik_SSOT/rules/orchestration.md +215 -0
  50. package/omega/Agentik_SSOT/rules/prompt-protocols.md +219 -0
  51. package/omega/Agentik_SSOT/rules/scope-safety.md +197 -0
  52. package/omega/Agentik_SSOT/rules/three-laws.md +214 -0
  53. package/omega/Agentik_SSOT/rules/verified-completion.md +216 -0
  54. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ ---
2
+ id: audit-gates
3
+ layer: L0-governance
4
+ applies_to: [aisb, oracle, worker]
5
+ priority: 5
6
+ ---
7
+
8
+ # Audit Gates — Quality Arsenal as System Contract
9
+
10
+ > The 17 Quality Arsenal audits are **not just commands a human runs**.
11
+ > They are *gates* that lifecycle events at L3–L5 must pass before a
12
+ > `done.json` may state `done_clean`. This file fixes which audits gate
13
+ > which events, how the Gestalt-Popper methodology bakes into the
14
+ > grader, and the verified-completion thresholds the engine enforces.
15
+
16
+ ## The 17 audits (catalogued in `../audits/`)
17
+
18
+ | Audit | Domain | Question it answers | Threshold |
19
+ |---|---|---|---|
20
+ | `codeaudit` | Code | Is the code SOLID? | 85/100 |
21
+ | `flowaudit` | User flows | Does the experience WORK? | 85/100 |
22
+ | `uiuxaudit` | UI design | Is the interface BEAUTIFUL? | 85/100 |
23
+ | `refontaudit` | Redesign | Does the redesign hold? | 85/100 |
24
+ | `debugaudit` | Runtime | What is BROKEN right now? | 85/100 |
25
+ | `featureaudit` | Features | Is the product COMPLETE? | 85/100 |
26
+ | `perfaudit` | Performance | Is it FAST enough? | 85/100 |
27
+ | `secaudit` | Security | Is it SECURE? | 85/100 |
28
+ | `a11yaudit` | Accessibility | Is it ACCESSIBLE? | 85/100 |
29
+ | `seoaudit` | SEO | Is it DISCOVERABLE? | 85/100 |
30
+ | `dataaudit` | Data | Is the data INTACT? | 85/100 |
31
+ | `apiaudit` | API | Is the API SOLID? | 85/100 |
32
+ | `copyaudit` | Copy | Is the copy CLEAR? | 85/100 |
33
+ | `dxaudit` | DX | Is the DX SMOOTH? | 85/100 |
34
+ | `motionaudit` | Motion | Is the motion PURPOSEFUL? | 85/100 |
35
+ | `automationaudit` | Automation | Is automation RELIABLE? | 85/100 |
36
+ | `logicaudit` | Logic | Is the logic OPTIMAL? | 85/100 |
37
+ | `retentionaudit` | Retention | What FEATURES are missing? (READ-ONLY) | — |
38
+
39
+ The full definition for each lives in `../audits/<name>.yaml`
40
+ (domain, gather tools, phases, falsification rule, fix-loop flag).
41
+
42
+ ## Lifecycle gates
43
+
44
+ Audits are gates on *lifecycle events*, not on *human commands*. The
45
+ engine consults the gate registry at each event and refuses progress
46
+ if the required audits did not pass.
47
+
48
+ | Event | Gate | Audits typically required |
49
+ |---|---|---|
50
+ | Worker `done_clean` (per subtask) | Worker gate | The audits matching the files the Worker touched (e.g. edited `*.ts` → `codeaudit`; edited `*.css` + UI components → `uiuxaudit` + `a11yaudit`). |
51
+ | Oracle close-coherence (per mission) | Mission gate | The union of all Worker gates plus any mission-wide audits the brief declared (`brief.audit_gates`). |
52
+ | Pre-merge / pre-ship | Ship gate | `codeaudit`, `secaudit`, plus domain-relevant audits. Project's `ship-config.json` may add more. |
53
+ | Genesis completion (new project) | Genesis gate | `codeaudit`, `featureaudit`, `dxaudit`, `secaudit` — a freshly built project must stand on its own. |
54
+ | Post-mission (asynchronous) | Drift gate | `debugaudit`, `perfaudit`, periodically scheduled by Hermès or the engine cadence. |
55
+
56
+ Gates compose: a Worker that triggers two audits passes only if *both*
57
+ audits exit `verdict: satisfied` with score ≥ threshold.
58
+
59
+ ## The Gestalt-Popper methodology
60
+
61
+ Every audit (see `../docs/quality-arsenal/QUALITY-ARSENAL-PREAMBLE.md`
62
+ and `../docs/quality-arsenal/AUDIT-VERIFICATION-CONTRACT.md`) implements:
63
+
64
+ 1. **Gestalt clarity gate (Phase 0).** Before any scored phase, the
65
+ audit identifies the *hinge* of its domain — the single element on
66
+ which the domain's reliability or value pivots. The canonical hinge
67
+ noun per audit is fixed in
68
+ `AUDIT-VERIFICATION-CONTRACT.md` (e.g. `codeaudit` → HINGE POINT,
69
+ `flowaudit` → HINGE FLOW, `secaudit` → SECURITY HINGE POINT). The
70
+ hinge is given **10× scrutiny** in subsequent phases.
71
+ 2. **Popper falsification.** For each scored item, the auditor states
72
+ *what would prove this claim wrong*. A PASS is only valid if the
73
+ falsifier was sought and not found. Bias toward FAIL — a 100 is
74
+ earned, never assumed.
75
+ 3. **Hippocratic pre/post.** Before any fix, capture baseline
76
+ (Phase N-1). After each fix, re-run the baseline check (Phase N+1).
77
+ A fix that broke a previously-working check reverts and is marked
78
+ `NEEDS_REVIEW`.
79
+ 4. **Before-after matrix (Phase N+4).** Every audit produces
80
+ `.<audit>/before-after.md` proving zero regressions. No matrix → no
81
+ 100/100 verdict.
82
+ 5. **Fix → re-audit loop.** Bounded (typically 5 iterations). The loop
83
+ exits on `verdict: satisfied` *or* on iteration cap.
84
+
85
+ ## Mandatory minimums (per audit)
86
+
87
+ These structural invariants are enforced by `metaudit` (the audit of
88
+ audits). A skill that violates any of them fails meta and is removed
89
+ from the gate registry until repaired.
90
+
91
+ | # | Invariant | Why |
92
+ |---|---|---|
93
+ | 1 | At least 16 scored phases | Forensic depth — fewer phases = shallow audit. |
94
+ | 2 | Phase N-1 (PRE-FIX BASELINE) implemented before the first fix | Hippocratic rule — can't claim "no regression" without a baseline. |
95
+ | 3 | Phase N+4 (before-after matrix) written to `.<audit>/before-after.md` | Proof-of-work artefact required for the 100/100 verdict. |
96
+ | 4 | Score normalised to /100 (raw may be /280, /320, /360, /400, /420 — must publish the formula) | Cross-audit comparison. |
97
+ | 5 | HINGE identification at Phase 0 | Gestalt clarity gate. |
98
+ | 6 | Popper falsification per scored item | Epistemic rigor. |
99
+ | 7 | Fix → re-audit loop with explicit max iterations | Bounded recovery. |
100
+ | 8 | Final verdict gate refuses 100/100 unless `before-after.md` shows zero regressions | Contract enforcement. |
101
+
102
+ ## The verified-completion contract
103
+
104
+ A `done.json` may state `status: done_clean` only when **all** of:
105
+
106
+ | Condition | Source |
107
+ |---|---|
108
+ | `audit.verdict == "satisfied"` | The grader (LMC or direct) for every required gate. |
109
+ | `audit.scores[gate] >= threshold` (default 85/100) for each gate | `../audits/<gate>.yaml#threshold`. |
110
+ | `regressions.length == 0` | Phase N+4 before-after matrix. |
111
+ | `evidence.verify_exit_code == 0` | The brief's `verify_command`. |
112
+ | `ship.result in ["ok", "skipped"]` when `ship.requested == true` | The ship pipeline (see `verified-completion.md`). |
113
+ | Independent third party ran the *real* flow | The grader is a different agent from the executor; the verify is the real system, not a mock. |
114
+
115
+ Fail any condition → `status: pending` (with `pending_actions[]` listing
116
+ the failed conditions) or `status: failed` (when the verify itself
117
+ errored). The engine refuses to mark a session done on the receiver's
118
+ word alone — see `verified-completion.md`.
119
+
120
+ ## Routing — which audits apply
121
+
122
+ Each `<audit>.yaml` declares `applies_to.changed` — the glob set that
123
+ *triggers* the audit when a Worker's `files_owned` intersects it.
124
+ Sample mappings:
125
+
126
+ | Glob change | Audits auto-required |
127
+ |---|---|
128
+ | `*.py`, `*.ts`, `*.tsx`, `*.js`, `*.go`, `*.rs` | `codeaudit` |
129
+ | `*.tsx`, `*.jsx`, `*.css`, design tokens | `uiuxaudit`, `a11yaudit`, `motionaudit` (if motion files touched) |
130
+ | `*.env*`, `Dockerfile`, `package.json`, auth modules | `secaudit` |
131
+ | API route handlers, OpenAPI / GraphQL schemas | `apiaudit` |
132
+ | Database migrations, schema files | `dataaudit` |
133
+ | Onboarding, signup, payment flows | `flowaudit` |
134
+ | Cron specs, daemon scripts, scheduled tasks | `automationaudit` |
135
+ | Marketing pages, SEO meta, sitemap | `seoaudit`, `copyaudit` |
136
+
137
+ The Oracle expands `brief.audit_gates` from this routing table at
138
+ dispatch time. A Worker may not narrow the gate set; it may *only*
139
+ widen it (e.g. discovers a security implication mid-task).
140
+
141
+ ## Ship gate (pre-prod)
142
+
143
+ When `brief.ship == true`, the ship pipeline runs before final
144
+ `done.json`. Each step gates the next:
145
+
146
+ 1. `npm run build` (or equivalent) — exit 0.
147
+ 2. Whitelisted staging — only `files_owned`. Any extra file aborts.
148
+ 3. Secret scan (e.g. `gitleaks --staged`) — zero matches.
149
+ 4. Whitespace sanity (`git diff --check`) — clean.
150
+ 5. Conventional-commit message from `brief.commit_message`.
151
+ 6. Per-project ship lock (`flock`) — serialise across Oracles.
152
+ 7. Freeze flag check — if `Agentik_Runtime/locks/ship-<project>.frozen`
153
+ exists, abort and alert.
154
+ 8. `git pull --rebase` — clean.
155
+ 9. `git push` — clean.
156
+ 10. Deploy (project-defined command) — typically `vercel --prod` or
157
+ equivalent.
158
+ 11. Poll deploy status until READY/ERROR/TIMEOUT (default 10 min).
159
+ 12. Write `done.json#ship` with commit, URL, status, duration.
160
+
161
+ Default deploy-failure policy is **freeze, don't rollback** — the
162
+ freeze flag blocks further pushes on the project until the human lifts
163
+ it. Auto-rollback is opt-in per project via `ship-config.json`.
164
+
165
+ ## Drift gate (continuous)
166
+
167
+ `debugaudit` and `perfaudit` are scheduled to run periodically against
168
+ the live deployed URL (typically by Hermès cadence or the engine's
169
+ cron). A drift detection writes a `done.json` with
170
+ `status: failed` against a synthetic "drift" mission, which AISB
171
+ surfaces to the human and (if the project opts in) auto-dispatches a
172
+ repair mission.
173
+
174
+ ## Cross-references
175
+
176
+ - `constitution.md` — Verification Rule.
177
+ - `three-laws.md` — First Law (runtime over code) is the audit
178
+ methodology's epistemology.
179
+ - `prompt-protocols.md` — `brief.audit_gates`, `done.audit` schema.
180
+ - `verified-completion.md` — the terminal contract these gates serve.
181
+ - `scope-safety.md` — Worker gates intersect with `files_owned`.
182
+ - `orchestration.md` — Oracle close-coherence runs the mission gate.
183
+ - `../audits/*.yaml` — per-audit catalogue (domain, gather, phases).
184
+ - `../docs/quality-arsenal/AUDIT-VERIFICATION-CONTRACT.md` — Hippocratic
185
+ pre/post protocol.
186
+ - `../docs/quality-arsenal/QUALITY-ARSENAL-PREAMBLE.md` — Gestalt-Popper
187
+ methodology.
188
+ - `../docs/LAYERS.md` — which layer runs which gate.
189
+ - `../personas/OMEGAOS-CONTEXT.md` — provider-neutral working context.
@@ -1,3 +1,10 @@
1
+ ---
2
+ id: constitution
3
+ layer: L0-governance
4
+ applies_to: [aisb, oracle, worker, hermes]
5
+ priority: 1
6
+ ---
7
+
1
8
  # The Omega OS Constitution
2
9
 
3
10
  > The rules every agent at every level inherits. Provider-neutral. Compiled into
@@ -0,0 +1,215 @@
1
+ ---
2
+ id: orchestration
3
+ layer: L0-governance
4
+ applies_to: [aisb, oracle, worker, hermes]
5
+ priority: 3
6
+ ---
7
+
8
+ # Orchestration — Who Dispatches What
9
+
10
+ > OmegaOS is a five-layer agentic OS with one optional governance roof
11
+ > (L0/Paperclip). This file fixes the dispatch hierarchy, the decisions
12
+ > log discipline, and the fresh-context template every layer uses when
13
+ > handing work down. The architecture itself is defined in
14
+ > `../docs/LAYERS.md`; this file makes it *operational*.
15
+
16
+ ## The hierarchy
17
+
18
+ ```
19
+ L0 Paperclip (optional governance roof — budget, org chart, approvals)
20
+ L1 Human (Telegram, CLI, web — three doors into the system)
21
+ L2 Hermès (meta-companion — Anthropic API, separate budget)
22
+ L3 AISB (intake / orchestrator — Claude Max OAuth)
23
+ L4 Oracle (per-project planner — persistent tmux session)
24
+ L5 Workers (executors — one per subtask, .done.json verified)
25
+ ```
26
+
27
+ Each layer is *independently usable*. Skip L0 and L2 and OmegaOS is
28
+ still a complete agentic OS: a human writes intent, AISB classifies,
29
+ Oracle plans, Workers execute, the engine verifies.
30
+
31
+ ## Dispatch rules
32
+
33
+ The arrows below define *who is permitted to dispatch to whom*. Any
34
+ other dispatch is a violation and the receiving layer must refuse.
35
+
36
+ | From | May dispatch to | Notes |
37
+ |---|---|---|
38
+ | L1 Human | L2 Hermès, L3 AISB | Three doors: Telegram-to-Hermès, Telegram-to-AISB, CLI/tmux. |
39
+ | L0 Paperclip | L2 Hermès, L3 AISB | Approval gates; never bypasses the lower layers. |
40
+ | L2 Hermès | L3 AISB | Hermès cannot reach Oracle or Worker directly. Missions go through AISB. |
41
+ | L3 AISB | L4 Oracle | One Oracle per project. AISB never spawns a Worker directly. |
42
+ | L4 Oracle | L5 Workers | One Worker per subtask, with a verify command. |
43
+ | L5 Worker | — | A Worker never dispatches. If more work is needed, it returns `status: pending` and lets Oracle decide. |
44
+
45
+ **Why no skipping.** Each step adds a layer of intent translation. AISB
46
+ turns a freeform human prompt into a typed mission. Oracle turns a
47
+ mission into a DAG of subtasks with verify commands. A Worker that
48
+ receives a freeform human prompt has no scope, no verify command, and
49
+ no way to call itself done — the verified-completion contract breaks.
50
+
51
+ ## Roles in one line
52
+
53
+ - **L0 Paperclip.** Approvals + budget + org chart. Read-only over L1–L5
54
+ unless a budget guard fires.
55
+ - **L1 Human.** Author of intent. Reads final reports. Approves
56
+ destructive ops.
57
+ - **L2 Hermès.** Meta-reasoning, scheduling, learning. Watches
58
+ observations, proposes missions, dispatches them down to L3.
59
+ - **L3 AISB.** Intake. Classifies a mission (simple / medium / complex /
60
+ epic), picks a topology, hands to L4.
61
+ - **L4 Oracle.** Per-project planner. Reads the mission, builds the
62
+ outcome rubric (see `audit-gates.md`), dispatches Workers, polices
63
+ their `done.json`, runs the close-coherence audit.
64
+ - **L5 Worker.** Executor. Owns a strict file scope
65
+ (`spec.scope.files_owned`), writes `done.json` when the verify
66
+ command passes.
67
+
68
+ ## The decisions log
69
+
70
+ Every layer that makes a non-trivial routing or design choice **MUST**
71
+ append to `.orchestrator/decisions.md` in the project root:
72
+
73
+ ```markdown
74
+ ### [ISO-8601 timestamp] Decision title
75
+ - **Task:** what was asked
76
+ - **Classification:** SIMPLE / MEDIUM / COMPLEX / EPIC
77
+ - **Decision:** what was chosen (agent, topology, audit set, scope)
78
+ - **Rationale:** why (one line)
79
+ - **Falsifier:** the runtime check that would prove this wrong
80
+ ```
81
+
82
+ The log is append-only. Past entries are never edited — only superseded
83
+ by a new entry that cites the old one. AISB and Oracle both write to
84
+ the same file; Workers write only if they exercise the Third Law and
85
+ correct a premise inside a dispatched session.
86
+
87
+ Reason: when a mission is re-opened a week later, the *why* is in the
88
+ log. Without it the next agent has to reverse-engineer past intent from
89
+ diffs.
90
+
91
+ ## The fresh-context template (mandatory at every dispatch)
92
+
93
+ When *any* layer dispatches to the one below it, the brief MUST contain
94
+ the following sections. Empty sections are allowed; missing sections
95
+ are a contract violation.
96
+
97
+ ```
98
+ ## Mission
99
+ <1-2 line summary of the goal>
100
+
101
+ ## Purpose
102
+ <why this matters — links the work to the human intent at L1>
103
+
104
+ ## Context
105
+ <project root, deployed URL, stack, relevant prior runs>
106
+
107
+ ## What's Done
108
+ <bullet list of completed work in this mission so far>
109
+
110
+ ## Current Task
111
+ <specific files, line numbers, exact changes — surgical scope>
112
+
113
+ ## Done Criteria
114
+ <measurable condition: a shell-checkable predicate, an audit verdict,
115
+ a screenshot diff, a passing test>
116
+
117
+ ## Verify Command
118
+ <exact command the receiver runs to prove it satisfied Done Criteria>
119
+
120
+ ## Key Decisions
121
+ <excerpts from .orchestrator/decisions.md relevant to this task>
122
+
123
+ ## Files in Scope
124
+ <the receiver's spec.scope.files_owned — files it may edit>
125
+
126
+ ## Relevant Memories
127
+ <pre-selected lessons-learned entries — NOT a full dump>
128
+ ```
129
+
130
+ **Why both Done Criteria and Verify Command.** Without `Done Criteria`
131
+ the receiver redefines "done" mid-stream. Without `Verify Command` the
132
+ dispatcher cannot independently confirm — and the verified-completion
133
+ contract demands an independent third party (see
134
+ `verified-completion.md`).
135
+
136
+ ## Fresh context vs context overlap
137
+
138
+ When a layer hands a sub-mission to a fresh agent, the dispatcher
139
+ decides between two patterns:
140
+
141
+ | Pattern | When | Cost |
142
+ |---|---|---|
143
+ | **Continue agent** | High overlap with prior subtask; the prior agent already holds the relevant files and state in working memory. | Cheap but risks context bloat past compaction thresholds. |
144
+ | **Spawn fresh** | New domain, new files, new specialist. The dispatcher pre-inlines a summary of prior results into the fresh brief. | Slightly more expensive, guarantees a clean slate. |
145
+
146
+ Default is *spawn fresh* for any subtask that crosses a layer or a
147
+ domain boundary. Continue only inside a single layer's working session.
148
+
149
+ ## Multi-Oracle on the same project
150
+
151
+ Multiple Oracles can run in parallel on the same project. The engine
152
+ serialises *file ownership*, not Oracle count.
153
+
154
+ - AISB checks the per-project Oracle registry before dispatching. If
155
+ an Oracle is *idle* (no Workers, at prompt, >5 min), AISB reuses
156
+ it. Otherwise AISB spawns Oracle #2 (`oracle-<Project>-2`).
157
+ - Each Oracle declares `files_owned` for its mission. Two Oracles
158
+ cannot claim overlapping files.
159
+ - The patrol auto-cleans dead Oracles every 5 minutes.
160
+ - A registry file at `Agentik_Runtime/oracles/<Project>-<id>.json`
161
+ records the Oracle's mission, scope, and heartbeat.
162
+
163
+ ## Worker batching (parallel-safe)
164
+
165
+ Inside a single Oracle, Workers may run *in parallel* if and only if
166
+ their file footprints are disjoint. The Oracle's plan groups subtasks
167
+ into batches:
168
+
169
+ - **Narrow** subtasks: identifiable file set, no overlap with other
170
+ narrow tasks → packable into a batch of up to N (typical N = 3 or 4).
171
+ - **Broad** subtasks: vague scope, no identifiable file footprint →
172
+ run alone, serially.
173
+ - **Terminal** subtasks: touch infrastructure (env files, package
174
+ manifests, migrations) → always run alone, after all batches.
175
+
176
+ Two Workers on the same file at the same time is a contract violation
177
+ even if their edits "wouldn't conflict" — the assertion of disjointness
178
+ itself is the contract.
179
+
180
+ ## Close-coherence (Oracle's final check)
181
+
182
+ When all Workers report `done_clean`, the Oracle runs a *close-
183
+ coherence* pass before reporting up to AISB:
184
+
185
+ 1. Re-read the mission brief.
186
+ 2. For each Worker, confirm its `done.json` matches the brief's slice.
187
+ 3. Run the audit set the brief requires (see `audit-gates.md`).
188
+ 4. Write the Oracle's own `done.json` with `consensus_score`,
189
+ `regressions`, and the final verdict.
190
+
191
+ An Oracle that skips close-coherence has not finished its job, even if
192
+ every Worker did.
193
+
194
+ ## The "no idle wait" invariant
195
+
196
+ The Third Law applies to *every* dispatched session in this hierarchy
197
+ (L2 ↔ L3 ↔ L4 ↔ L5). The only sessions where a question may be asked
198
+ of a human are sessions L1 owns directly — typically an interactive
199
+ shell or a Telegram DM the human is actively reading.
200
+
201
+ Practical detection rule for an agent: *"Am I attached to a tmux
202
+ session whose name starts with `oracle-`, `aisb-`, or contains
203
+ `-worker-`?"* If yes, no questions; decide and proceed
204
+ (`prompt-protocols.md` for the exact `blocked.json` fallback).
205
+
206
+ ## Cross-references
207
+
208
+ - `constitution.md` — Prime Principle, Three Laws.
209
+ - `three-laws.md` — expanded Third Law (no idle wait).
210
+ - `prompt-protocols.md` — brief / done.json / blocked.json schemas.
211
+ - `audit-gates.md` — which audits gate which dispatch transitions.
212
+ - `scope-safety.md` — `spec.scope.files_owned` discipline.
213
+ - `verified-completion.md` — terminal states an Oracle/Worker may report.
214
+ - `../docs/LAYERS.md` — formal L1–L5 architecture and credential model.
215
+ - `../personas/OMEGAOS-CONTEXT.md` — provider-neutral working context.
@@ -0,0 +1,219 @@
1
+ ---
2
+ id: prompt-protocols
3
+ layer: L0-governance
4
+ applies_to: [aisb, oracle, worker, hermes]
5
+ priority: 4
6
+ ---
7
+
8
+ # Prompt Protocols — Brief, Done, Blocked
9
+
10
+ > Every dispatch in OmegaOS is a contract: a brief in, a `done.json`
11
+ > out, with `blocked.json` as the escape valve. This file fixes the
12
+ > three schemas, the LMC (Lead-Manager-Checker) variant for grader
13
+ > agents, and the "no idle wait" rule that turns the Third Law into
14
+ > a protocol guarantee.
15
+ >
16
+ > See `../agents/aisb/lmc-protocol.md` for the in-agent LMC reference
17
+ > (when full LMC is used vs lite vs direct).
18
+
19
+ ## The three artefacts
20
+
21
+ | Artefact | Direction | Required keys | Lifecycle |
22
+ |---|---|---|---|
23
+ | `brief.json` (or inline prompt) | Down (dispatcher → receiver) | mission, purpose, files_owned, done_criteria, verify_command, ship | Created per dispatch, immutable. |
24
+ | `done.json` | Up (receiver → dispatcher) | status, started_at, finished_at, evidence, score (when audited), ship (when applicable) | Created exactly once per receiver, terminal. |
25
+ | `blocked.json` | Sideways (receiver → orchestrator state) | session, blocked_at, question, best_guess, fallback_action, can_resume_without_answer | May exist *in parallel* with `done.json` — surfaces the question to the human asynchronously. |
26
+
27
+ The schemas below are the contract. Engine and Telegram bridge both
28
+ parse them; deviations break notifications and audit replay.
29
+
30
+ ## brief.json schema
31
+
32
+ ```json
33
+ {
34
+ "id": "<uuid-v4>",
35
+ "mission": "<1-2 line goal>",
36
+ "purpose": "<why this matters at L1>",
37
+ "context": {
38
+ "project_root": "/absolute/path",
39
+ "deployed_url": "https://...",
40
+ "stack": "next.js | python | go | …",
41
+ "prior_runs": ["<done.json paths>"]
42
+ },
43
+ "whats_done": ["<bullet>", "<bullet>"],
44
+ "current_task": "<files, line numbers, exact changes>",
45
+ "done_criteria": "<measurable predicate>",
46
+ "verify_command": "<exact shell command>",
47
+ "key_decisions": ["<excerpt from decisions.md>"],
48
+ "spec": {
49
+ "scope": {
50
+ "files_owned": ["src/foo.ts", "tests/foo.test.ts"]
51
+ }
52
+ },
53
+ "relevant_memories": ["<lesson-id>"],
54
+ "ship": false,
55
+ "audit_gates": ["codeaudit"],
56
+ "lifecycle": "ephemeral | persistent"
57
+ }
58
+ ```
59
+
60
+ - `mission` ≤ 200 chars (longer = dispatcher failed to decompose).
61
+ - `files_owned` is a hard boundary; see `scope-safety.md`.
62
+ - `verify_command` MUST be a shell command, not prose; wrap sequences
63
+ in a script that exits 0 on success.
64
+ - `ship` defaults to `false`; set true only when the prompt contains a
65
+ ship/deploy/push directive or `ship-config.json` opts in.
66
+ - `audit_gates` lists Quality Arsenal audits that must pass before
67
+ `status: done_clean` (see `audit-gates.md`).
68
+ - `lifecycle: ephemeral` lets the dispatcher close the receiver on
69
+ `done_clean`; `persistent` keeps it alive for follow-up.
70
+
71
+ ## done.json schema
72
+
73
+ ```json
74
+ {
75
+ "agent": "<oracle-name | worker-name>",
76
+ "project": "<slug>",
77
+ "status": "done_clean | pending | failed",
78
+ "started_at": "<ISO-8601>",
79
+ "finished_at": "<ISO-8601>",
80
+ "duration_sec": 0,
81
+ "mission": "<copy of brief.mission>",
82
+ "evidence": {
83
+ "verify_command": "<command run>",
84
+ "verify_exit_code": 0,
85
+ "verify_stdout": "<captured>",
86
+ "verify_stderr": "<captured>",
87
+ "artefacts": ["path/to/screenshot.png", "path/to/log"]
88
+ },
89
+ "audit": {
90
+ "gates_required": ["codeaudit", "secaudit"],
91
+ "gates_passed": ["codeaudit", "secaudit"],
92
+ "scores": {"codeaudit": 92, "secaudit": 88},
93
+ "verdict": "satisfied | partial | unsatisfied"
94
+ },
95
+ "regressions": [],
96
+ "pending_actions": [],
97
+ "ship": {
98
+ "requested": false,
99
+ "result": "ok | failed | skipped | frozen",
100
+ "commit": "<sha or null>",
101
+ "deploy_url": "<url or null>",
102
+ "deploy_status": "READY | ERROR | TIMEOUT | null"
103
+ },
104
+ "report_path": "<path/to/report.md>"
105
+ }
106
+ ```
107
+
108
+ ### Status values + forbidden patterns
109
+
110
+ | Status | Meaning | Dispatcher action |
111
+ |---|---|---|
112
+ | `done_clean` | Verify passed, all audit gates passed, zero regressions. | Closes session (if ephemeral), forwards report up. |
113
+ | `pending` | Verify passed *for this slice*; `pending_actions[]` lists next slices. | Keeps session alive, decides continue vs hand off. |
114
+ | `failed` | Verify failed, audit gate refused, or regression detected. | Keeps session alive, reads evidence, re-dispatches. |
115
+
116
+ Forbidden: `done_clean` without `verify_exit_code == 0`; with
117
+ `regressions[]` non-empty; with any required gate missing from
118
+ `gates_passed`; after a ship that returned `failed` or `frozen`. Any
119
+ violation → dispatcher rejects the claim, re-opens the mission, logs
120
+ to `.orchestrator/decisions.md`. Absence of `done.json` is **not**
121
+ success — patrol waits.
122
+
123
+ ## blocked.json schema
124
+
125
+ ```json
126
+ {
127
+ "session": "<tmux session name>",
128
+ "blocked_at": "<ISO-8601>",
129
+ "question": "<what is ambiguous>",
130
+ "best_guess": "<the receiver's recommendation>",
131
+ "fallback_action": "<what the receiver is doing meanwhile>",
132
+ "can_resume_without_answer": true,
133
+ "human_required_for": "<credential | destructive op | scope expansion | null>"
134
+ }
135
+ ```
136
+
137
+ Lives at `Agentik_Runtime/state/blocked-<session>.json`. The patrol
138
+ polls this directory; when a file appears, the human is notified via
139
+ Telegram (Hermès or AISB, depending on routing).
140
+
141
+ ### Legal vs illegal blocks
142
+
143
+ A `blocked.json` is legal only when (a) the block is genuine
144
+ (credential missing, destructive op outside scope, true semantic
145
+ ambiguity with no safe default), (b) `fallback_action` is *executing
146
+ right now*, and (c) `can_resume_without_answer: true`.
147
+
148
+ Illegal blocks (these are *preferences*, not blocks — decide and
149
+ proceed per the Third Law):
150
+
151
+ - "I'd like to confirm before proceeding."
152
+ - "Three options exist, which would you prefer?"
153
+ - "I want the user to validate the approach before I code."
154
+
155
+ ## The LMC variant (Lead-Manager-Checker)
156
+
157
+ LMC is the *optional* grader topology used by audit-grade agents
158
+ (e.g. `seraph`). Most agents work direct — Lead alone — because
159
+ Manager/Checker overhead is wasted on routing or simple execution.
160
+ See `../agents/aisb/lmc-protocol.md` for the canonical table.
161
+
162
+ | Agent role | LMC mode | Why |
163
+ |---|---|---|
164
+ | Audit grader (seraph) | **Full LMC** (Lead + Manager + Checker) | Independent validation is the whole point of audit. |
165
+ | Planner (keymaker) | **Lite LMC** (Lead + Manager; Lead validates) | Plans benefit from structured generation. |
166
+ | Everyone else | **Direct** | Speed > ceremony for execution, research, routing. |
167
+
168
+ Manager output:
169
+
170
+ ```
171
+ BRIEF: <1-line> STATUS: DONE | PARTIAL | BLOCKED
172
+ CONFIDENCE: <0.0-1.0> ARTIFACTS: <files>
173
+ ```
174
+
175
+ Checker verdict (full LMC only):
176
+
177
+ ```
178
+ DECISION: PASS | FAIL CONFIDENCE: <0.0-1.0>
179
+ ISSUES: <list> FEEDBACK: <next-attempt guidance>
180
+ ```
181
+
182
+ Three FAIL verdicts in a row → escalate to dispatcher (do not loop).
183
+
184
+ ## The "no idle wait" rule
185
+
186
+ Sessions identified as *dispatched* (per `orchestration.md`) **MUST
187
+ NEVER** stop with an idle prompt. The only legal terminal states are:
188
+
189
+ 1. `done.json` with `status: done_clean`.
190
+ 2. `done.json` with `status: pending` and non-empty `pending_actions[]`.
191
+ 3. `done.json` with `status: failed` and non-empty
192
+ `evidence.verify_stderr`.
193
+ 4. `done.json` plus a `blocked.json` whose `fallback_action` is
194
+ currently executing.
195
+
196
+ Violation phrases a transcript audit will flag: *"Which path should I
197
+ take?"*, *"Should I proceed?"*, *"Awaiting confirmation"*, *"Confirm
198
+ before I continue"*. Replace any of them with a decision written to
199
+ `decisions.md` and immediate execution of the best path.
200
+
201
+ ## Idempotency
202
+
203
+ `done.json` is written exactly once per session; duplicate writes are
204
+ rejected by mtime. To *correct* a prior `done.json` (e.g. a regression
205
+ discovered after `done_clean`), write a new
206
+ `done-correction-<timestamp>.json` referencing the original and let
207
+ the dispatcher reconcile.
208
+
209
+ ## Cross-references
210
+
211
+ - `constitution.md` — Prime Principle, Three Laws.
212
+ - `three-laws.md` — Third Law (no idle wait) in detail.
213
+ - `orchestration.md` — dispatch hierarchy + decisions log.
214
+ - `audit-gates.md` — `audit_gates[]` semantics in brief / done.
215
+ - `scope-safety.md` — `files_owned` enforcement.
216
+ - `verified-completion.md` — the terminal contract done.json fulfils.
217
+ - `../agents/aisb/lmc-protocol.md` — LMC mode reference.
218
+ - `../docs/LAYERS.md` — which sessions are "dispatched".
219
+ - `../personas/OMEGAOS-CONTEXT.md` — provider-neutral working context.