audit-tools 0.34.20 → 0.34.21

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 (57) hide show
  1. package/dist/audit/cli/auditStep.d.ts +1 -0
  2. package/dist/audit/cli/auditStep.d.ts.map +1 -1
  3. package/dist/audit/cli/auditStep.js +5 -0
  4. package/dist/audit/cli/auditStep.js.map +1 -1
  5. package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
  6. package/dist/audit/cli/nextStepCommand.js +73 -0
  7. package/dist/audit/cli/nextStepCommand.js.map +1 -1
  8. package/dist/audit/cli/nextStepHelpers.d.ts +18 -1
  9. package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
  10. package/dist/audit/cli/nextStepHelpers.js +68 -0
  11. package/dist/audit/cli/nextStepHelpers.js.map +1 -1
  12. package/dist/audit/cli/steps.d.ts +4 -4
  13. package/dist/audit/cli/steps.d.ts.map +1 -1
  14. package/dist/audit/cli/steps.js +1 -0
  15. package/dist/audit/cli/steps.js.map +1 -1
  16. package/dist/audit/decompose/buildStructureDecomposition.d.ts +8 -0
  17. package/dist/audit/decompose/buildStructureDecomposition.d.ts.map +1 -1
  18. package/dist/audit/decompose/buildStructureDecomposition.js +14 -4
  19. package/dist/audit/decompose/buildStructureDecomposition.js.map +1 -1
  20. package/dist/audit/orchestrator/advanceTypes.d.ts +3 -0
  21. package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
  22. package/dist/audit/orchestrator/artifactFreshness.d.ts.map +1 -1
  23. package/dist/audit/orchestrator/artifactFreshness.js +6 -0
  24. package/dist/audit/orchestrator/artifactFreshness.js.map +1 -1
  25. package/dist/audit/orchestrator/artifactMetadata.d.ts.map +1 -1
  26. package/dist/audit/orchestrator/artifactMetadata.js +50 -10
  27. package/dist/audit/orchestrator/artifactMetadata.js.map +1 -1
  28. package/dist/audit/orchestrator/dependencySlices.d.ts +44 -0
  29. package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -0
  30. package/dist/audit/orchestrator/dependencySlices.js +149 -0
  31. package/dist/audit/orchestrator/dependencySlices.js.map +1 -0
  32. package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
  33. package/dist/audit/orchestrator/executorRunners.js +6 -0
  34. package/dist/audit/orchestrator/executorRunners.js.map +1 -1
  35. package/dist/audit/orchestrator/executors.d.ts.map +1 -1
  36. package/dist/audit/orchestrator/executors.js +9 -0
  37. package/dist/audit/orchestrator/executors.js.map +1 -1
  38. package/dist/audit/orchestrator/intentCheckpointGate.d.ts +45 -105
  39. package/dist/audit/orchestrator/intentCheckpointGate.d.ts.map +1 -1
  40. package/dist/audit/orchestrator/intentCheckpointGate.js +98 -163
  41. package/dist/audit/orchestrator/intentCheckpointGate.js.map +1 -1
  42. package/dist/audit/orchestrator/intentEquivalenceExecutor.d.ts +83 -0
  43. package/dist/audit/orchestrator/intentEquivalenceExecutor.d.ts.map +1 -0
  44. package/dist/audit/orchestrator/intentEquivalenceExecutor.js +188 -0
  45. package/dist/audit/orchestrator/intentEquivalenceExecutor.js.map +1 -0
  46. package/dist/audit/orchestrator/nextStep.d.ts.map +1 -1
  47. package/dist/audit/orchestrator/nextStep.js +4 -0
  48. package/dist/audit/orchestrator/nextStep.js.map +1 -1
  49. package/dist/audit/orchestrator/staleness.d.ts.map +1 -1
  50. package/dist/audit/orchestrator/staleness.js +39 -3
  51. package/dist/audit/orchestrator/staleness.js.map +1 -1
  52. package/dist/audit/orchestrator/state.d.ts.map +1 -1
  53. package/dist/audit/orchestrator/state.js +22 -0
  54. package/dist/audit/orchestrator/state.js.map +1 -1
  55. package/dist/audit/types/artifactMetadata.d.ts +43 -0
  56. package/dist/audit/types/artifactMetadata.d.ts.map +1 -1
  57. package/package.json +2 -1
@@ -1,66 +1,87 @@
1
1
  /**
2
- * O2 — the intent_checkpoint semantic-equivalence gate.
2
+ * O2 — the intent_checkpoint semantic-equivalence gate (DD-9, wired).
3
3
  *
4
- * The ONE place that decides whether a re-confirmed intent_checkpoint value is
5
- * semantically EQUIVALENT to the prior one (so dependents need not re-stale) or
6
- * CHANGED (so the `intent_checkpoint_current` obligation must re-fire and
7
- * downstream artifacts re-derive). A raw byte/JSON compare over-stales: a host
8
- * re-confirming the same intent with reordered keys, whitespace, or a benign
9
- * rephrase would needlessly invalidate the whole planning tree. A pure structural
10
- * compare under-stales: a genuine intent change phrased to hash-collide on the
11
- * normalized form would be silently dropped. So the gate is
12
- * normalize-then-bounded-LLM-judge:
4
+ * Decides whether a re-confirmed intent_checkpoint is semantically EQUIVALENT to
5
+ * the form downstreams last derived against (so dependents need not re-stale) or
6
+ * CHANGED (so the planning cascade re-derives). A raw byte/JSON compare
7
+ * over-stales: a host re-confirming the same intent with a fresh timestamp,
8
+ * reordered keys, or a benign rephrase would needlessly invalidate the whole
9
+ * planning tree. A pure structural compare under-stales: a genuine intent change
10
+ * phrased to normalize identically would be silently dropped.
13
11
  *
14
- * 1. NORMALIZE both values deterministically (`normalizeCheckpointValue`). Equal
15
- * normal forms ⟹ `unchanged` with no judge call (the common, free case).
16
- * 2. Otherwise a BOUNDED LLM judge decides semantic equivalence. The judge is
17
- * FAIL-SAFE: any uncertain / errored / malformed verdict resolves to
18
- * `'changed'` (INV-O2-fail-3) — the gate never silently treats an
19
- * unverified pair as equivalent.
12
+ * The semantic surface is SPLIT into two normal forms:
20
13
  *
21
- * VERSION-KEYED VERDICT CACHE (INV-O2-inv-5): a judge verdict is cached on
22
- * `(priorValue, newValue, gate_version)`. `gate_version` is a LOCALLY-resolved
23
- * token `hash(normalizeConfig) + judge-id token + prompt-template version` —
24
- * computed with NO network/API probe (INV-O2-inv-6). Bumping the normalize
25
- * config, swapping the locally-resolved judge, or revising the prompt template
26
- * invalidates every cached verdict deterministically; an unchanged trio is a
27
- * cache hit so a re-confirm never re-pays the judge.
14
+ * - STRUCTURED (`structuredFields`): scope/lens/filter/constraint/design-review
15
+ * fields. A structured delta is DETERMINISTICALLY `changed` an LLM judge
16
+ * never arbitrates a numeric/list delta (a `ceiling` 3→5 must never be waved
17
+ * through as "equivalent prose").
18
+ * - PROSE (`proseFields`): the free-text summaries. A prose-only delta is the
19
+ * ONLY thing the bounded host judge arbitrates, and the judge is FAIL-SAFE:
20
+ * anything but an explicit `equivalent` verdict resolves to `changed`.
21
+ *
22
+ * The judge is the HOST via a bounded step (conversation-first — audit-code has
23
+ * no in-process LLM): see `intentEquivalenceExecutor.ts` for the obligation /
24
+ * commit machinery and `artifactMetadata.ts` for how the committed baseline
25
+ * mirrors the intent entry's revision. There is no in-process lock choreography
26
+ * and no verdict cache: a verdict is materialized into the persisted baseline at
27
+ * commit, and the step round-trip re-checks the judged pair against the live
28
+ * pair before committing (an interleaved intent edit discards the verdict and
29
+ * re-fires the obligation).
28
30
  *
29
- * LOCK INTERLEAVE DISCIPLINE (INV-O2-inv-7 / inv-8, the O2 lock contract): the
30
- * judge is SLOW and MUST run OUTSIDE the artifact-tree lock. `runIntentCheckpointGate`
31
- * therefore: reads a ledger/version token under the lock, releases, runs the
32
- * judge unlocked, then RE-ACQUIRES the lock and compares the token captured at
33
- * read against the token now. Any interleaved append (token moved) forces a
34
- * re-derive bounded to N attempts. On exhaustion it falls back to taking the
35
- * lock ACROSS the judge for one final guaranteed-committing derivation, and
36
- * records that fallback firing through the best-effort friction sink (CE-010
37
- * residual: a contended friction append under the held non-reentrant lock is
38
- * swallowed best-effort, never blocking the commit).
31
+ * VERSION KEYING (INV-O2-inv-5/6): `computeGateVersion` is a LOCALLY-resolved
32
+ * token `hash(normalizeConfig) + judge-id token + prompt-template version`
33
+ * computed with NO network/API probe. The judge id is the constant `"host"`
34
+ * (conversation-first: the host agent is always the judge), so every component
35
+ * is derivable at compare time; a stale component invalidates the persisted
36
+ * baseline, which the executor resolves as `changed` (over-stale, safe).
37
+ */
38
+ import { hashContent, stableStringify } from 'audit-tools/shared';
39
+ /**
40
+ * The single active normalization config (INV-O2-inv-5 input). The two lists
41
+ * together cover every `IntentCheckpoint` field except the provenance pair
42
+ * (`confirmed_at`, `confirmed_by`) — which `NON_SEMANTIC_FIELDS_BY_ARTIFACT`
43
+ * also strips from the canonical content hash. `schema_version` is deliberately
44
+ * STRUCTURED (a schema migration is a semantic reinterpretation, not
45
+ * provenance).
39
46
  */
40
- import { captureStepBoundaryFriction, hashContent, stableStringify } from 'audit-tools/shared';
41
- /** The single active normalization config (INV-O2-inv-5 input). */
42
47
  export const DEFAULT_NORMALIZE_CONFIG = {
43
- version: 'intent-checkpoint-normalize/v1',
44
- semanticFields: ['scope_summary', 'intent_summary', 'free_form_intent', 'constraint_clauses'],
48
+ version: 'intent-checkpoint-normalize/v2',
49
+ structuredFields: [
50
+ 'schema_version',
51
+ 'excluded_scope',
52
+ 'must_not_touch',
53
+ 'filters',
54
+ 'disposition_overrides',
55
+ 'lens_selection',
56
+ 'design_review',
57
+ ],
58
+ // `constraint_clauses` is PROSE per DD-9's explicit listing (host_answer
59
+ // rephrases are judge-arbitrated): the clauses array rides the prose normal
60
+ // form in full, so a clause addition/removal is visible to the judge and a
61
+ // benign answer rephrase is judgeable rather than deterministically re-staling
62
+ // the cascade.
63
+ proseFields: [
64
+ 'scope_summary',
65
+ 'intent_summary',
66
+ 'free_form_intent',
67
+ 'constraint_clauses',
68
+ ],
45
69
  };
46
70
  /** Static prompt-template version — bump on any judge-prompt change. */
47
71
  export const INTENT_GATE_PROMPT_TEMPLATE_VERSION = 'intent-checkpoint-judge-prompt/v1';
48
72
  /**
49
- * Deterministically normalize an intent_checkpoint value to its semantic normal
50
- * form. Only `config.semanticFields` participate; values are canonically
51
- * serialized (stable key order) so reordering/whitespace is invisible. An absent
52
- * checkpoint normalizes to a stable empty marker so present-vs-absent is a real
53
- * difference, not a crash.
73
+ * The locally-resolved judge id (conversation-first: the host agent is always
74
+ * the judge). A constant so every `gate_version` component is derivable at
75
+ * compare time with no probe.
54
76
  */
55
- export function normalizeCheckpointValue(checkpoint, config = DEFAULT_NORMALIZE_CONFIG) {
56
- if (!checkpoint)
57
- return stableStringify({ __absent: true });
77
+ export const HOST_JUDGE_ID = 'host';
78
+ function projectFields(checkpoint, fields) {
58
79
  const projection = {};
59
- for (const field of config.semanticFields) {
80
+ for (const field of fields) {
60
81
  const value = checkpoint[field];
61
82
  if (value !== undefined) {
62
- // free_form_intent is whitespace-insensitive at the edges; clauses/objects
63
- // are compared structurally via the stable serializer.
83
+ // Prose is whitespace-insensitive at the edges; structured values are
84
+ // compared structurally via the stable serializer (key order invisible).
64
85
  projection[field] =
65
86
  typeof value === 'string' ? value.trim() : value;
66
87
  }
@@ -68,127 +89,41 @@ export function normalizeCheckpointValue(checkpoint, config = DEFAULT_NORMALIZE_
68
89
  return stableStringify(projection);
69
90
  }
70
91
  /**
71
- * Compute the LOCALLY-resolved `gate_version` cache key component:
72
- * `hash(normalizeConfig) + judge-id token + prompt-template version`.
73
- *
74
- * NO network/API probe (INV-O2-inv-6): the judge id is a caller-supplied LOCAL
75
- * token (e.g. a configured model id string already known to the host, or a
76
- * sentinel like `'host'`), never a live capability query. Bumping the normalize
77
- * config, the judge id, or the prompt template deterministically invalidates the
78
- * verdict cache.
92
+ * Deterministically normalize an intent_checkpoint value to its two semantic
93
+ * normal forms. An absent checkpoint normalizes to a stable empty marker so
94
+ * present-vs-absent is a real difference, not a crash.
79
95
  */
80
- export function computeGateVersion(input) {
81
- const normalizeConfig = input.normalizeConfig ?? DEFAULT_NORMALIZE_CONFIG;
82
- const promptTemplateVersion = input.promptTemplateVersion ?? INTENT_GATE_PROMPT_TEMPLATE_VERSION;
83
- const configHash = hashContent(stableStringify(normalizeConfig), { length: 16 });
84
- return `${configHash}:${input.judgeId}:${promptTemplateVersion}`;
85
- }
86
- /** Build the deterministic verdict-cache key from the version-keyed trio. */
87
- export function verdictCacheKey(priorNormalized, newNormalized, gateVersion) {
88
- return hashContent(stableStringify([priorNormalized, newNormalized, gateVersion]));
96
+ export function normalizeCheckpointForms(checkpoint, config = DEFAULT_NORMALIZE_CONFIG) {
97
+ if (!checkpoint) {
98
+ const absent = stableStringify({ __absent: true });
99
+ return { structured: absent, prose: absent };
100
+ }
101
+ return {
102
+ structured: projectFields(checkpoint, config.structuredFields),
103
+ prose: projectFields(checkpoint, config.proseFields),
104
+ };
89
105
  }
90
106
  /**
91
- * The normalize-then-bounded-LLM-judge equivalence gate.
92
- *
93
- * 1. Normalize both values; equal normal forms `unchanged`, no judge call.
94
- * 2. Cache hit on (priorNormalized, newNormalized, gate_version) cached verdict.
95
- * 3. Otherwise run the bounded judge; FAIL-SAFEuncertain/errored/non-boolean
96
- * `'changed'`. Cache and return.
97
- *
98
- * Pure decision: holds no lock and does no artifact IO. The lock-interleave
99
- * discipline lives in `runIntentCheckpointGate`.
107
+ * Compute the LOCALLY-resolved `gate_version` token:
108
+ * `hash(normalizeConfig) + judge-id token + prompt-template version`.
109
+ * NO network/API probe (INV-O2-inv-6). Bumping the normalize config, the judge
110
+ * id, or the prompt template deterministically invalidates the persisted
111
+ * baseline (the executor resolves the mismatch as `changed`over-stale, the
112
+ * safe direction).
100
113
  */
101
- export async function intentCheckpointEquivalenceGate(input) {
102
- const config = input.normalizeConfig ?? DEFAULT_NORMALIZE_CONFIG;
103
- const priorNormalized = normalizeCheckpointValue(input.prior, config);
104
- const newNormalized = normalizeCheckpointValue(input.next, config);
105
- const gateVersion = computeGateVersion({
106
- normalizeConfig: config,
107
- judgeId: input.judgeId,
108
- promptTemplateVersion: input.promptTemplateVersion,
109
- });
110
- if (priorNormalized === newNormalized) {
111
- return { verdict: 'unchanged', gateVersion, judged: false };
112
- }
113
- const cacheKey = verdictCacheKey(priorNormalized, newNormalized, gateVersion);
114
- const cached = input.cache?.get(cacheKey);
115
- if (cached !== undefined) {
116
- return { verdict: cached, gateVersion, judged: false };
117
- }
118
- let verdict;
119
- try {
120
- const equivalent = await input.judge({ priorNormalized, newNormalized });
121
- // FAIL-SAFE: only an explicit `true` resolves to unchanged; anything else
122
- // (false, non-boolean, undefined) is treated as changed.
123
- verdict = equivalent === true ? 'unchanged' : 'changed';
124
- }
125
- catch {
126
- // FAIL-SAFE: a judge error never silently passes as equivalent.
127
- verdict = 'changed';
128
- }
129
- input.cache?.set(cacheKey, verdict);
130
- return { verdict, gateVersion, judged: true };
114
+ export function computeGateVersion(input) {
115
+ const normalizeConfig = input?.normalizeConfig ?? DEFAULT_NORMALIZE_CONFIG;
116
+ const judgeId = input?.judgeId ?? HOST_JUDGE_ID;
117
+ const promptTemplateVersion = input?.promptTemplateVersion ?? INTENT_GATE_PROMPT_TEMPLATE_VERSION;
118
+ const configHash = hashContent(stableStringify(normalizeConfig), { length: 16 });
119
+ return `${configHash}:${judgeId}:${promptTemplateVersion}`;
131
120
  }
132
121
  /**
133
- * Run the intent_checkpoint gate under the O2 lock-interleave discipline.
134
- *
135
- * The judge is SLOW and runs OUTSIDE the held lock. Sequence per attempt:
136
- * 1. Acquire the lock; read the current ledger/version token; release.
137
- * 2. Run the bounded equivalence gate (judge) UNLOCKED.
138
- * 3. Re-acquire the lock; read the token again. If unchanged, COMMIT the verdict
139
- * under the lock and return. If an interleaved append moved the token,
140
- * release and re-derive (bounded to `maxAttempts`).
141
- * 4. On attempt exhaustion, take the lock ACROSS the judge for one final
142
- * guaranteed-committing derivation, recording the fallback firing through the
143
- * best-effort friction sink (CE-010 residual — never blocks the commit).
144
- *
145
- * `withLock` is the artifact-tree lock wrapper (e.g. `withFileLock` bound to the
146
- * artifact-tree lock path); `commit` persists the decided verdict under the held
147
- * lock and is the single mutation point.
122
+ * Hash one normal form for pair identification (the judge submission names the
123
+ * pair it judged by these hashes, and consumption re-derives them from the live
124
+ * checkpoint to detect an interleaved edit).
148
125
  */
149
- export async function runIntentCheckpointGate(deps) {
150
- const maxAttempts = deps.maxAttempts ?? 3;
151
- for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
152
- // (1) Capture the read-time token under the lock, then release.
153
- const readToken = await deps.withLock(() => deps.readLedgerToken());
154
- // (2) Run the slow judge UNLOCKED.
155
- const { verdict } = await deps.gate();
156
- // (3) Re-acquire; if no interleave, commit under the lock.
157
- const outcome = await deps.withLock(async () => {
158
- const nowToken = await deps.readLedgerToken();
159
- if (nowToken !== readToken) {
160
- // Interleaved append — bail out of this attempt and re-derive.
161
- return { committed: undefined, interleaved: true };
162
- }
163
- const committed = await deps.commit(verdict);
164
- return { committed, interleaved: false };
165
- });
166
- if (!outcome.interleaved) {
167
- return { verdict, committed: outcome.committed, usedFallback: false };
168
- }
169
- // else: token moved during the unlocked judge — loop and re-derive.
170
- }
171
- // (4) Attempts exhausted under repeated contention: take the lock ACROSS the
172
- // judge for one final guaranteed-committing derivation. Record the fallback
173
- // firing best-effort (CE-010 residual: a contended friction append under the
174
- // held non-reentrant lock is swallowed best-effort, never blocking the commit).
175
- return deps.withLock(async () => {
176
- if (deps.artifactsDir && deps.runId) {
177
- // Fire-and-forget but awaited: captureFrictionEvent is itself best-effort
178
- // and never throws, so it can never block the commit below.
179
- await captureStepBoundaryFriction(deps.artifactsDir, deps.runId, {
180
- eventType: 'intent_gate_fallback',
181
- discriminator: 'lock-across-judge-fallback',
182
- category: 'trap',
183
- severity: 'low',
184
- area: 'intent_checkpoint gate',
185
- note: 'intent_checkpoint gate fell back to taking the lock across the LLM judge after ' +
186
- `${maxAttempts} interleaved re-derive attempts; one guaranteed-committing derivation ran under the held lock.`,
187
- }, 'audit-code');
188
- }
189
- const { verdict } = await deps.gate();
190
- const committed = await deps.commit(verdict);
191
- return { verdict, committed, usedFallback: true };
192
- });
126
+ export function normalFormHash(normalized) {
127
+ return hashContent(normalized, { length: 16 });
193
128
  }
194
129
  //# sourceMappingURL=intentCheckpointGate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"intentCheckpointGate.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/intentCheckpointGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,2BAA2B,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBA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ACL,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC;QAC9D,KAAK,EAAE,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC;KACrD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAKlC;IACC,MAAM,eAAe,GAAG,KAAK,EAAE,eAAe,IAAI,wBAAwB,CAAC;IAC3E,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,aAAa,CAAC;IAChD,MAAM,qBAAqB,GACzB,KAAK,EAAE,qBAAqB,IAAI,mCAAmC,CAAC;IACtE,MAAM,UAAU,GAAG,WAAW,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IACjF,OAAO,GAAG,UAAU,IAAI,OAAO,IAAI,qBAAqB,EAAE,CAAC;AAC7D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * DD-9 — the intent-equivalence obligation's executor.
3
+ *
4
+ * Decides whether the live `intent_checkpoint.json` is semantically equivalent
5
+ * to the baseline downstreams last derived against, and COMMITS the resolution
6
+ * into `artifact_metadata.intent_baseline` — the revision authority the
7
+ * metadata stamper mirrors (see `artifactMetadata.ts`): a committed `changed`
8
+ * advances `baseline.revision` (downstreams re-stale exactly once); an
9
+ * `equivalent` advances only the normal forms (downstreams never notice).
10
+ *
11
+ * Arms (see `deriveIntentEquivalenceStatus`):
12
+ * - `satisfied` — no checkpoint, or forms match the gate-current baseline.
13
+ * - `stamp_baseline` — no baseline yet: stamp from the current checkpoint
14
+ * (deterministic, drainable). First-contact on legacy run dirs.
15
+ * - `gate_version_stale` — the persisted baseline predates the current
16
+ * normalize-config / judge / prompt-template trio: resolve as CHANGED
17
+ * (over-stale, the safe direction; the old normal forms are not comparable).
18
+ * - `structured_changed` — the STRUCTURED normal form moved: deterministically
19
+ * CHANGED, no judge (an LLM must never arbitrate a numeric/list delta).
20
+ * - `prose_judgment_pending` — structured equal, prose moved: the bounded host
21
+ * judge owns the verdict (conversation flow emits the judge step; pure
22
+ * headless resolves as CHANGED, fail-safe).
23
+ *
24
+ * A judge submission names the pair it judged (`judged_pair` normal-form
25
+ * hashes); consumption re-derives the live pair and DISCARDS a stale verdict
26
+ * (the checkpoint moved again mid-judgment) so the obligation re-fires on the
27
+ * new pair — the O2 interleave property realized by the step round-trip itself.
28
+ */
29
+ import { z } from "zod";
30
+ import type { ArtifactBundle } from "../io/artifacts.js";
31
+ import type { ExecutorRunResult } from "./executorResult.js";
32
+ export declare const IntentEquivalenceVerdictSchema: z.ZodObject<{
33
+ verdict: z.ZodEnum<["equivalent", "changed"]>;
34
+ judged_pair: z.ZodObject<{
35
+ prior_hash: z.ZodString;
36
+ new_hash: z.ZodString;
37
+ }, "strict", z.ZodTypeAny, {
38
+ prior_hash: string;
39
+ new_hash: string;
40
+ }, {
41
+ prior_hash: string;
42
+ new_hash: string;
43
+ }>;
44
+ }, "strict", z.ZodTypeAny, {
45
+ verdict: "changed" | "equivalent";
46
+ judged_pair: {
47
+ prior_hash: string;
48
+ new_hash: string;
49
+ };
50
+ }, {
51
+ verdict: "changed" | "equivalent";
52
+ judged_pair: {
53
+ prior_hash: string;
54
+ new_hash: string;
55
+ };
56
+ }>;
57
+ export type IntentEquivalenceVerdictSubmission = z.infer<typeof IntentEquivalenceVerdictSchema>;
58
+ export type IntentEquivalenceStatus = {
59
+ kind: "satisfied";
60
+ } | {
61
+ kind: "stamp_baseline";
62
+ } | {
63
+ kind: "gate_version_stale";
64
+ } | {
65
+ kind: "structured_changed";
66
+ } | {
67
+ kind: "prose_judgment_pending";
68
+ prior_prose: string;
69
+ current_prose: string;
70
+ prior_hash: string;
71
+ new_hash: string;
72
+ };
73
+ /** Pure derivation of the obligation's state from the live bundle. */
74
+ export declare function deriveIntentEquivalenceStatus(bundle: ArtifactBundle): IntentEquivalenceStatus;
75
+ /**
76
+ * Resolve the obligation. `verdict` is the consumed judge submission when one
77
+ * arrived this step; absent, every arm resolves deterministically — including
78
+ * `prose_judgment_pending` → CHANGED, which is only reachable verdict-less in
79
+ * the pure-headless drain (the conversation flow emits the judge step instead)
80
+ * and is the fail-safe direction there.
81
+ */
82
+ export declare function runIntentEquivalenceResolve(bundle: ArtifactBundle, verdict?: IntentEquivalenceVerdictSubmission): ExecutorRunResult;
83
+ //# sourceMappingURL=intentEquivalenceExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intentEquivalenceExecutor.d.ts","sourceRoot":"","sources":["../../../src/audit/orchestrator/intentEquivalenceExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;EAUhC,CAAC;AACZ,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CACtD,OAAO,8BAA8B,CACtC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IACE,IAAI,EAAE,wBAAwB,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,sEAAsE;AACtE,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,cAAc,GACrB,uBAAuB,CAsBzB;AAsBD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,kCAAkC,GAC3C,iBAAiB,CAsHnB"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * DD-9 — the intent-equivalence obligation's executor.
3
+ *
4
+ * Decides whether the live `intent_checkpoint.json` is semantically equivalent
5
+ * to the baseline downstreams last derived against, and COMMITS the resolution
6
+ * into `artifact_metadata.intent_baseline` — the revision authority the
7
+ * metadata stamper mirrors (see `artifactMetadata.ts`): a committed `changed`
8
+ * advances `baseline.revision` (downstreams re-stale exactly once); an
9
+ * `equivalent` advances only the normal forms (downstreams never notice).
10
+ *
11
+ * Arms (see `deriveIntentEquivalenceStatus`):
12
+ * - `satisfied` — no checkpoint, or forms match the gate-current baseline.
13
+ * - `stamp_baseline` — no baseline yet: stamp from the current checkpoint
14
+ * (deterministic, drainable). First-contact on legacy run dirs.
15
+ * - `gate_version_stale` — the persisted baseline predates the current
16
+ * normalize-config / judge / prompt-template trio: resolve as CHANGED
17
+ * (over-stale, the safe direction; the old normal forms are not comparable).
18
+ * - `structured_changed` — the STRUCTURED normal form moved: deterministically
19
+ * CHANGED, no judge (an LLM must never arbitrate a numeric/list delta).
20
+ * - `prose_judgment_pending` — structured equal, prose moved: the bounded host
21
+ * judge owns the verdict (conversation flow emits the judge step; pure
22
+ * headless resolves as CHANGED, fail-safe).
23
+ *
24
+ * A judge submission names the pair it judged (`judged_pair` normal-form
25
+ * hashes); consumption re-derives the live pair and DISCARDS a stale verdict
26
+ * (the checkpoint moved again mid-judgment) so the obligation re-fires on the
27
+ * new pair — the O2 interleave property realized by the step round-trip itself.
28
+ */
29
+ import { z } from "zod";
30
+ import { METADATA_SCHEMA_VERSION } from "../types/artifactMetadata.js";
31
+ import { computeGateVersion, normalizeCheckpointForms, normalFormHash, } from "./intentCheckpointGate.js";
32
+ import { hashArtifactValue } from "./artifactFreshness.js";
33
+ export const IntentEquivalenceVerdictSchema = z
34
+ .object({
35
+ verdict: z.enum(["equivalent", "changed"]),
36
+ judged_pair: z
37
+ .object({
38
+ prior_hash: z.string(),
39
+ new_hash: z.string(),
40
+ })
41
+ .strict(),
42
+ })
43
+ .strict();
44
+ /** Pure derivation of the obligation's state from the live bundle. */
45
+ export function deriveIntentEquivalenceStatus(bundle) {
46
+ const checkpoint = bundle.intent_checkpoint;
47
+ if (!checkpoint)
48
+ return { kind: "satisfied" };
49
+ const baseline = bundle.artifact_metadata?.intent_baseline;
50
+ if (!baseline)
51
+ return { kind: "stamp_baseline" };
52
+ if (baseline.gate_version !== computeGateVersion()) {
53
+ return { kind: "gate_version_stale" };
54
+ }
55
+ const forms = normalizeCheckpointForms(checkpoint);
56
+ if (forms.structured !== baseline.normalized_structured) {
57
+ return { kind: "structured_changed" };
58
+ }
59
+ if (forms.prose !== baseline.normalized_prose) {
60
+ return {
61
+ kind: "prose_judgment_pending",
62
+ prior_prose: baseline.normalized_prose,
63
+ current_prose: forms.prose,
64
+ prior_hash: normalFormHash(baseline.normalized_prose),
65
+ new_hash: normalFormHash(forms.prose),
66
+ };
67
+ }
68
+ return { kind: "satisfied" };
69
+ }
70
+ function withBaseline(bundle, baseline) {
71
+ const manifest = bundle.artifact_metadata ?? {
72
+ metadata_schema_version: METADATA_SCHEMA_VERSION,
73
+ artifacts: {},
74
+ };
75
+ return {
76
+ ...bundle,
77
+ artifact_metadata: { ...manifest, intent_baseline: baseline },
78
+ };
79
+ }
80
+ function currentEntryRevision(bundle) {
81
+ return (bundle.artifact_metadata?.artifacts["intent_checkpoint.json"]?.revision ?? 0);
82
+ }
83
+ /**
84
+ * Resolve the obligation. `verdict` is the consumed judge submission when one
85
+ * arrived this step; absent, every arm resolves deterministically — including
86
+ * `prose_judgment_pending` → CHANGED, which is only reachable verdict-less in
87
+ * the pure-headless drain (the conversation flow emits the judge step instead)
88
+ * and is the fail-safe direction there.
89
+ */
90
+ export function runIntentEquivalenceResolve(bundle, verdict) {
91
+ const status = deriveIntentEquivalenceStatus(bundle);
92
+ const checkpoint = bundle.intent_checkpoint;
93
+ if (status.kind === "satisfied" || !checkpoint) {
94
+ return {
95
+ updated: bundle,
96
+ artifacts_written: [],
97
+ progress_summary: "Intent-equivalence baseline already current; nothing to resolve.",
98
+ };
99
+ }
100
+ const forms = normalizeCheckpointForms(checkpoint);
101
+ const gateVersion = computeGateVersion();
102
+ const resolveChanged = (why) => {
103
+ const baseline = {
104
+ normalized_structured: forms.structured,
105
+ normalized_prose: forms.prose,
106
+ revision: currentEntryRevision(bundle) + 1,
107
+ gate_version: gateVersion,
108
+ };
109
+ return {
110
+ updated: withBaseline(bundle, baseline),
111
+ artifacts_written: [],
112
+ progress_summary: `Intent checkpoint resolved as CHANGED (${why}); downstream planning artifacts re-stale once.`,
113
+ };
114
+ };
115
+ if (status.kind === "stamp_baseline") {
116
+ // First contact. If the recorded entry hash does NOT match the live
117
+ // checkpoint, a change is PENDING whose prior semantics are unknowable (no
118
+ // baseline was ever recorded) — adopting the old revision here would let
119
+ // the revision mirror restamp the entry and silently evaporate the
120
+ // downstream staleness that change legitimately owes (fail-OPEN on legacy
121
+ // run dirs). Resolve it as CHANGED instead (over-stale, safe). Only a
122
+ // hash-consistent first contact stamps quietly at the current revision.
123
+ const entry = bundle.artifact_metadata?.artifacts["intent_checkpoint.json"];
124
+ if (entry &&
125
+ entry.content_hash !== hashArtifactValue("intent_checkpoint.json", checkpoint)) {
126
+ return resolveChanged("first contact with a pending checkpoint change; prior semantics unrecorded");
127
+ }
128
+ const baseline = {
129
+ normalized_structured: forms.structured,
130
+ normalized_prose: forms.prose,
131
+ // Mirror what the ordinary bump rules will assign this entry at the next
132
+ // metadata pass: an existing entry keeps its revision; a first-ever entry
133
+ // gets 1 (0 + 1).
134
+ revision: Math.max(currentEntryRevision(bundle), 1),
135
+ gate_version: gateVersion,
136
+ };
137
+ return {
138
+ updated: withBaseline(bundle, baseline),
139
+ artifacts_written: [],
140
+ progress_summary: "Stamped the intent-equivalence baseline from the current checkpoint (first contact).",
141
+ };
142
+ }
143
+ if (status.kind === "gate_version_stale") {
144
+ return resolveChanged("normalize/judge/prompt version moved; prior baseline not comparable");
145
+ }
146
+ if (status.kind === "structured_changed") {
147
+ return resolveChanged("structured intent fields differ — deterministic, never LLM-judged");
148
+ }
149
+ // prose_judgment_pending
150
+ if (!verdict) {
151
+ return resolveChanged("prose differs and no host judge is available (headless fail-safe)");
152
+ }
153
+ if (verdict.judged_pair.prior_hash !== status.prior_hash ||
154
+ verdict.judged_pair.new_hash !== status.new_hash) {
155
+ // The checkpoint moved again mid-judgment: discard the stale verdict; the
156
+ // obligation stays pending and the judge step re-fires on the live pair.
157
+ // Loud on stderr (mirrors the quarantine path) — the host otherwise sees a
158
+ // fresh judge step with different hashes and no statement of why its
159
+ // verdict vanished.
160
+ process.stderr.write(`[audit-code] intent-equivalence verdict discarded: it judged pair ` +
161
+ `${verdict.judged_pair.prior_hash}:${verdict.judged_pair.new_hash} but the live pair is ` +
162
+ `${status.prior_hash}:${status.new_hash} (the checkpoint changed again mid-judgment). ` +
163
+ `The judge step re-fires with the current pair.\n`);
164
+ return {
165
+ updated: bundle,
166
+ artifacts_written: [],
167
+ progress_summary: "Discarded a stale intent-equivalence verdict (the checkpoint changed again mid-judgment); the judge step re-fires on the live pair.",
168
+ };
169
+ }
170
+ if (verdict.verdict === "changed") {
171
+ return resolveChanged("host judge verdict: changed");
172
+ }
173
+ // equivalent: advance the normal forms; the revision authority stays put, so
174
+ // downstream `dependency_revisions` compares stay clean and nothing re-derives.
175
+ const baseline = {
176
+ normalized_structured: forms.structured,
177
+ normalized_prose: forms.prose,
178
+ revision: bundle.artifact_metadata?.intent_baseline?.revision ??
179
+ Math.max(currentEntryRevision(bundle), 1),
180
+ gate_version: gateVersion,
181
+ };
182
+ return {
183
+ updated: withBaseline(bundle, baseline),
184
+ artifacts_written: [],
185
+ progress_summary: "Host judge verdict: EQUIVALENT — baseline normal forms advanced; downstream planning artifacts stay fresh (no re-derivation).",
186
+ };
187
+ }
188
+ //# sourceMappingURL=intentEquivalenceExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intentEquivalenceExecutor.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/intentEquivalenceExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAIvE,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC;KAC5C,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAC1C,WAAW,EAAE,CAAC;SACX,MAAM,CAAC;QACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;KACrB,CAAC;SACD,MAAM,EAAE;CACZ,CAAC;KACD,MAAM,EAAE,CAAC;AAkBZ,sEAAsE;AACtE,MAAM,UAAU,6BAA6B,CAC3C,MAAsB;IAEtB,MAAM,UAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAC5C,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC9C,MAAM,QAAQ,GAAG,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC;IAC3D,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,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ACH,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChD;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,qBAA0B,GAClC,gBAAgB,CA6ClB;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAEjC"}
@@ -21,6 +21,10 @@ export const PRIORITY = [
21
21
  "design_assessment_current",
22
22
  "structure_decomposition_current",
23
23
  "intent_checkpoint_current",
24
+ // DD-9: the equivalence gate sits between the checkpoint and EVERY consumer
25
+ // of it (charters, coverage, tasks all derive at/below the charter slot), so
26
+ // a pending prose judgment pauses the cascade instead of racing it.
27
+ "intent_equivalence_current",
24
28
  "charter_extraction_current",
25
29
  "charter_delta_current",
26
30
  "design_review_contract_completed",