audit-tools 0.50.3 → 0.50.6
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.
- package/dist/audit/cli/auditStep.d.ts +30 -0
- package/dist/audit/cli/auditStep.d.ts.map +1 -1
- package/dist/audit/cli/auditStep.js +50 -0
- package/dist/audit/cli/auditStep.js.map +1 -1
- package/dist/audit/cli/foldTransaction.d.ts +103 -0
- package/dist/audit/cli/foldTransaction.d.ts.map +1 -0
- package/dist/audit/cli/foldTransaction.js +243 -0
- package/dist/audit/cli/foldTransaction.js.map +1 -0
- package/dist/audit/cli/nextStepHelpers.d.ts +109 -28
- package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
- package/dist/audit/cli/nextStepHelpers.js +645 -560
- package/dist/audit/cli/nextStepHelpers.js.map +1 -1
- package/dist/audit/cli/reviewRun.d.ts +15 -3
- package/dist/audit/cli/reviewRun.d.ts.map +1 -1
- package/dist/audit/cli/reviewRun.js +39 -13
- package/dist/audit/cli/reviewRun.js.map +1 -1
- package/dist/audit/orchestrator/advance.d.ts +38 -36
- package/dist/audit/orchestrator/advance.d.ts.map +1 -1
- package/dist/audit/orchestrator/advance.js +126 -82
- package/dist/audit/orchestrator/advance.js.map +1 -1
- package/dist/audit/orchestrator/advanceTypes.d.ts +23 -0
- package/dist/audit/orchestrator/advanceTypes.d.ts.map +1 -1
- package/dist/audit/orchestrator/autoFixExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/autoFixExecutor.js +10 -8
- package/dist/audit/orchestrator/autoFixExecutor.js.map +1 -1
- package/dist/audit/orchestrator/designReviewSnapshot.d.ts +8 -2
- package/dist/audit/orchestrator/designReviewSnapshot.d.ts.map +1 -1
- package/dist/audit/orchestrator/designReviewSnapshot.js +12 -6
- package/dist/audit/orchestrator/designReviewSnapshot.js.map +1 -1
- package/dist/audit/orchestrator/executorRunners.d.ts.map +1 -1
- package/dist/audit/orchestrator/executorRunners.js +1 -1
- package/dist/audit/orchestrator/executorRunners.js.map +1 -1
- package/dist/audit/orchestrator/executors.d.ts.map +1 -1
- package/dist/audit/orchestrator/executors.js +1 -1
- package/dist/audit/orchestrator/executors.js.map +1 -1
- package/dist/audit/orchestrator/hostInputPause.d.ts +0 -33
- package/dist/audit/orchestrator/hostInputPause.d.ts.map +1 -1
- package/dist/audit/orchestrator/hostInputPause.js +6 -64
- package/dist/audit/orchestrator/hostInputPause.js.map +1 -1
- package/dist/audit/orchestrator/localCommands.d.ts +9 -4
- package/dist/audit/orchestrator/localCommands.d.ts.map +1 -1
- package/dist/audit/orchestrator/localCommands.js +19 -7
- package/dist/audit/orchestrator/localCommands.js.map +1 -1
- package/dist/audit/orchestrator/obligationPolicy.d.ts +90 -0
- package/dist/audit/orchestrator/obligationPolicy.d.ts.map +1 -0
- package/dist/audit/orchestrator/obligationPolicy.js +228 -0
- package/dist/audit/orchestrator/obligationPolicy.js.map +1 -0
- package/dist/audit/orchestrator/reviewPackets.d.ts.map +1 -1
- package/dist/audit/orchestrator/reviewPackets.js +4 -6
- package/dist/audit/orchestrator/reviewPackets.js.map +1 -1
- package/dist/audit/orchestrator/selectiveDeepening/shared.d.ts +0 -1
- package/dist/audit/orchestrator/selectiveDeepening/shared.d.ts.map +1 -1
- package/dist/audit/orchestrator/selectiveDeepening/shared.js +5 -6
- package/dist/audit/orchestrator/selectiveDeepening/shared.js.map +1 -1
- package/dist/audit/orchestrator/syntaxResolutionExecutor.d.ts +1 -1
- package/dist/audit/orchestrator/syntaxResolutionExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/syntaxResolutionExecutor.js +7 -7
- package/dist/audit/orchestrator/syntaxResolutionExecutor.js.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +4 -3
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.js +56 -9
- package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +3 -2
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js +8 -6
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -1
- package/dist/audit/systemic/systemicChallengeLoop.d.ts +8 -4
- package/dist/audit/systemic/systemicChallengeLoop.d.ts.map +1 -1
- package/dist/audit/systemic/systemicChallengeLoop.js +9 -5
- package/dist/audit/systemic/systemicChallengeLoop.js.map +1 -1
- package/dist/audit/types/systemicChallenge.d.ts +35 -7
- package/dist/audit/types/systemicChallenge.d.ts.map +1 -1
- package/dist/shared/engine/obligationEngine.d.ts +45 -11
- package/dist/shared/engine/obligationEngine.d.ts.map +1 -1
- package/dist/shared/engine/obligationEngine.js +41 -7
- package/dist/shared/engine/obligationEngine.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { resolveCharterCeiling, ceilingRequestsCharters } from "./charterExtractionExecutor.js";
|
|
2
2
|
import { aggregateMetricsDigest } from "../systemic/aggregateMetricsDigest.js";
|
|
3
3
|
import { foldChallengeRound } from "../systemic/systemicChallengeLoop.js";
|
|
4
|
+
/**
|
|
5
|
+
* Convergence rule: the loop terminates only after this many CONSECUTIVE quiet
|
|
6
|
+
* (dry) rounds. Owner decision 2026-08-28: under a one-round rule, a single
|
|
7
|
+
* re-consumed or duplicate submission reports a dry round and terminates the
|
|
8
|
+
* adversary loop permanently — durable submission staging is the class fix
|
|
9
|
+
* (CX-02 blocker 3); two consecutive quiet rounds remove the single-event
|
|
10
|
+
* trigger. Cost accepted: one extra adversary round per audit. The applied
|
|
11
|
+
* rule is recorded on the register (`convergence_rule`) so the artifact is
|
|
12
|
+
* self-describing.
|
|
13
|
+
*/
|
|
14
|
+
const QUIET_ROUNDS_TO_CONVERGE = 2;
|
|
15
|
+
function appliedConvergenceRule() {
|
|
16
|
+
return { quiet_rounds_required: QUIET_ROUNDS_TO_CONVERGE };
|
|
17
|
+
}
|
|
4
18
|
function omittedRegister(ceiling, generated_at) {
|
|
5
19
|
return {
|
|
6
20
|
generated_at,
|
|
@@ -9,6 +23,7 @@ function omittedRegister(ceiling, generated_at) {
|
|
|
9
23
|
status: "omitted",
|
|
10
24
|
rounds: [],
|
|
11
25
|
converged: true,
|
|
26
|
+
convergence_rule: appliedConvergenceRule(),
|
|
12
27
|
findings: [],
|
|
13
28
|
validation_issues: [],
|
|
14
29
|
};
|
|
@@ -26,16 +41,32 @@ function omittedRegister(ceiling, generated_at) {
|
|
|
26
41
|
* conversation-first default; mirrors the charter-clarification omit).
|
|
27
42
|
* - **run** (`deep`/`deepest` ceiling): assemble the metrics digest and fold each
|
|
28
43
|
* submitted challenge round into the register. An EMPTY submission (a round that
|
|
29
|
-
* surfaced nothing new)
|
|
30
|
-
*
|
|
44
|
+
* surfaced nothing new) is a QUIET round; the register marks `converged` only
|
|
45
|
+
* after {@link QUIET_ROUNDS_TO_CONVERGE} CONSECUTIVE quiet rounds. A non-empty
|
|
46
|
+
* submission appends a round and keeps the loop open for the next round.
|
|
31
47
|
*
|
|
32
48
|
* The first run (no submission yet) computes the digest and writes an OPEN register
|
|
33
49
|
* (converged:false) so the relay step can dispatch the adversary; each subsequent run
|
|
34
50
|
* with a submission folds a round.
|
|
35
51
|
*/
|
|
36
|
-
export function runSystemicChallengeExecutor(bundle, submission) {
|
|
52
|
+
export function runSystemicChallengeExecutor(bundle, submission, submissionHash) {
|
|
37
53
|
const ceiling = resolveCharterCeiling(bundle.intent_checkpoint);
|
|
38
54
|
const generated_at = new Date().toISOString();
|
|
55
|
+
// Iterative-fold duplicate guard (CX-02 landing 3): a submission whose
|
|
56
|
+
// content hash the register already folded is IGNORED — never folded again,
|
|
57
|
+
// and above all never counted as a quiet round, which is what would converge
|
|
58
|
+
// the adversary loop falsely and permanently. Reachable when a crash between
|
|
59
|
+
// the fold's core commit and its staged-submission cleanup restores an
|
|
60
|
+
// already-folded submission.
|
|
61
|
+
if (submission &&
|
|
62
|
+
submissionHash &&
|
|
63
|
+
bundle.systemic_challenge?.folded_submission_hashes?.includes(submissionHash)) {
|
|
64
|
+
return {
|
|
65
|
+
updated: { ...bundle },
|
|
66
|
+
artifacts_written: ["systemic_challenge.json"],
|
|
67
|
+
progress_summary: "Systemic challenge: duplicate round submission ignored (its content hash is already folded into the register).",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
39
70
|
if (!ceilingRequestsCharters(ceiling)) {
|
|
40
71
|
const omitted = omittedRegister(ceiling, generated_at);
|
|
41
72
|
return {
|
|
@@ -58,7 +89,11 @@ export function runSystemicChallengeExecutor(bundle, submission) {
|
|
|
58
89
|
ceiling,
|
|
59
90
|
metrics,
|
|
60
91
|
rounds: priorRounds,
|
|
92
|
+
...(prior?.folded_submission_hashes
|
|
93
|
+
? { folded_submission_hashes: prior.folded_submission_hashes }
|
|
94
|
+
: {}),
|
|
61
95
|
converged: false,
|
|
96
|
+
convergence_rule: appliedConvergenceRule(),
|
|
62
97
|
findings: priorFindings,
|
|
63
98
|
validation_issues: prior?.validation_issues ?? [],
|
|
64
99
|
};
|
|
@@ -81,14 +116,24 @@ export function runSystemicChallengeExecutor(bundle, submission) {
|
|
|
81
116
|
new_finding_ids: folded.new_finding_ids,
|
|
82
117
|
dry: folded.dry,
|
|
83
118
|
};
|
|
119
|
+
const rounds = [...priorRounds, round];
|
|
120
|
+
const foldedHashes = submissionHash
|
|
121
|
+
? [...(prior?.folded_submission_hashes ?? []), submissionHash]
|
|
122
|
+
: prior?.folded_submission_hashes;
|
|
123
|
+
// CONSECUTIVE-QUIET convergence: the loop terminates only when the last
|
|
124
|
+
// QUIET_ROUNDS_TO_CONVERGE rounds were ALL dry. Derived from the persisted
|
|
125
|
+
// rounds themselves — no separate counter state to drift.
|
|
126
|
+
const converged = rounds.length >= QUIET_ROUNDS_TO_CONVERGE &&
|
|
127
|
+
rounds.slice(-QUIET_ROUNDS_TO_CONVERGE).every((r) => r.dry);
|
|
84
128
|
const register = {
|
|
85
129
|
generated_at,
|
|
86
130
|
target: "systemic_challenge",
|
|
87
131
|
ceiling,
|
|
88
132
|
metrics,
|
|
89
|
-
rounds
|
|
90
|
-
|
|
91
|
-
converged
|
|
133
|
+
rounds,
|
|
134
|
+
...(foldedHashes ? { folded_submission_hashes: foldedHashes } : {}),
|
|
135
|
+
converged,
|
|
136
|
+
convergence_rule: appliedConvergenceRule(),
|
|
92
137
|
findings: folded.findings,
|
|
93
138
|
validation_issues: [
|
|
94
139
|
...(prior?.validation_issues ?? []),
|
|
@@ -99,9 +144,11 @@ export function runSystemicChallengeExecutor(bundle, submission) {
|
|
|
99
144
|
updated: { ...bundle, systemic_challenge: register },
|
|
100
145
|
artifacts_written: ["systemic_challenge.json"],
|
|
101
146
|
progress_summary: `Systemic challenge round ${round.round}: ${folded.new_finding_ids.length} new improvement(s)` +
|
|
102
|
-
(
|
|
103
|
-
?
|
|
104
|
-
:
|
|
147
|
+
(converged
|
|
148
|
+
? ` — nothing new for ${QUIET_ROUNDS_TO_CONVERGE} consecutive rounds, loop converged.`
|
|
149
|
+
: folded.dry
|
|
150
|
+
? " — quiet round; the loop converges after the next consecutive quiet round."
|
|
151
|
+
: `, ${folded.findings.length} total; loop continues.`),
|
|
105
152
|
};
|
|
106
153
|
}
|
|
107
154
|
//# sourceMappingURL=systemicChallengeExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemicChallengeExecutor.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/systemicChallengeExecutor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,SAAS,eAAe,CAAC,OAAgB,EAAE,YAAoB;IAC7D,OAAO;QACL,YAAY;QACZ,MAAM,EAAE,oBAAoB;QAC5B,OAAO;QACP,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE,EAAE;QACZ,iBAAiB,EAAE,EAAE;KACtB,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"systemicChallengeExecutor.js","sourceRoot":"","sources":["../../../src/audit/orchestrator/systemicChallengeExecutor.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC,SAAS,sBAAsB;IAG7B,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB,EAAE,YAAoB;IAC7D,OAAO;QACL,YAAY;QACZ,MAAM,EAAE,oBAAoB;QAC5B,OAAO;QACP,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE,sBAAsB,EAAE;QAC1C,QAAQ,EAAE,EAAE;QACZ,iBAAiB,EAAE,EAAE;KACtB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAAsB,EACtB,UAAwC,EACxC,cAAuB;IAEvB,MAAM,OAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE9C,uEAAuE;IACvE,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,uEAAuE;IACvE,6BAA6B;IAC7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,MAAM;QACN,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,wBAAwB,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,SAAS;QACT,gBAAgB,EAAE,sBAAsB,EAAE;QAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE;YACjB,GAAG,CAAC,KAAK,EAAE,iBAAiB,IAAI,EAAE,CAAC;YACnC,GAAG,MAAM,CAAC,iBAAiB;SAC5B;KACF,CAAC;IACF,OAAO;QACL,OAAO,EAAE,EAAE,GAAG,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE;QACpD,iBAAiB,EAAE,CAAC,yBAAyB,CAAC;QAC9C,gBAAgB,EACd,4BAA4B,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,eAAe,CAAC,MAAM,qBAAqB;YAC9F,CAAC,SAAS;gBACR,CAAC,CAAC,sBAAsB,wBAAwB,sCAAsC;gBACtF,CAAC,CAAC,MAAM,CAAC,GAAG;oBACV,CAAC,CAAC,4EAA4E;oBAC9E,CAAC,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM,yBAAyB,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,9 @@ import type { AggregateMetricsDigest } from "./aggregateMetricsDigest.js";
|
|
|
3
3
|
* Render the second-order-adversary LANE prompt for one challenge round. `round` is
|
|
4
4
|
* the 1-based loop ordinal; `priorFindingCount` orients the adversary on what already
|
|
5
5
|
* surfaced (so it pushes for NEW improvements, not re-statements). `submissionPath`
|
|
6
|
-
* is where the agent writes its findings; an EMPTY findings array
|
|
7
|
-
*
|
|
6
|
+
* is where the agent writes its findings; an EMPTY findings array marks a QUIET
|
|
7
|
+
* round (this round found nothing new) — the loop converges after consecutive
|
|
8
|
+
* quiet rounds, per the register's `convergence_rule`.
|
|
8
9
|
*
|
|
9
10
|
* Advance-free (design resolution 2): the lane prompt is materialized to a file
|
|
10
11
|
* and carries no continue-command — the step prompt owns the advance, so a lane
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondOrderAdversaryPrompt.d.ts","sourceRoot":"","sources":["../../../src/audit/systemic/secondOrderAdversaryPrompt.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"secondOrderAdversaryPrompt.d.ts","sourceRoot":"","sources":["../../../src/audit/systemic/secondOrderAdversaryPrompt.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,sBAAsB,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CA6DT"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// duplicated, over-built; what assumption went unquestioned; is there a categorically
|
|
9
9
|
// better approach (design of record spec + backlog "Systemic reviewers must be pushed
|
|
10
10
|
// adversarially for improvement"). LOOP-UNTIL-DRY: this is round N of a loop that ends
|
|
11
|
-
// only when
|
|
11
|
+
// only when CONSECUTIVE rounds surface NOTHING NEW (the register's convergence_rule).
|
|
12
12
|
//
|
|
13
13
|
// The aggregate-metrics digest is NECESSARY supporting evidence, explicitly NOT
|
|
14
14
|
// SUFFICIENT alone — the adversary reasons from the whole system, using the counts as
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* Render the second-order-adversary LANE prompt for one challenge round. `round` is
|
|
18
18
|
* the 1-based loop ordinal; `priorFindingCount` orients the adversary on what already
|
|
19
19
|
* surfaced (so it pushes for NEW improvements, not re-statements). `submissionPath`
|
|
20
|
-
* is where the agent writes its findings; an EMPTY findings array
|
|
21
|
-
*
|
|
20
|
+
* is where the agent writes its findings; an EMPTY findings array marks a QUIET
|
|
21
|
+
* round (this round found nothing new) — the loop converges after consecutive
|
|
22
|
+
* quiet rounds, per the register's `convergence_rule`.
|
|
22
23
|
*
|
|
23
24
|
* Advance-free (design resolution 2): the lane prompt is materialized to a file
|
|
24
25
|
* and carries no continue-command — the step prompt owns the advance, so a lane
|
|
@@ -55,9 +56,10 @@ export function renderSecondOrderAdversaryPrompt(opts) {
|
|
|
55
56
|
"`architecture`. The lens routes the improvement to the right place in synthesis.",
|
|
56
57
|
"",
|
|
57
58
|
"## Loop-until-dry",
|
|
58
|
-
"The review is done only when
|
|
59
|
-
"answer. If, after genuine pressure, you find no NEW improvement this
|
|
60
|
-
"an EMPTY findings array; that
|
|
59
|
+
"The review is done only when consecutive rounds yield NOTHING NEW — not when it",
|
|
60
|
+
"first has an answer. If, after genuine pressure, you find no NEW improvement this",
|
|
61
|
+
"round, submit an EMPTY findings array; that marks a quiet round, and the loop",
|
|
62
|
+
"converges after consecutive quiet rounds. Otherwise submit the new",
|
|
61
63
|
"improvements (each pointing at at least one real component).",
|
|
62
64
|
"",
|
|
63
65
|
"## Output",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondOrderAdversaryPrompt.js","sourceRoot":"","sources":["../../../src/audit/systemic/secondOrderAdversaryPrompt.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,qFAAqF;AACrF,gFAAgF;AAChF,gFAAgF;AAChF,kFAAkF;AAClF,gFAAgF;AAChF,sFAAsF;AACtF,sFAAsF;AACtF,uFAAuF;AACvF,
|
|
1
|
+
{"version":3,"file":"secondOrderAdversaryPrompt.js","sourceRoot":"","sources":["../../../src/audit/systemic/secondOrderAdversaryPrompt.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,qFAAqF;AACrF,gFAAgF;AAChF,gFAAgF;AAChF,kFAAkF;AAClF,gFAAgF;AAChF,sFAAsF;AACtF,sFAAsF;AACtF,uFA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KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -4,9 +4,12 @@ import type { GoalGraph } from "audit-tools/shared";
|
|
|
4
4
|
export interface SystemicRoundResult {
|
|
5
5
|
/** Every distinct finding across all rounds so far, blast-ranked, true-lens. */
|
|
6
6
|
findings: Finding[];
|
|
7
|
-
/** The ids this round added that no prior round had (empty ⇒ dry
|
|
7
|
+
/** The ids this round added that no prior round had (empty ⇒ dry). */
|
|
8
8
|
new_finding_ids: string[];
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* True when this round surfaced nothing new — a QUIET round. Convergence is
|
|
11
|
+
* the executor's call over CONSECUTIVE quiet rounds, not this flag alone.
|
|
12
|
+
*/
|
|
10
13
|
dry: boolean;
|
|
11
14
|
/** Assembly notes (e.g. a finding was dropped as ungrounded), surfaced. */
|
|
12
15
|
validation_issues: string[];
|
|
@@ -20,8 +23,9 @@ export interface SystemicRoundResult {
|
|
|
20
23
|
* PRESERVING the adversary-tagged TRUE lens.
|
|
21
24
|
* 3. DEDUPE against prior rounds by finding identity (lens+category+title); a
|
|
22
25
|
* re-emission of a prior finding is NOT new.
|
|
23
|
-
* 4.
|
|
24
|
-
*
|
|
26
|
+
* 4. Mark dryness: a round that adds zero new findings is `dry`; an empty
|
|
27
|
+
* submission is trivially dry. The EXECUTOR converges the loop only after
|
|
28
|
+
* consecutive dry rounds (the register's `convergence_rule`).
|
|
25
29
|
* Deterministic: the returned `findings` are ordered by descending blast radius, ties
|
|
26
30
|
* broken by finding id, so the register never churns on submission order.
|
|
27
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemicChallengeLoop.d.ts","sourceRoot":"","sources":["../../../src/audit/systemic/systemicChallengeLoop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"systemicChallengeLoop.d.ts","sourceRoot":"","sources":["../../../src/audit/systemic/systemicChallengeLoop.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAwBpD,sEAAsE;AACtE,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,sEAAsE;IACtE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,GAAG,EAAE,OAAO,CAAC;IACb,2EAA2E;IAC3E,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IACnD,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;CACvD,GAAG,mBAAmB,CA6CtB"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
//
|
|
3
3
|
// A second-order adversary (a SEPARATE agent) re-interrogates the whole system with
|
|
4
4
|
// human-grade pressure and folds newly-surfaced improvements back in, LOOP-UNTIL-DRY:
|
|
5
|
-
// done only when
|
|
5
|
+
// done only when CONSECUTIVE challenge rounds yield NOTHING NEW — this module marks
|
|
6
|
+
// each round dry or not; the EXECUTOR decides convergence over the rounds register
|
|
7
|
+
// (design of record
|
|
6
8
|
// spec/conceptual-design-review-design.md §"Convergence (loop-until-dry)"). The
|
|
7
9
|
// mandate is OPTIMIZATION / BETTER-WAY — superior alternatives to things that
|
|
8
10
|
// currently work — not only defect-finding.
|
|
@@ -46,8 +48,9 @@ function resolveBlastRadius(finding, goalGraph, goalNodeOf) {
|
|
|
46
48
|
* PRESERVING the adversary-tagged TRUE lens.
|
|
47
49
|
* 3. DEDUPE against prior rounds by finding identity (lens+category+title); a
|
|
48
50
|
* re-emission of a prior finding is NOT new.
|
|
49
|
-
* 4.
|
|
50
|
-
*
|
|
51
|
+
* 4. Mark dryness: a round that adds zero new findings is `dry`; an empty
|
|
52
|
+
* submission is trivially dry. The EXECUTOR converges the loop only after
|
|
53
|
+
* consecutive dry rounds (the register's `convergence_rule`).
|
|
51
54
|
* Deterministic: the returned `findings` are ordered by descending blast radius, ties
|
|
52
55
|
* broken by finding id, so the register never churns on submission order.
|
|
53
56
|
*/
|
|
@@ -85,8 +88,9 @@ export function foldChallengeRound(params) {
|
|
|
85
88
|
return blastDelta;
|
|
86
89
|
return compareCodeUnits(a.id, b.id);
|
|
87
90
|
});
|
|
88
|
-
// A round is DRY
|
|
89
|
-
//
|
|
91
|
+
// A round is DRY when it surfaced nothing the prior set lacked — an empty
|
|
92
|
+
// submission is trivially dry. `new_finding_ids` already captures the newness.
|
|
93
|
+
// Convergence over consecutive dry rounds is the executor's decision.
|
|
90
94
|
const dry = new_finding_ids.length === 0;
|
|
91
95
|
return { findings, new_finding_ids, dry, validation_issues };
|
|
92
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemicChallengeLoop.js","sourceRoot":"","sources":["../../../src/audit/systemic/systemicChallengeLoop.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,EAAE;AACF,oFAAoF;AACpF,sFAAsF;AACtF,
|
|
1
|
+
{"version":3,"file":"systemicChallengeLoop.js","sourceRoot":"","sources":["../../../src/audit/systemic/systemicChallengeLoop.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,EAAE;AACF,oFAAoF;AACpF,sFAAsF;AACtF,oFAAoF;AACpF,mFAAmF;AACnF,oBAAoB;AACpB,gFAAgF;AAChF,8EAA8E;AAC9E,4CAA4C;AAC5C,EAAE;AACF,q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e,CAAC,MAAM,KAAK,CAAC,CAAC;IAEzC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -6,8 +6,8 @@ import type { AggregateMetricsDigest } from "../systemic/metricsDigestTypes.js";
|
|
|
6
6
|
* the SYSTEMIC IMPROVEMENT-SEEKING CHALLENGE LOOP. A second-order adversary (a
|
|
7
7
|
* SEPARATE agent — [[delegate-adversarial-phases-to-separate-agent]]) re-interrogates
|
|
8
8
|
* the whole system with human-grade pressure and folds newly-surfaced improvements
|
|
9
|
-
* back in, LOOP-UNTIL-DRY: the pass is done only when
|
|
10
|
-
* NOTHING NEW, not when it first has an answer (design of record
|
|
9
|
+
* back in, LOOP-UNTIL-DRY: the pass is done only when CONSECUTIVE challenge rounds
|
|
10
|
+
* yield NOTHING NEW, not when it first has an answer (design of record
|
|
11
11
|
* spec/conceptual-design-review-design.md §"Convergence (loop-until-dry)"; backlog
|
|
12
12
|
* "Systemic reviewers must be pushed adversarially for improvement").
|
|
13
13
|
*
|
|
@@ -22,8 +22,10 @@ import type { AggregateMetricsDigest } from "../systemic/metricsDigestTypes.js";
|
|
|
22
22
|
* `status:"omitted"` when the ceiling did not request the systemic layer (shallow —
|
|
23
23
|
* the default), so the obligation is satisfied without a host turn.
|
|
24
24
|
*
|
|
25
|
-
* Each host-delegation round appends to `rounds`;
|
|
26
|
-
*
|
|
25
|
+
* Each host-delegation round appends to `rounds`; the loop terminates
|
|
26
|
+
* (`converged:true`) only after CONSECUTIVE rounds that return zero new
|
|
27
|
+
* findings — the applied count is recorded in `convergence_rule`, so the
|
|
28
|
+
* register is self-describing. `findings` are every
|
|
27
29
|
* distinct improvement surfaced across rounds — carrying their TRUE lens (a
|
|
28
30
|
* test-parallelization finding is `tests`/`performance`, an ops finding is
|
|
29
31
|
* `operability`), NEVER a hardcoded `architecture` tag.
|
|
@@ -33,7 +35,11 @@ export interface SystemicChallengeRound {
|
|
|
33
35
|
round: number;
|
|
34
36
|
/** Distinct finding ids this round surfaced that no prior round had. */
|
|
35
37
|
new_finding_ids: string[];
|
|
36
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Whether this round yielded nothing new (a QUIET round). One quiet round is
|
|
40
|
+
* not the terminator on its own: convergence requires the consecutive count
|
|
41
|
+
* the register's `convergence_rule` states.
|
|
42
|
+
*/
|
|
37
43
|
dry: boolean;
|
|
38
44
|
}
|
|
39
45
|
export interface SystemicChallengeRegister {
|
|
@@ -57,10 +63,32 @@ export interface SystemicChallengeRegister {
|
|
|
57
63
|
* from the whole picture, not the counts). Absent on an omitted register.
|
|
58
64
|
*/
|
|
59
65
|
metrics?: AggregateMetricsDigest;
|
|
60
|
-
/** The loop-until-dry challenge rounds, in order
|
|
66
|
+
/** The loop-until-dry challenge rounds, in order. */
|
|
61
67
|
rounds: SystemicChallengeRound[];
|
|
62
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Content hashes of every submission already folded into this register — the
|
|
70
|
+
* iterative-fold duplicate guard (CX-02 landing 3). A crash between the
|
|
71
|
+
* fold's core commit and its staged-submission cleanup can restore an
|
|
72
|
+
* already-folded submission for re-consumption; without this register a
|
|
73
|
+
* re-fold of the identical round reports a QUIET round and can converge the
|
|
74
|
+
* adversary loop falsely. A duplicate hash is ignored, never counted.
|
|
75
|
+
*/
|
|
76
|
+
folded_submission_hashes?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* True once the required number of CONSECUTIVE rounds surfaced nothing new
|
|
79
|
+
* (the loop terminated) — see `convergence_rule` for the applied count.
|
|
80
|
+
*/
|
|
63
81
|
converged: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The convergence rule the enforcement half applied: the loop terminates
|
|
84
|
+
* only after `quiet_rounds_required` CONSECUTIVE dry rounds (owner decision
|
|
85
|
+
* 2026-08-28 — one dry round let a single duplicate submission terminate the
|
|
86
|
+
* adversary loop permanently). Optional because registers written before the
|
|
87
|
+
* rule existed do not carry it; every current writer records it.
|
|
88
|
+
*/
|
|
89
|
+
convergence_rule?: {
|
|
90
|
+
quiet_rounds_required: number;
|
|
91
|
+
};
|
|
64
92
|
/** Every distinct improvement finding surfaced, carrying its TRUE lens. */
|
|
65
93
|
findings: Finding[];
|
|
66
94
|
/** Gate/assembly notes (e.g. a round dropped an ungrounded finding) — surfaced. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemicChallenge.d.ts","sourceRoot":"","sources":["../../../src/audit/types/systemicChallenge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF
|
|
1
|
+
{"version":3,"file":"systemicChallenge.d.ts","sourceRoot":"","sources":["../../../src/audit/types/systemicChallenge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;OAIG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,MAAM,EAAE,oBAAoB,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,qDAAqD;IACrD,MAAM,EAAE,sBAAsB,EAAE,CAAC;IACjC;;;;;;;OAOG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE;QAAE,qBAAqB,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,mFAAmF;IACnF,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B"}
|
|
@@ -152,25 +152,44 @@ export declare function deriveEngineBound(cap: number): number;
|
|
|
152
152
|
* - `step` null, `stopped: "bound"` → the fold spent `maxTransitions`
|
|
153
153
|
* transitions without reaching an emit or completion. Also non-convergence,
|
|
154
154
|
* detected by counting rather than by signature.
|
|
155
|
+
* - `step` null, `stopped: "budget"` → the fold spent `maxExecutions` charged
|
|
156
|
+
* obligation executions. This is NOT non-convergence: the budget is a pacing
|
|
157
|
+
* cap, the stop is graceful, and the caller resumes the fold on its next
|
|
158
|
+
* call. Only possible when `opts.maxExecutions` is supplied.
|
|
155
159
|
*
|
|
156
160
|
* `stopped` being ABSENT is what means "the run is complete". A caller that
|
|
157
161
|
* branches on `step` alone therefore cannot tell completion from
|
|
158
|
-
* non-convergence, and would report a wedged fold as a finished one — so
|
|
159
|
-
* stopped
|
|
160
|
-
* obligation the fold was executing
|
|
161
|
-
*
|
|
162
|
+
* non-convergence, and would report a wedged fold as a finished one — so every
|
|
163
|
+
* stopped value must be handled explicitly. `lastObligationId` names the
|
|
164
|
+
* obligation the fold was executing (or, for `budget`, about to execute) when
|
|
165
|
+
* it stopped, so a caller can say WHICH obligation is in flight without
|
|
166
|
+
* parsing it out of a message.
|
|
162
167
|
*/
|
|
163
168
|
export interface AdvanceResult<S, Step> {
|
|
164
169
|
state: S;
|
|
165
170
|
step: Step | null;
|
|
166
|
-
stopped?: "cycle" | "bound";
|
|
171
|
+
stopped?: "cycle" | "bound" | "budget";
|
|
167
172
|
/** The obligation in flight when `stopped` was set; absent otherwise. */
|
|
168
173
|
lastObligationId?: string;
|
|
174
|
+
/**
|
|
175
|
+
* The numeric limit that fired — `maxTransitions` for `bound`,
|
|
176
|
+
* `maxExecutions` for `budget`; absent for `cycle` (no number fired). Carried
|
|
177
|
+
* ON the result so `describeStoppedFold` reports the number that actually
|
|
178
|
+
* stopped the fold, and no caller has to know which of two limits to restate.
|
|
179
|
+
*/
|
|
180
|
+
stoppedBound?: number;
|
|
169
181
|
}
|
|
170
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* A stop, described once for every draw that can hit one. `cycle` and `bound`
|
|
184
|
+
* are non-convergence; `budget` is the graceful pacing cap — a caller that
|
|
185
|
+
* expects the cap should branch on `stopped === "budget"` BEFORE reaching for
|
|
186
|
+
* this description, and build its own resumable pause from its accumulators.
|
|
187
|
+
* The description exists so a caller that does NOT special-case the budget
|
|
188
|
+
* still reports the stop honestly rather than as a finished run.
|
|
189
|
+
*/
|
|
171
190
|
export interface StoppedFoldDescription {
|
|
172
191
|
/** Which backstop fired, carried through so a caller need not re-read it. */
|
|
173
|
-
stopped: "cycle" | "bound";
|
|
192
|
+
stopped: "cycle" | "bound" | "budget";
|
|
174
193
|
/**
|
|
175
194
|
* The obligation in flight when the fold stopped, or `"unknown"` when it
|
|
176
195
|
* stopped before selecting one. Never parsed out of prose.
|
|
@@ -189,14 +208,16 @@ export interface StoppedFoldDescription {
|
|
|
189
208
|
* null-check itself the branch: there is no way to consume the description
|
|
190
209
|
* without having asked the question.
|
|
191
210
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
211
|
+
* The number reported is `outcome.stoppedBound` — the limit that actually
|
|
212
|
+
* fired, carried on the result by the engine itself. `opts.bound` remains as
|
|
213
|
+
* the fallback for callers describing an outcome from an engine that did not
|
|
214
|
+
* stamp one, so the number a host reads is still never a restated constant.
|
|
194
215
|
*
|
|
195
216
|
* `cause` is prose for a human terminal ONLY. Never match it: `stopped` and
|
|
196
217
|
* `spinning` are the machine-readable fields, and recognizing a wedged fold by
|
|
197
218
|
* its message text is the divergence this module's bounded-call invariant bans.
|
|
198
219
|
*/
|
|
199
|
-
export declare function describeStoppedFold(outcome: Pick<AdvanceResult<unknown, unknown>, "stopped" | "lastObligationId">, opts?: {
|
|
220
|
+
export declare function describeStoppedFold(outcome: Pick<AdvanceResult<unknown, unknown>, "stopped" | "lastObligationId" | "stoppedBound">, opts?: {
|
|
200
221
|
bound?: number;
|
|
201
222
|
}): StoppedFoldDescription | null;
|
|
202
223
|
/**
|
|
@@ -222,7 +243,19 @@ export declare function describeStoppedFold(outcome: Pick<AdvanceResult<unknown,
|
|
|
222
243
|
* signature — it stops the loop with `stopped: "bound"` after that many
|
|
223
244
|
* consecutive transitions.
|
|
224
245
|
*
|
|
225
|
-
*
|
|
246
|
+
* **Execution budget.** `opts.maxExecutions` is the consumer-facing pacing cap
|
|
247
|
+
* (PH-03: a budget stop the result expresses structurally, so no caller wraps
|
|
248
|
+
* the engine in a second drain to enforce one). The engine charges EVERY
|
|
249
|
+
* `obligation.execute` call to it, spend-before-dispatch: once the budget is
|
|
250
|
+
* spent, the next selected obligation is NOT executed and the loop returns
|
|
251
|
+
* `stopped: "budget"` naming it. Because every transition follows a charged
|
|
252
|
+
* execution, `transitions <= charged executions` holds by construction — so a
|
|
253
|
+
* `maxTransitions` derived via {@link deriveEngineBound} from the same cap can
|
|
254
|
+
* never fire first, which is the bounded-call invariant this module owns. An
|
|
255
|
+
* `emit` spends its charge and returns normally; it is never converted into a
|
|
256
|
+
* budget stop.
|
|
257
|
+
*
|
|
258
|
+
* ALL backstops terminate GRACEFULLY. The bound used to throw, which forced
|
|
226
259
|
* every consumer to recognize a wedged fold by matching text in an error
|
|
227
260
|
* message and to recover the spinning obligation's id with a regex over that
|
|
228
261
|
* same prose — so the engine's bound was part of its contract while its only
|
|
@@ -239,5 +272,6 @@ export declare function describeStoppedFold(outcome: Pick<AdvanceResult<unknown,
|
|
|
239
272
|
export declare function advance<S, Ctx, Step>(engine: ObligationEngine<S, Ctx, Step>, state: S, ctx: Ctx, opts?: {
|
|
240
273
|
maxTransitions?: number;
|
|
241
274
|
stateSignature?: (state: S) => string;
|
|
275
|
+
maxExecutions?: number;
|
|
242
276
|
}): Promise<AdvanceResult<S, Step>>;
|
|
243
277
|
//# sourceMappingURL=obligationEngine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obligationEngine.d.ts","sourceRoot":"","sources":["../../../src/shared/engine/obligationEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,oEAMhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAMlB,CAAC;AACZ,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,UAAU,EAChE,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,SAAS,CAAC,EAAE,GACxB,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC;IAClC,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC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AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EACxC,MAAM,EAAE,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EACtC,KAAK,EAAE,CAAC,EACR,GAAG,EAAE,GAAG,EACR,IAAI,CAAC,EAAE;IACL,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAqEjC"}
|
|
@@ -111,8 +111,10 @@ export function deriveEngineBound(cap) {
|
|
|
111
111
|
* null-check itself the branch: there is no way to consume the description
|
|
112
112
|
* without having asked the question.
|
|
113
113
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
114
|
+
* The number reported is `outcome.stoppedBound` — the limit that actually
|
|
115
|
+
* fired, carried on the result by the engine itself. `opts.bound` remains as
|
|
116
|
+
* the fallback for callers describing an outcome from an engine that did not
|
|
117
|
+
* stamp one, so the number a host reads is still never a restated constant.
|
|
116
118
|
*
|
|
117
119
|
* `cause` is prose for a human terminal ONLY. Never match it: `stopped` and
|
|
118
120
|
* `spinning` are the machine-readable fields, and recognizing a wedged fold by
|
|
@@ -121,13 +123,16 @@ export function deriveEngineBound(cap) {
|
|
|
121
123
|
export function describeStoppedFold(outcome, opts) {
|
|
122
124
|
if (!outcome.stopped)
|
|
123
125
|
return null;
|
|
124
|
-
const bound = opts?.bound ?? DEFAULT_MAX_TRANSITIONS;
|
|
126
|
+
const bound = outcome.stoppedBound ?? opts?.bound ?? DEFAULT_MAX_TRANSITIONS;
|
|
127
|
+
const cause = outcome.stopped === "bound"
|
|
128
|
+
? `spent the engine transition bound (${String(bound)}) without reaching a host-actionable step`
|
|
129
|
+
: outcome.stopped === "budget"
|
|
130
|
+
? `spent its charged-execution budget (${String(bound)}) and pauses resumably at the cap`
|
|
131
|
+
: "revisited a state it had already scanned this run";
|
|
125
132
|
return {
|
|
126
133
|
stopped: outcome.stopped,
|
|
127
134
|
spinning: outcome.lastObligationId ?? "unknown",
|
|
128
|
-
cause
|
|
129
|
-
? `spent the engine transition bound (${String(bound)}) without reaching a host-actionable step`
|
|
130
|
-
: "revisited a state it had already scanned this run",
|
|
135
|
+
cause,
|
|
131
136
|
};
|
|
132
137
|
}
|
|
133
138
|
/**
|
|
@@ -153,7 +158,19 @@ export function describeStoppedFold(outcome, opts) {
|
|
|
153
158
|
* signature — it stops the loop with `stopped: "bound"` after that many
|
|
154
159
|
* consecutive transitions.
|
|
155
160
|
*
|
|
156
|
-
*
|
|
161
|
+
* **Execution budget.** `opts.maxExecutions` is the consumer-facing pacing cap
|
|
162
|
+
* (PH-03: a budget stop the result expresses structurally, so no caller wraps
|
|
163
|
+
* the engine in a second drain to enforce one). The engine charges EVERY
|
|
164
|
+
* `obligation.execute` call to it, spend-before-dispatch: once the budget is
|
|
165
|
+
* spent, the next selected obligation is NOT executed and the loop returns
|
|
166
|
+
* `stopped: "budget"` naming it. Because every transition follows a charged
|
|
167
|
+
* execution, `transitions <= charged executions` holds by construction — so a
|
|
168
|
+
* `maxTransitions` derived via {@link deriveEngineBound} from the same cap can
|
|
169
|
+
* never fire first, which is the bounded-call invariant this module owns. An
|
|
170
|
+
* `emit` spends its charge and returns normally; it is never converted into a
|
|
171
|
+
* budget stop.
|
|
172
|
+
*
|
|
173
|
+
* ALL backstops terminate GRACEFULLY. The bound used to throw, which forced
|
|
157
174
|
* every consumer to recognize a wedged fold by matching text in an error
|
|
158
175
|
* message and to recover the spinning obligation's id with a regex over that
|
|
159
176
|
* same prose — so the engine's bound was part of its contract while its only
|
|
@@ -169,10 +186,12 @@ export function describeStoppedFold(outcome, opts) {
|
|
|
169
186
|
*/
|
|
170
187
|
export async function advance(engine, state, ctx, opts) {
|
|
171
188
|
const maxTransitions = opts?.maxTransitions ?? DEFAULT_MAX_TRANSITIONS;
|
|
189
|
+
const maxExecutions = opts?.maxExecutions;
|
|
172
190
|
const stateSignature = opts?.stateSignature;
|
|
173
191
|
const visited = stateSignature ? new Set() : null;
|
|
174
192
|
let current = state;
|
|
175
193
|
let transitions = 0;
|
|
194
|
+
let executions = 0;
|
|
176
195
|
// The obligation most recently selected — reported on every non-convergent
|
|
177
196
|
// stop so the caller can name what is spinning.
|
|
178
197
|
let lastObligationId = null;
|
|
@@ -197,6 +216,20 @@ export async function advance(engine, state, ctx, opts) {
|
|
|
197
216
|
if (!obligation)
|
|
198
217
|
return { state: current, step: null };
|
|
199
218
|
lastObligationId = obligation.id;
|
|
219
|
+
if (maxExecutions !== undefined && executions >= maxExecutions) {
|
|
220
|
+
// The budget is spent and another obligation is still actionable. Spend-
|
|
221
|
+
// before-dispatch: the selected obligation is NOT executed — a cap stated
|
|
222
|
+
// as a maximum must never authorize one step past itself. Graceful and
|
|
223
|
+
// resumable; the next call re-selects this same obligation.
|
|
224
|
+
return {
|
|
225
|
+
state: current,
|
|
226
|
+
step: null,
|
|
227
|
+
stopped: "budget",
|
|
228
|
+
lastObligationId,
|
|
229
|
+
stoppedBound: maxExecutions,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
executions += 1;
|
|
200
233
|
const outcome = await obligation.execute(current, ctx);
|
|
201
234
|
if (outcome.kind === "emit") {
|
|
202
235
|
return { state: outcome.state ?? current, step: outcome.step };
|
|
@@ -213,6 +246,7 @@ export async function advance(engine, state, ctx, opts) {
|
|
|
213
246
|
step: null,
|
|
214
247
|
stopped: "bound",
|
|
215
248
|
lastObligationId,
|
|
249
|
+
stoppedBound: maxTransitions,
|
|
216
250
|
};
|
|
217
251
|
}
|
|
218
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obligationEngine.js","sourceRoot":"","sources":["../../../src/shared/engine/obligationE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