harness-everything 0.54.0 → 0.54.1

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 (45) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +8 -0
  4. package/ci/action-gate.test.js +1 -1
  5. package/ci/mechanism-2at-fable-execution-phases.test.js +38 -0
  6. package/ci/mechanism-codex-hook-results.test.js +145 -0
  7. package/ci/openai-plugin-runtime.test.js +2 -1
  8. package/ci/prompt-contract-regressions.test.js +6 -2
  9. package/docs/platform-capabilities.md +17 -0
  10. package/fable-mode/SKILL.md +5 -5
  11. package/fable-mode/execution-guardrails/SKILL.md +1 -1
  12. package/fable-mode/fable-haiku/SKILL.md +1 -1
  13. package/fable-mode/fable-opus/SKILL.md +1 -1
  14. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  15. package/fable-mode/references/execution-phases.md +26 -4
  16. package/hooks/scripts/action-gate.js +5 -0
  17. package/hooks/scripts/codex-action-gate-post.js +3 -12
  18. package/hooks/scripts/contract-test.js +17 -7
  19. package/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  20. package/hooks/scripts/rule-of-3-tracker.js +11 -4
  21. package/hooks/scripts/state-persist.js +15 -9
  22. package/hooks/scripts/subagent-scope-guard.js +32 -25
  23. package/hooks/scripts/subagent-start.js +1 -1
  24. package/hooks/scripts/subagent-stop.js +14 -3
  25. package/opencode-plugin/plugin.json +1 -1
  26. package/package.json +1 -1
  27. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  28. package/plugins/harness-everything/hooks/hooks.json +6 -6
  29. package/plugins/harness-everything/hooks/scripts/action-gate.js +5 -0
  30. package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +3 -12
  31. package/plugins/harness-everything/hooks/scripts/contract-test.js +17 -7
  32. package/plugins/harness-everything/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  33. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +11 -4
  34. package/plugins/harness-everything/hooks/scripts/state-persist.js +15 -9
  35. package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +32 -25
  36. package/plugins/harness-everything/hooks/scripts/subagent-start.js +1 -1
  37. package/plugins/harness-everything/hooks/scripts/subagent-stop.js +14 -3
  38. package/plugins/harness-everything/plugin.json +1 -1
  39. package/plugins/harness-everything/skills/fable-mode/SKILL.md +5 -5
  40. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
  41. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  42. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
  43. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  44. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +26 -4
  45. package/sbom.cdx.json +7 -7
@@ -10,7 +10,7 @@
10
10
  "name": "harness-everything",
11
11
  "source": "./",
12
12
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
13
- "version": "0.54.0",
13
+ "version": "0.54.1",
14
14
  "author": {
15
15
  "name": "Miya Daniel"
16
16
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-everything",
3
3
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
4
- "version": "0.54.0",
4
+ "version": "0.54.1",
5
5
  "author": {
6
6
  "name": "Miya Daniel"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.54.1](https://github.com/dyphn1/Harness-everything/compare/v0.54.0...v0.54.1) (2026-11-20)
6
+
7
+ ### Bug Fixes
8
+
9
+ * **codex:** handle hook outcomes and subagent warnings ([420b36f](https://github.com/dyphn1/Harness-everything/commit/420b36f4f21e32d1ce416abbcda0c239a4ee0a8b))
10
+ * **fable:** move planning rules into execution phases and relax the prompt contract pin ([149bc78](https://github.com/dyphn1/Harness-everything/commit/149bc785ee9575c839f15a50ecb73606be0d3b0e)), closes [#476](https://github.com/dyphn1/Harness-everything/issues/476)
11
+ * **fable:** restore quoted skill description within the token budget ([7935939](https://github.com/dyphn1/Harness-everything/commit/7935939f4455ba4c885f8cfaa4b3bbb4de3a5ee5))
12
+
5
13
  ## [0.54.0](https://github.com/dyphn1/Harness-everything/compare/v0.53.0...v0.54.0) (2026-11-19)
6
14
 
7
15
  ### Features
@@ -348,7 +348,7 @@ try {
348
348
  check(pluginPost && pluginPost.hooks.some(hook => /codex-action-gate-post\.js/.test(hook.command)), 'Codex plugin infers action-gate outcome from supported PostToolUse');
349
349
  check(codexPost.inferOutcome({ tool_response: { exitCode: 0 } }) === 'success', 'Codex PostToolUse maps zero exit code to success');
350
350
  check(codexPost.inferOutcome({ tool_response: { exit_code: 2, stderr: 'failed' } }) === 'failure', 'Codex PostToolUse maps non-zero exit code to failure');
351
- check(codexPost.inferOutcome({ tool_response: { stderr: 'fatal: denied' } }) === 'failure', 'Codex PostToolUse conservatively recognizes failure stderr without exit code');
351
+ check(codexPost.inferOutcome({ tool_response: { stderr: 'fatal: denied' } }) === 'unknown', 'Codex PostToolUse treats stderr without a structured status as unknown');
352
352
  check(pluginHooks.hooks.Stop.some(group => group.hooks.some(hook => /action-gate\.js/.test(hook.command))), 'OpenAI plugin closes pending approvals at Stop');
353
353
 
354
354
  check(fs.readFileSync(rulesPath, 'utf8') === fs.readFileSync(pluginRules, 'utf8'), 'canonical and plugin action-gate rule tables are byte-identical');
@@ -5,6 +5,8 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
7
  const ROOT = path.resolve(__dirname, '..');
8
+ const skill = fs.readFileSync(path.join(ROOT, 'fable-mode/SKILL.md'), 'utf8');
9
+ const packagedSkill = fs.readFileSync(path.join(ROOT, 'plugins/harness-everything/skills/fable-mode/SKILL.md'), 'utf8');
8
10
  const guide = fs.readFileSync(path.join(ROOT, 'fable-mode/references/execution-phases.md'), 'utf8');
9
11
  const packagedGuide = fs.readFileSync(path.join(ROOT, 'plugins/harness-everything/skills/fable-mode/references/execution-phases.md'), 'utf8');
10
12
  const contract = fs.readFileSync(path.join(ROOT, 'fable-mode/CONTRACT-FORMAT.md'), 'utf8');
@@ -43,4 +45,40 @@ assert.match(guide, /explicit user or\s+host runtime choice/i);
43
45
  assert.doesNotMatch(guide, /Resolve requested model|Opus macro work|do not silently change models/i);
44
46
  assert.match(guide.slice(legacyStart), /`\.claude\/harness-everything\/state\/contracts\//);
45
47
 
48
+ const workflow = skill.split('## Workflow\n')[1];
49
+ assert.strictEqual(packagedSkill, skill, 'OpenAI package includes the canonical Fable workflow');
50
+ const routing = [
51
+ '## USE FOR:',
52
+ '- Large multi-file, multi-source, or multi-session work',
53
+ '- Fable profile explanations or explicit Fable execution requests',
54
+ '- Work needing named delegation and cold verification',
55
+ '',
56
+ '## DO NOT USE FOR:',
57
+ '- One obvious single-pass edit',
58
+ '- Ordinary Tier 2 implementation or bugfix work',
59
+ '',
60
+ '## Select Operation First',
61
+ ].join('\n');
62
+ assert.ok(skill.includes(routing), 'the existing Fable routing text is preserved');
63
+ assert.match(workflow, /^1\. Discover the runtime and lock the authorized file scope before edits\.$/m);
64
+ assert.ok(skill.includes('Execution only: stage checklist and audit records.'));
65
+ assert.match(skill, /Execution: `<this-skill-dir>\/scripts\/model-selector\.js`, stage contracts, and `<skills-repo-root>\/harness-everything\/scripts\/verify-gate\.js`\./);
66
+ assert.ok(skill.includes('For explanation/profile-only lookup, read only `<this-skill-dir>/references/profile-lookup.md` and answer. No stage state, delegation, or selector source reads. Quoted aliases do not start Fable. Mixed execution retains its topology; execution follows the workflow below.'));
67
+ assert.match(workflow, /^4\. Delegate by profile: orchestrator coordinates, reasoning takes bounded judgment, mechanical takes low-ambiguity work; workers never spawn workers\./m);
68
+ assert.match(workflow, /^5\. The host runtime-model floor is advisory; record it, never block on model choice alone\.$/m);
69
+ assert.match(workflow, /^6\. .*Run stage checks, cold-review high-stakes artifacts, and audit profile\/runtime\/fallback fields\.$/m);
70
+ const handoffReference = '`<this-skill-dir>/references/execution-phases.md#verification-and-handoff`'; // portability-lint: allow markdown text to match, never a path
71
+ assert.ok(workflow.includes(`4. Delegate by profile: orchestrator coordinates, reasoning takes bounded judgment, mechanical takes low-ambiguity work; workers never spawn workers. Before Codex dispatch, load/apply ${handoffReference}.`),
72
+ 'step 4 requires loading and applying the verification-and-handoff reference before Codex subagent dispatch');
73
+ assert.ok(workflow.includes(`6. On every Codex handoff or silent stop, load/apply ${handoffReference} before accepting results or releasing dependent stages. Run stage checks, cold-review high-stakes artifacts, and audit profile/runtime/fallback fields.`),
74
+ 'step 6 requires loading and applying the verification-and-handoff reference at every handoff before accepting results or releasing dependent stages');
75
+ assert.match(workflow, /^2\. Plan via `<this-skill-dir>\/references\/execution-phases\.md`\.$/m);
76
+ assert.match(workflow, /^3\. Use `model-selector\.js`\.$/m);
77
+ assert.match(guide, /^## Verification and handoff$/m, 'the explicit handoff target heading exists');
78
+ const handoff = guide.split(/\r?\n## Verification and handoff\r?\n/)[1];
79
+ assert.ok(handoff, 'the dispatch reference contains Verification and handoff');
80
+ assert.match(handoff, /coordinator MUST reconcile scope before accepting a\nresult or using it in a dependent stage/);
81
+ assert.match(handoff, /Before dispatch, capture the worker worktree's starting state/);
82
+ assert.match(handoff, /Run this check after every handoff, including silent stops\./);
83
+
46
84
  console.log('PASS Fable execution phases match the active workflow contract and preserve a scoped legacy fallback');
@@ -0,0 +1,145 @@
1
+ 'use strict';
2
+
3
+ const assert = require('node:assert/strict');
4
+ const fs = require('node:fs');
5
+ const os = require('node:os');
6
+ const path = require('node:path');
7
+ const { spawnSync } = require('node:child_process');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+ const pluginRoot = path.join(root, 'plugins', 'harness-everything');
11
+ const manifest = require('../plugins/harness-everything/hooks/hooks.json');
12
+ const { getSessionDir, getStateRoot } = require('../hooks/scripts/lib/harness-state');
13
+
14
+ function registeredHook(event, script) {
15
+ const handler = manifest.hooks[event].flatMap(group => group.hooks)
16
+ .find(hook => hook.command.includes('/' + script + '"'));
17
+ assert.ok(handler, script + ' is registered');
18
+ const match = /^node "\$\{PLUGIN_ROOT\}\/([^"]+)"( --codex)?$/.exec(handler.command);
19
+ assert.ok(match, handler.command);
20
+ assert.equal(handler.commandWindows,
21
+ 'node "${PLUGIN_ROOT}\\' + match[1].replaceAll('/', '\\') + '"' + (match[2] || ''));
22
+ return match[2] ? [match[1], '--codex'] : [match[1]];
23
+ }
24
+
25
+ function spawn(executable, args, cwd, input) {
26
+ const result = spawnSync(executable, args, { cwd, input, encoding: 'utf8', timeout: 10000 });
27
+ assert.ifError(result.error);
28
+ assert.equal(result.status, 0, result.stderr);
29
+ return result;
30
+ }
31
+
32
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-codex-hook-results-'));
33
+ process.env.HARNESS_STATE_HOME = path.join(temp, 'state');
34
+ delete process.env.HARNESS_DOC_RECONCILIATION_PILOT;
35
+
36
+ try {
37
+ for (const layout of [root, pluginRoot]) {
38
+ const label = layout === root ? 'source' : 'package';
39
+ const cwd = path.join(temp, 'workspace ' + label);
40
+ const session_id = 'codex-result-' + label;
41
+ fs.mkdirSync(cwd);
42
+ spawn('git', ['init', '-q'], cwd);
43
+
44
+ function hook(event, script, fields = {}) {
45
+ const [relative, ...args] = registeredHook(event, script);
46
+ return spawn(process.execPath, [path.join(layout, relative), ...args], cwd,
47
+ JSON.stringify({ hook_event_name: event, cwd, session_id, ...fields }));
48
+ }
49
+
50
+ const session = getSessionDir(cwd, session_id);
51
+ const checkCommand = 'npm test';
52
+ const shell = { tool_name: 'Bash', tool_input: { command: checkCommand } };
53
+
54
+ const runRoot = path.join(getStateRoot(cwd), 'fable-runs', 'result-run');
55
+ const contract = path.join(runRoot, 'contracts', 'check.json');
56
+ const evidence = path.join(runRoot, 'evidence', 'check.json');
57
+ fs.mkdirSync(path.dirname(contract), { recursive: true });
58
+ fs.writeFileSync(contract, JSON.stringify({
59
+ schemaVersion: 2, planId: 'result-plan', runId: 'result-run', stageId: 'check',
60
+ sessionId: session_id, status: 'pending', checkCommand,
61
+ }));
62
+ function read(file) { return JSON.parse(fs.readFileSync(file, 'utf8')); }
63
+ function post(response) {
64
+ for (const script of ['state-persist.js', 'rule-of-3-tracker.js', 'contract-test.js']) {
65
+ hook('PostToolUse', script, { ...shell, tool_response: response });
66
+ }
67
+ }
68
+
69
+ const handoff = path.join(session, 'handoff-state.json');
70
+ const tracker = path.join(session, 'rule-of-3-state.json');
71
+ post({ exit_code: 1, stderr: 'test failed' });
72
+ assert.equal(read(handoff).status, 'failed');
73
+ assert.equal(read(tracker).count, 1);
74
+ assert.equal(read(contract).status, 'fail');
75
+ function evidenceSnapshot() {
76
+ // Test commands can themselves write files, so the edit timestamp is
77
+ // independent of whether the host confirmed success.
78
+ const { lastEditAt, ...verification } = read(handoff);
79
+ return [verification, ...[tracker, contract, evidence].map(read)];
80
+ }
81
+ const snapshots = evidenceSnapshot();
82
+
83
+ for (const ambiguous of [
84
+ undefined, null, [], { stdout: { exitCode: 0 } }, { exitCode: '0' },
85
+ { success: true }, 'Process exited with code 0\nOutput:\nanything',
86
+ ]) {
87
+ post(ambiguous);
88
+ assert.deepEqual(evidenceSnapshot(), snapshots);
89
+ }
90
+
91
+ post({ exitCode: 0, stderr: 'benign test warning' });
92
+ assert.equal(read(handoff).status, 'idle');
93
+ assert.ok(read(handoff).lastVerifyAt > 0);
94
+ assert.equal(read(tracker).count, 0);
95
+ assert.equal(read(contract).status, 'pass');
96
+
97
+ const priorEdit = read(handoff).lastEditAt;
98
+ const edits = hook('PostToolUse', 'state-persist.js', {
99
+ tool_name: 'Bash', tool_input: { command: 'echo changed > generated.txt' },
100
+ tool_response: 'opaque',
101
+ });
102
+ assert.equal(edits.stdout, '');
103
+ assert.ok(read(handoff).lastEditAt > priorEdit);
104
+
105
+ const { inferOutcome } = require(path.join(layout, 'hooks/scripts/codex-action-gate-post.js'));
106
+ assert.equal(inferOutcome({ ...shell, tool_response: 'done' }), 'unknown');
107
+ assert.equal(inferOutcome({ ...shell, tool_response: { stderr: 'error' } }), 'unknown');
108
+ assert.equal(inferOutcome({ ...shell, tool_response: { exitCode: 0, isError: true } }), 'failure');
109
+ assert.equal(inferOutcome({ tool_name: 'mcp__repo__update', tool_response: { isError: false } }), 'success');
110
+
111
+ const tool_use_id = 'gated-mcp-result';
112
+ const gated = {
113
+ host: 'codex', tool_use_id, tool_name: 'mcp__codex_apps__github__update_pull_request',
114
+ tool_input: { repository_full_name: 'example/repo', pr_number: 7, body: 'test fixture' },
115
+ };
116
+ hook('PreToolUse', 'codex-action-gate-pre.js', gated);
117
+ const audit = path.join(session, 'action-gate', tool_use_id + '.json');
118
+ hook('PostToolUse', 'codex-action-gate-post.js', { ...gated, tool_response: 'opaque' });
119
+ assert.equal(read(audit).executionOutcome, 'unknown');
120
+ hook('PostToolUse', 'codex-action-gate-post.js', { ...gated, tool_response: { exitCode: 1 } });
121
+ assert.equal(read(audit).executionOutcome, 'failure');
122
+ hook('PostToolUse', 'codex-action-gate-post.js', { ...gated, tool_response: 'opaque' });
123
+ assert.equal(read(audit).executionOutcome, 'failure');
124
+
125
+ const worker = { agent_id: 'worker-1', agent_type: 'default' };
126
+ hook('SubagentStart', 'subagent-start.js', worker);
127
+ const clean = hook('SubagentStop', 'subagent-stop.js', worker);
128
+ assert.equal(clean.stdout, '');
129
+ assert.equal(clean.stderr, '');
130
+ fs.writeFileSync(path.join(cwd, 'unexpected.txt'), 'change\n');
131
+ const changed = hook('SubagentStop', 'subagent-stop.js', worker);
132
+ const warning = JSON.parse(changed.stdout);
133
+ assert.deepEqual(Object.keys(warning), ['systemMessage']);
134
+ assert.match(warning.systemMessage, /unexpected\.txt/);
135
+ assert.equal(changed.stderr, '');
136
+ const scopeAudit = path.join(session, 'subagent-scope-last.json');
137
+ assert.equal(read(scopeAudit).outOfScope.length, 1);
138
+ assert.equal(hook('SubagentStop', 'subagent-stop.js', worker).stdout, '');
139
+ assert.deepEqual(read(scopeAudit).outOfScope, []);
140
+ assert.equal(fs.readFileSync(path.join(cwd, 'unexpected.txt'), 'utf8'), 'change\n');
141
+ console.log('PASS Codex ' + label + ' outcome and advisory SubagentStop contracts');
142
+ }
143
+ } finally {
144
+ fs.rmSync(temp, { recursive: true, force: true });
145
+ }
@@ -170,6 +170,7 @@ const subagentStop = runHook('hooks/scripts/subagent-stop.js', {
170
170
  agent_type: 'worker'
171
171
  }, stateHome);
172
172
  assert.strictEqual(subagentStop.status, 0, subagentStop.stderr);
173
- assert.match(subagentStop.stderr, /Subagent Scope Reminder/);
173
+ assert.strictEqual(subagentStop.stderr, '');
174
+ assert.match(JSON.parse(subagentStop.stdout).systemMessage, /Subagent Scope Reminder.*[\s\S]*unplanned-change\.txt/);
174
175
 
175
176
  console.log('OpenAI plugin runtime compatibility verified.');
@@ -18,8 +18,12 @@ for (const [canonical, packaged] of [
18
18
  ]) {
19
19
  const body = read(canonical);
20
20
  assert.strictEqual(read(packaged), body, canonical + ' packaged contract matches');
21
- assert.ok(/advisory replan/i.test(body), canonical + ' must describe replans as advisory');
22
- assert.ok(/Rule-of-3/i.test(body), canonical + ' must preserve same-signature failure reflection');
21
+ // #476: fable-mode moved the planning rules into the execution-phases reference its Workflow points to.
22
+ const phases = canonical === 'fable-mode/SKILL.md' && body.includes('references/execution-phases.md')
23
+ ? read('fable-mode/references/execution-phases.md') : '';
24
+ const contract = body + '\n' + phases;
25
+ assert.ok(/advisory replan|replans are advisory/i.test(contract), canonical + ' must describe replans as advisory');
26
+ assert.ok(/Rule-of-3/i.test(contract), canonical + ' must preserve same-signature failure reflection');
23
27
  assert.ok(!/at most two (?:full )?replans/i.test(body), canonical + ' must not imply a two-replan hard cap');
24
28
  }
25
29
  for (const rel of [
@@ -21,6 +21,23 @@ Codex and OpenCode are `Partial` in `liveHostVerification`. The Codex artifact v
21
21
 
22
22
  Exact title/body-only `update_pull_request` calls are Codex-only host-deferred mutations after an argument allowlist check; explicit required Gate hints and all additional fields retain the existing Gate. Native task scope, permissions and GitHub authorization remain authoritative. Canonical/package mechanism tests cover hashes, audit provenance, outcomes and negative controls; this does not establish candidate live-host coverage. See [Codex policy](codex-action-gate.md#codex-pr-titlebody-updates-host-deferred).
23
23
 
24
+ ### Codex post-tool and subagent-stop hooks
25
+
26
+ Codex emits `PostToolUse` for both successful and failed shell commands. Harness
27
+ requires a structured zero exit status to credit shell verification or clear a
28
+ tracked shell failure. Text-only or missing status leaves verification and
29
+ recovery state intact and is audited as `unknown` for observed gated actions.
30
+ Edits are still tracked when the outcome is unknown because side effects may
31
+ already have occurred.
32
+
33
+ Codex `SubagentStop` uses the documented JSON `systemMessage` field for a UI-only
34
+ warning when the scope audit detects a new violation. Each audit advances the
35
+ Git status baseline and replaces `subagent-scope-last.json`. A later silent stop
36
+ can therefore coexist with unresolved changes. The coordinator owns
37
+ [scope reconciliation before accepting the result](../fable-mode/references/execution-phases.md#verification-and-handoff),
38
+ even when the hook is silent. The source and package fixtures cover these
39
+ behaviors. Windows host delivery remains to be verified.
40
+
24
41
  ### Routing contract vs. host evidence
25
42
 
26
43
  The workflow plan controller rejects present non-array required/optional binding declarations before recording a requirement plan. This input-validation contract is covered by deterministic mechanism tests and does not change live-host evidence status.
@@ -4,7 +4,7 @@ description: "Stage large tasks through plans, named fable agents, failable chec
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.31.3
7
+ version: 0.54.1
8
8
  ---
9
9
 
10
10
  # Fable Mode
@@ -34,10 +34,10 @@ For explanation/profile-only lookup, read only `<this-skill-dir>/references/prof
34
34
  ## Workflow
35
35
 
36
36
  1. Discover the runtime and lock the authorized file scope before edits.
37
- 2. Per stage, set artifact, check, and required/optional bindings; dependency-ready stages disclose them, passing once resolved. Gaps never lock tools or Stop; advisory replans never halt. Rule-of-3 covers same-signature failures.
38
- 3. Resolve the requested behavior profile with `model-selector.js`; `opus`, `sonnet`/`sonnect`, and `haiku` are compatibility aliases, not model bindings.
39
- 4. Delegate by profile: orchestrator coordinates, reasoning takes bounded judgment, mechanical takes low-ambiguity work; workers never spawn workers.
37
+ 2. Plan via `<this-skill-dir>/references/execution-phases.md`.
38
+ 3. Use `model-selector.js`.
39
+ 4. Delegate by profile: orchestrator coordinates, reasoning takes bounded judgment, mechanical takes low-ambiguity work; workers never spawn workers. Before Codex dispatch, load/apply `<this-skill-dir>/references/execution-phases.md#verification-and-handoff`.
40
40
  5. The host runtime-model floor is advisory; record it, never block on model choice alone.
41
- 6. Run stage checks, cold-review high-stakes artifacts, and audit profile/runtime/fallback fields.
41
+ 6. On every Codex handoff or silent stop, load/apply `<this-skill-dir>/references/execution-phases.md#verification-and-handoff` before accepting results or releasing dependent stages. Run stage checks, cold-review high-stakes artifacts, and audit profile/runtime/fallback fields.
42
42
 
43
43
  Deep dive: <this-skill-dir>/references/model-matrix.md
@@ -4,7 +4,7 @@ description: "Reference guardrails for verified warnings and safe replacements;
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.31.3
7
+ version: 0.54.1
8
8
  ---
9
9
 
10
10
  # Execution Guardrails
@@ -4,7 +4,7 @@ description: "Reference mechanical behavior profile (legacy alias haiku) for bul
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.31.3
7
+ version: 0.54.1
8
8
  ---
9
9
 
10
10
  # Fable Mode — Haiku
@@ -4,7 +4,7 @@ description: "Reference orchestrator behavior profile (legacy alias opus) for st
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.31.3
7
+ version: 0.54.1
8
8
  ---
9
9
 
10
10
  # Fable Mode — Opus
@@ -4,7 +4,7 @@ description: "Reference reasoning behavior profile (legacy alias sonnet/sonnect)
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.31.3
7
+ version: 0.54.1
8
8
  ---
9
9
 
10
10
  # Fable Mode — Sonnet
@@ -17,13 +17,18 @@ flowchart TD
17
17
  Read relevant files and sources before producing an artifact. Record the
18
18
  authorized write scope. Give each stage an objective, dependencies, write set,
19
19
  expected output, exact check command, and pass condition. Required and optional
20
- bindings belong on the stage that needs them. Replan counts are advisory; after
21
- three same-signature failures, use Rule-of-3 `zoom-out`.
20
+ bindings belong on the stage that needs them. Replans are advisory and do not
21
+ halt tools or Stop; after three same-signature failures, use Rule-of-3
22
+ `zoom-out`.
22
23
 
23
24
  ## Profiles and delegation
24
25
 
25
- Resolve a requested behavior profile with Fable's profile selector and record
26
- it separately from the runtime choice. `fable-orchestrator`,
26
+ See the [model matrix](model-matrix.md) for profile details.
27
+
28
+ Resolve a requested behavior profile with Fable's `model-selector.js` and
29
+ record it separately from the runtime choice. `opus`, `sonnet`/`sonnect`, and
30
+ `haiku` are compatibility aliases for behavior profiles, not model bindings.
31
+ `fable-orchestrator`,
27
32
  `fable-worker-sonnet`, and `fable-worker-haiku` name coordination,
28
33
  reasoning/synthesis, and mechanical-work roles. These are behavior-profile
29
34
  aliases; they do not switch the runtime model. Preserve an explicit user or
@@ -104,3 +109,20 @@ Run each named check and review scope-guard evidence before delivery. When the
104
109
  selected plan requires independent verification, the verifier is read-only and
105
110
  uses a distinct worker identity after all other stages pass. Record a blocker
106
111
  or an evidence-backed result; do not discard unresolved requirements.
112
+
113
+ For Codex subagents, the coordinator MUST reconcile scope before accepting a
114
+ result or using it in a dependent stage, even if the stage check passed.
115
+
116
+ 1. Before dispatch, capture the worker worktree's starting state, including
117
+ existing local changes. At handoff, compare the committed, staged, unstaged,
118
+ and untracked changes since dispatch with the stage's declared `writeSet`.
119
+ 2. For unexpected or ambiguously attributed changes, establish ownership and
120
+ record the disposition. Exclude the changes from the result, revert only
121
+ attributable worker changes when authorized, or obtain explicit approval for
122
+ a scope change and follow the replanning rules. Record a blocker if the
123
+ coordinator cannot reconcile a path.
124
+
125
+ Run this check after every handoff, including silent stops. The Codex warning
126
+ and `subagent-scope-last.json` describe the latest hook observation. A clean
127
+ observation can replace an earlier warning while the corresponding change is
128
+ still present.
@@ -547,6 +547,11 @@ function finalizeExecution(payload, outcome, options = {}) {
547
547
  record.disposition = 'integrity-violation';
548
548
  record.integrityViolation = 'executed-payload-hash-differs-from-approved-payload';
549
549
  } else {
550
+ // A replay without status cannot replace an already observed outcome.
551
+ const known = record.executionOutcome === 'success' || record.executionOutcome === 'failure';
552
+ if (record.disposition === 'executed' && known && outcome === 'unknown') {
553
+ return { kind: 'audit', exitCode: 0, record };
554
+ }
550
555
  record.disposition = 'executed';
551
556
  record.executionOutcome = outcome;
552
557
  }
@@ -3,19 +3,10 @@
3
3
 
4
4
  const { finalizeExecution } = require('./action-gate');
5
5
 
6
- function inferOutcome(payload) {
7
- const response = (payload && (payload.tool_response || payload.toolResponse)) || {};
8
- const rawExitCode = response.exitCode ?? response.exit_code ?? payload?.exitCode ?? payload?.exit_code;
9
- if (typeof rawExitCode === 'number') return rawExitCode === 0 ? 'success' : 'failure';
10
- if (response.success === false || response.ok === false) return 'failure';
6
+ const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
11
7
 
12
- const stderr = response.stderr ?? payload?.stderr ?? '';
13
- if (typeof stderr === 'string' && stderr.trim()) {
14
- if (/\b(error|fail|failed|failure|exception|fatal|panic|traceback|denied|refused|cannot|unable)\b/i.test(stderr)) {
15
- return 'failure';
16
- }
17
- }
18
- return 'success';
8
+ function inferOutcome(payload) {
9
+ return readCodexToolOutcome(payload).outcome;
19
10
  }
20
11
 
21
12
  function processPayload(payload) {
@@ -24,8 +24,14 @@ const {
24
24
  } = require('./lib/fable-contracts');
25
25
  const { loadWorkflow, matchingRun } = require('./lib/workflow-runtime');
26
26
  const { createLearningOpportunity } = require('./lib/learning-opportunity');
27
+ const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
28
+ const codex = process.argv.includes('--codex');
27
29
 
28
30
  function resultState(payload) {
31
+ if (codex) {
32
+ const { outcome, exitCode, stdout, stderr } = readCodexToolOutcome(payload);
33
+ return { outcome, exitCode, evidence: (stderr.trim() || stdout).slice(-1000).trim() };
34
+ }
29
35
  const toolResponse = payload.tool_response || payload.tool_result || {};
30
36
  const stdout = toolResponse.stdout ?? payload.stdout ?? '';
31
37
  const stderr = toolResponse.stderr ?? payload.stderr ?? '';
@@ -36,7 +42,7 @@ function resultState(payload) {
36
42
  (exitCode !== undefined && exitCode !== 0) ||
37
43
  (exitCode === undefined && stderrSignal);
38
44
  const evidence = ((stderrSignal ? stderr : stdout) || '').slice(-1000).trim();
39
- return { failed, exitCode, evidence };
45
+ return { outcome: failed ? 'failure' : 'success', exitCode, evidence };
40
46
  }
41
47
 
42
48
  function unresolvedBindings(contract) {
@@ -46,8 +52,9 @@ function unresolvedBindings(contract) {
46
52
  : !['loaded', 'not-needed'].includes(binding.status));
47
53
  }
48
54
 
49
- function updateRunContract(entry, payload, command, sessionId) {
50
- const { failed, exitCode, evidence } = resultState(payload);
55
+ function updateRunContract(entry, payload, command, sessionId, result) {
56
+ const { outcome, exitCode, evidence } = result;
57
+ const failed = outcome === 'failure';
51
58
  const unresolved = unresolvedBindings(entry.contract);
52
59
  const status = failed ? 'fail' : unresolved.length ? 'binding-unresolved' : 'pass';
53
60
  const observedAt = new Date().toISOString();
@@ -93,7 +100,7 @@ function activeFableStages(runRoot) {
93
100
  return [];
94
101
  }
95
102
 
96
- function resolveLegacyContract(stateRoot, command, payload) {
103
+ function resolveLegacyContract(stateRoot, command, result) {
97
104
  const contractsDir = path.join(stateRoot, 'contracts');
98
105
  let files = [];
99
106
  try { files = fs.readdirSync(contractsDir).filter(file => file.endsWith('.json')); } catch (_) { return null; }
@@ -106,7 +113,8 @@ function resolveLegacyContract(stateRoot, command, payload) {
106
113
  matches.push({ manifest, filePath });
107
114
  }
108
115
  if (matches.length !== 1) return matches.length > 1 ? { ambiguous: true } : null;
109
- const { failed, evidence } = resultState(payload);
116
+ const { outcome, evidence } = result;
117
+ const failed = outcome === 'failure';
110
118
  const match = matches[0];
111
119
  match.manifest.status = failed ? 'fail' : 'pass';
112
120
  match.manifest.evidence = evidence;
@@ -124,6 +132,8 @@ process.stdin.on('end', () => {
124
132
 
125
133
  const command = ((payload.tool_input && payload.tool_input.command) || '').trim();
126
134
  if (!command) process.exit(0);
135
+ const result = resultState(payload);
136
+ if (result.outcome === 'unknown') process.exit(0);
127
137
 
128
138
  const root = getWorkspaceRoot(payload);
129
139
  const stateRoot = getStateRoot(root, payload);
@@ -161,7 +171,7 @@ process.stdin.on('end', () => {
161
171
  }
162
172
  const previousStatus = entry.contract.status;
163
173
  const previousVerifiedAt = entry.contract.verifiedAt || entry.contract.updatedAt || null;
164
- const contract = updateRunContract(entry, payload, command, sessionId);
174
+ const contract = updateRunContract(entry, payload, command, sessionId, result);
165
175
  if (previousStatus === 'fail' && contract.status === 'pass') {
166
176
  try {
167
177
  createLearningOpportunity(payload, {
@@ -199,7 +209,7 @@ process.stdin.on('end', () => {
199
209
 
200
210
  // Temporary compatibility with pre-Phase-3 manifests. New orchestration
201
211
  // must use run-scoped contracts; legacy manifests have no plan/run link.
202
- const legacy = resolveLegacyContract(stateRoot, command, payload);
212
+ const legacy = resolveLegacyContract(stateRoot, command, result);
203
213
  if (legacy && legacy.ambiguous) {
204
214
  console.error(`[Contract Test] Ambiguous legacy stage contracts matched: ${command}`);
205
215
  process.exit(0);
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // Codex PostToolUse runs for both zero and nonzero exits. A string response
4
+ // can contain arbitrary command output and is never evidence of an exit code.
5
+ function readCodexToolOutcome(payload) {
6
+ const raw = payload?.tool_response ?? payload?.toolResponse;
7
+ const response = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
8
+ const codes = [response.exitCode, response.exit_code, payload?.exitCode, payload?.exit_code]
9
+ .filter(Number.isInteger);
10
+ const exitCode = codes.find(code => code !== 0) ?? codes[0];
11
+ const stdout = typeof raw === 'string' ? raw : response.stdout ?? payload?.stdout;
12
+ const stderr = response.stderr ?? payload?.stderr;
13
+ const shell = ['Bash', 'PowerShell', 'exec_command'].includes(payload?.tool_name);
14
+ const failed = exitCode !== undefined && exitCode !== 0 ||
15
+ response.isError === true || response.is_error === true ||
16
+ response.success === false || response.ok === false;
17
+ const succeeded = exitCode === 0 || (!shell &&
18
+ (response.isError === false || response.is_error === false ||
19
+ response.success === true || response.ok === true));
20
+ return {
21
+ outcome: failed ? 'failure' : succeeded ? 'success' : 'unknown',
22
+ exitCode,
23
+ stdout: typeof stdout === 'string' ? stdout : '',
24
+ stderr: typeof stderr === 'string' ? stderr : '',
25
+ };
26
+ }
27
+
28
+ module.exports = { readCodexToolOutcome };
@@ -4,6 +4,8 @@ const path = require('path');
4
4
  const crypto = require('crypto');
5
5
  const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
6
6
  const { createLearningOpportunity } = require('./lib/learning-opportunity');
7
+ const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
8
+ const codex = process.argv.includes('--codex');
7
9
 
8
10
  // PostToolUse/PostToolUseFailure hooks in Claude Code receive their payload via stdin
9
11
  let inputData = '';
@@ -15,12 +17,14 @@ process.stdin.on('data', chunk => {
15
17
  process.stdin.on('end', () => {
16
18
  try {
17
19
  const payload = JSON.parse(inputData);
20
+ const codexResult = codex ? readCodexToolOutcome(payload) : null;
21
+ if (codexResult?.outcome === 'unknown') return;
18
22
  const hookEventName = payload.hook_event_name || payload.hookEventName || '';
19
23
  const isFailureEvent = hookEventName === 'PostToolUseFailure';
20
24
  const isSuccessEvent = hookEventName === 'PostToolUse';
21
25
  const toolResponse = payload.tool_response || {};
22
- const stdout = toolResponse.stdout ?? payload.stdout ?? '';
23
- const stderr = toolResponse.stderr ?? payload.stderr ?? '';
26
+ const stdout = codexResult?.stdout ?? toolResponse.stdout ?? payload.stdout ?? '';
27
+ const stderr = codexResult?.stderr ?? toolResponse.stderr ?? payload.stderr ?? '';
24
28
  const failureText = typeof payload.error === 'string' ? payload.error : '';
25
29
  const rawExitCode = toolResponse.exitCode ?? toolResponse.exit_code ?? payload.exitCode ?? payload.exit_code;
26
30
  const exitCode = typeof rawExitCode === 'number' ? rawExitCode : undefined;
@@ -33,11 +37,14 @@ process.stdin.on('end', () => {
33
37
  const explicitFailure = exitCode !== undefined && exitCode !== 0;
34
38
  const stderrSignal = typeof stderr === 'string' && stderr.trim().length > 0;
35
39
  const looksLikeError = /\b(error|fail|failed|failure|exception|fatal|panic|traceback|denied|refused|cannot|unable)\b/i.test(stderr);
36
- const isFailure = isFailureEvent || explicitFailure ||
40
+ const isFailure = codex ? codexResult.outcome === 'failure' : isFailureEvent || explicitFailure ||
37
41
  (!isSuccessEvent && exitCode === undefined && stderrSignal && looksLikeError);
38
- const errorText = isFailureEvent
42
+ const reportedError = isFailureEvent
39
43
  ? (failureText || (stderrSignal ? stderr : stdout) || '')
40
44
  : ((stderrSignal ? stderr : stdout) || failureText || '');
45
+ const errorText = reportedError || (codexResult?.outcome === 'failure'
46
+ ? (codexResult.exitCode === undefined ? 'Tool reported failure' : `Tool exited with code ${codexResult.exitCode}`)
47
+ : '');
41
48
 
42
49
  const root = getWorkspaceRoot(payload);
43
50
  const stateFile = path.join(getSessionDir(root, payload.session_id || payload.sessionId), 'rule-of-3-state.json');