loopforge 3.7.0 → 3.8.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.
- package/LICENSE +21 -21
- package/README.md +171 -157
- package/dist/audit.d.ts +53 -1
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +106 -22
- package/dist/audit.js.map +1 -1
- package/dist/canonical-state.d.ts +75 -69
- package/dist/canonical-state.d.ts.map +1 -1
- package/dist/canonical-state.js +276 -168
- package/dist/canonical-state.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +111 -12
- package/dist/cli.js.map +1 -1
- package/dist/cognitive-facts.d.ts +13 -0
- package/dist/cognitive-facts.d.ts.map +1 -1
- package/dist/cognitive-facts.js +30 -16
- package/dist/cognitive-facts.js.map +1 -1
- package/dist/cognitive-governance.d.ts +30 -6
- package/dist/cognitive-governance.d.ts.map +1 -1
- package/dist/cognitive-governance.js +74 -18
- package/dist/cognitive-governance.js.map +1 -1
- package/dist/committed-round.d.ts +109 -24
- package/dist/committed-round.d.ts.map +1 -1
- package/dist/committed-round.js +235 -52
- package/dist/committed-round.js.map +1 -1
- package/dist/contract-items.d.ts +55 -0
- package/dist/contract-items.d.ts.map +1 -0
- package/dist/contract-items.js +180 -0
- package/dist/contract-items.js.map +1 -0
- package/dist/enforcement-gate.d.ts +43 -20
- package/dist/enforcement-gate.d.ts.map +1 -1
- package/dist/enforcement-gate.js +269 -378
- package/dist/enforcement-gate.js.map +1 -1
- package/dist/engine.d.ts +11 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +102 -67
- package/dist/engine.js.map +1 -1
- package/dist/evidence-claims.d.ts +4 -4
- package/dist/evidence-claims.d.ts.map +1 -1
- package/dist/evidence-claims.js +16 -14
- package/dist/evidence-claims.js.map +1 -1
- package/dist/evidence-provider.d.ts +91 -90
- package/dist/evidence-provider.d.ts.map +1 -1
- package/dist/evidence-provider.js +349 -160
- package/dist/evidence-provider.js.map +1 -1
- package/dist/explain.d.ts +76 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +127 -0
- package/dist/explain.js.map +1 -0
- package/dist/generate-schema.js +250 -53
- package/dist/generate-schema.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/loop-compiler.d.ts +41 -40
- package/dist/loop-compiler.d.ts.map +1 -1
- package/dist/loop-compiler.js +275 -515
- package/dist/loop-compiler.js.map +1 -1
- package/dist/loop-extras-parser.d.ts +0 -1
- package/dist/loop-extras-parser.d.ts.map +1 -1
- package/dist/loop-extras-parser.js +0 -4
- package/dist/loop-extras-parser.js.map +1 -1
- package/dist/loop-projection.d.ts.map +1 -1
- package/dist/loop-projection.js +3 -1
- package/dist/loop-projection.js.map +1 -1
- package/dist/mcp/round-lifecycle.d.ts +40 -21
- package/dist/mcp/round-lifecycle.d.ts.map +1 -1
- package/dist/mcp/round-lifecycle.js +173 -120
- package/dist/mcp/round-lifecycle.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +63 -10
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session.d.ts +53 -7
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +240 -139
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/submission-boundary.d.ts +89 -0
- package/dist/mcp/submission-boundary.d.ts.map +1 -0
- package/dist/mcp/submission-boundary.js +203 -0
- package/dist/mcp/submission-boundary.js.map +1 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +377 -125
- package/dist/mcp/tools.js.map +1 -1
- package/dist/policy-metrics.js +2 -2
- package/dist/policy-metrics.js.map +1 -1
- package/dist/policy.d.ts +65 -95
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +151 -39
- package/dist/policy.js.map +1 -1
- package/dist/prompt-assembler.d.ts +7 -33
- package/dist/prompt-assembler.d.ts.map +1 -1
- package/dist/prompt-assembler.js +313 -473
- package/dist/prompt-assembler.js.map +1 -1
- package/dist/prompt-policy.d.ts +1 -4
- package/dist/prompt-policy.d.ts.map +1 -1
- package/dist/prompt-policy.js +6 -7
- package/dist/prompt-policy.js.map +1 -1
- package/dist/protocol.d.ts +411 -168
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +23 -69
- package/dist/protocol.js.map +1 -1
- package/dist/replay.js +2 -2
- package/dist/replay.js.map +1 -1
- package/dist/round-contract.d.ts +69 -57
- package/dist/round-contract.d.ts.map +1 -1
- package/dist/round-contract.js +104 -64
- package/dist/round-contract.js.map +1 -1
- package/dist/round-coordinator.d.ts +55 -16
- package/dist/round-coordinator.d.ts.map +1 -1
- package/dist/round-coordinator.js +179 -57
- package/dist/round-coordinator.js.map +1 -1
- package/dist/round-driver.d.ts +7 -5
- package/dist/round-driver.d.ts.map +1 -1
- package/dist/round-driver.js +2 -1
- package/dist/round-driver.js.map +1 -1
- package/dist/round-facts.d.ts +96 -0
- package/dist/round-facts.d.ts.map +1 -0
- package/dist/round-facts.js +216 -0
- package/dist/round-facts.js.map +1 -0
- package/dist/round-transaction.d.ts +23 -9
- package/dist/round-transaction.d.ts.map +1 -1
- package/dist/round-transaction.js +99 -22
- package/dist/round-transaction.js.map +1 -1
- package/dist/self-eval.d.ts +127 -11
- package/dist/self-eval.d.ts.map +1 -1
- package/dist/self-eval.js +517 -36
- package/dist/self-eval.js.map +1 -1
- package/dist/subgoal-state.d.ts +77 -0
- package/dist/subgoal-state.d.ts.map +1 -0
- package/dist/subgoal-state.js +198 -0
- package/dist/subgoal-state.js.map +1 -0
- package/dist/token-utils.d.ts +52 -19
- package/dist/token-utils.d.ts.map +1 -1
- package/dist/token-utils.js +83 -72
- package/dist/token-utils.js.map +1 -1
- package/dist/verification-gate.d.ts +27 -46
- package/dist/verification-gate.d.ts.map +1 -1
- package/dist/verification-gate.js +308 -557
- package/dist/verification-gate.js.map +1 -1
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/workspace.d.ts +9 -0
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +17 -0
- package/dist/workspace.js.map +1 -1
- package/loop_policy.json +17 -25
- package/package.json +7 -7
- package/skills/perception/SKILL.md +266 -64
package/dist/round-contract.js
CHANGED
|
@@ -1,80 +1,120 @@
|
|
|
1
|
-
|
|
1
|
+
/** Round Contract derivation — the ACTIVE contract a round executes under.
|
|
2
|
+
*
|
|
3
|
+
* A submission's `round_contract` is a PROPOSAL for the next round. It
|
|
4
|
+
* becomes ACTIVE only after the declaring round commits; the active contract
|
|
5
|
+
* is then derived from committed rounds on every compile path (retry,
|
|
6
|
+
* resume, backtrack). It closes when every item is machine-verified, or when
|
|
7
|
+
* the agent reports `outcome: "blocked"`; while it is open a different
|
|
8
|
+
* proposal is ignored.
|
|
9
|
+
*
|
|
10
|
+
* v3.8 identity: `rc-` / `rci-` are derived from CONTENT ONLY (loop id +
|
|
11
|
+
* canonical proposal), so restating an unchanged contract keeps the same
|
|
12
|
+
* identity and the item ids the agent already cited. This is deliberately
|
|
13
|
+
* the opposite of a SubGoal, whose id includes its declaration round.
|
|
14
|
+
*/
|
|
15
|
+
import { canonicalContractText, deriveContractId, deriveContractItemIds, } from "./token-utils.js";
|
|
16
|
+
import { deriveContractItemStatuses } from "./contract-items.js";
|
|
2
17
|
import { getPolicy } from "./policy.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
/** v3.8: Build the derived active contract from a committed proposal plus the
|
|
19
|
+
* binding the runtime stamped when that round committed. */
|
|
20
|
+
export function activateContract(proposal, declaredAtRound, binding, loopId) {
|
|
21
|
+
const itemIds = deriveContractItemIds(proposal.items);
|
|
22
|
+
return {
|
|
23
|
+
id: deriveContractId(loopId, proposal),
|
|
24
|
+
declared_at_round: declaredAtRound,
|
|
25
|
+
work_item: proposal.work_item,
|
|
26
|
+
scope: [...proposal.scope],
|
|
27
|
+
items: proposal.items.map((item, index) => ({
|
|
28
|
+
description: item.description,
|
|
29
|
+
criterion_refs: [...item.criterion_refs],
|
|
30
|
+
subgoal_refs: [...item.subgoal_refs],
|
|
31
|
+
verify_with: [...item.verify_with],
|
|
32
|
+
id: itemIds[index],
|
|
33
|
+
})),
|
|
34
|
+
config_hash_by_command: { ...(binding?.config_hash_by_command ?? {}) },
|
|
35
|
+
};
|
|
13
36
|
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (aIsId && bIsId)
|
|
20
|
-
return a === b;
|
|
21
|
-
if (aIsId)
|
|
22
|
-
return a === deriveCriterionId(b);
|
|
23
|
-
if (bIsId)
|
|
24
|
-
return deriveCriterionId(a) === b;
|
|
25
|
-
return jaccardSimilarity(a, b) >= getPolicy().evolution.criteria_dedup_threshold;
|
|
37
|
+
/** v3.8: Content equality — restating a contract unchanged is the same
|
|
38
|
+
* contract. Never compare by id (8 hex = 32 bits; a collision must not merge
|
|
39
|
+
* two different contracts). */
|
|
40
|
+
export function sameContract(left, right) {
|
|
41
|
+
return canonicalContractText(left) === canonicalContractText(right);
|
|
26
42
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
* round_underspecified at declaration; they close at the first eval
|
|
30
|
-
* committed while active). */
|
|
31
|
-
export function contractDoneWhenSatisfied(contract, met) {
|
|
32
|
-
if (contract.done_when.length === 0)
|
|
33
|
-
return true;
|
|
34
|
-
return contract.done_when.every((item) => met.some((claim) => contractItemMatches(item, claim)));
|
|
35
|
-
}
|
|
36
|
-
/** Walk committed evals (ASCENDING by round; the caller already restricts
|
|
37
|
-
* them to rounds earlier than the compile/verify round) and return the
|
|
38
|
-
* ACTIVE contract for the round after the last committed one — null means
|
|
39
|
-
* the Current Task falls back to the original task text.
|
|
40
|
-
*
|
|
41
|
-
* State machine per committed eval r, with `active` the contract carried
|
|
42
|
-
* into r (null = whole-task round):
|
|
43
|
-
* - active && r.outcome === "blocked" → active = r.proposal
|
|
44
|
-
* - active && all done_when in r.met → active = r.proposal
|
|
45
|
-
* - active && neither → active unchanged (r's
|
|
46
|
-
* different proposal is a premature replacement and is ignored)
|
|
47
|
-
* - !active → active = r.proposal
|
|
48
|
-
* (a proposal never activates on its own declaration round — it becomes
|
|
49
|
-
* active only for the rounds that follow the commit). */
|
|
50
|
-
export function deriveActiveRoundContract(committed) {
|
|
43
|
+
/** v3.8: The active contract after replaying committed rounds in order. */
|
|
44
|
+
export function deriveActiveRoundContract(rounds, commands = getPolicy().evidence.commands ?? []) {
|
|
51
45
|
let active = null;
|
|
52
|
-
for (
|
|
46
|
+
for (let index = 0; index < rounds.length; index++) {
|
|
47
|
+
const round = rounds[index];
|
|
48
|
+
const proposal = round.contractProposal;
|
|
49
|
+
const activate = () => proposal
|
|
50
|
+
? activateContract(proposal, round.round, round.contractBinding, round.loopId)
|
|
51
|
+
: null;
|
|
53
52
|
if (active === null) {
|
|
54
|
-
active =
|
|
53
|
+
active = activate();
|
|
55
54
|
continue;
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
// A blocked round closes the active contract (existing semantics), and a
|
|
57
|
+
// fully verified one does too. Order matters: blocked is checked first,
|
|
58
|
+
// mirroring the historical walker.
|
|
59
|
+
if (round.outcome === "blocked") {
|
|
60
|
+
active = activate();
|
|
59
61
|
continue;
|
|
60
62
|
}
|
|
61
|
-
|
|
62
|
-
active
|
|
63
|
+
const statuses = deriveContractItemStatuses({
|
|
64
|
+
contract: active,
|
|
65
|
+
rounds: rounds.slice(0, index + 1),
|
|
66
|
+
currentRound: round.round + 1,
|
|
67
|
+
currentReport: null,
|
|
68
|
+
currentObservations: [],
|
|
69
|
+
commands,
|
|
70
|
+
});
|
|
71
|
+
if (statuses.closure === "verified") {
|
|
72
|
+
active = activate();
|
|
63
73
|
continue;
|
|
64
74
|
}
|
|
65
|
-
//
|
|
66
|
-
// is a premature replacement and is ignored.
|
|
75
|
+
// Otherwise the active contract stays; a different proposal is ignored.
|
|
67
76
|
}
|
|
68
77
|
return active;
|
|
69
78
|
}
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
+
/** v3.8: Every criterion id referenced by the contract's items. */
|
|
80
|
+
export function contractCriterionIds(contract) {
|
|
81
|
+
const ids = new Set();
|
|
82
|
+
for (const item of contract.items) {
|
|
83
|
+
for (const ref of item.criterion_refs) {
|
|
84
|
+
if (/^cr-[a-f0-9]{8}$/.test(ref))
|
|
85
|
+
ids.add(ref);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [...ids];
|
|
89
|
+
}
|
|
90
|
+
/** v3.8: The contract a round EXECUTED under, plus every item's status as of
|
|
91
|
+
* that round — the ONE derivation the live coordinator, explain and audit
|
|
92
|
+
* share, so the three can never disagree about what a round ran under.
|
|
93
|
+
*
|
|
94
|
+
* Two things make this different from "derive from every round up to and
|
|
95
|
+
* including this one":
|
|
96
|
+
*
|
|
97
|
+
* - The executed contract comes from the rounds BEFORE this one. A proposal
|
|
98
|
+
* declared in round R becomes active in R+1, and a contract round R CLOSES
|
|
99
|
+
* must still be reported as round R's contract — folding R's own proposal
|
|
100
|
+
* into the walker would hand the round the successor (or nothing).
|
|
101
|
+
* - The round's own report and observations enter as the in-flight slice, so
|
|
102
|
+
* its claims and its bound commands are judged with the same reducer the
|
|
103
|
+
* coordinator uses before the round commits. */
|
|
104
|
+
export function deriveRoundContractView(input) {
|
|
105
|
+
const prior = input.rounds.filter((candidate) => candidate.round < input.round);
|
|
106
|
+
const contract = deriveActiveRoundContract(prior, input.commands);
|
|
107
|
+
return {
|
|
108
|
+
contract,
|
|
109
|
+
statuses: deriveContractItemStatuses({
|
|
110
|
+
contract,
|
|
111
|
+
rounds: prior,
|
|
112
|
+
currentRound: input.round,
|
|
113
|
+
currentReport: input.report,
|
|
114
|
+
currentObservations: input.observations,
|
|
115
|
+
currentOutcome: input.outcome,
|
|
116
|
+
commands: input.commands,
|
|
117
|
+
}),
|
|
118
|
+
};
|
|
79
119
|
}
|
|
80
120
|
//# sourceMappingURL=round-contract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round-contract.js","sourceRoot":"","sources":["../src/round-contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"round-contract.js","sourceRoot":"","sources":["../src/round-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAqBxC;6DAC6D;AAC7D,MAAM,UAAU,gBAAgB,CAC9B,QAA+B,EAC/B,eAAuB,EACvB,OAAkE,EAClE,MAAc;IAEd,MAAM,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO;QACL,EAAE,EAAE,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACtC,iBAAiB,EAAE,eAAe;QAClC,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC1B,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC1C,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc,EAAE,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;YACxC,YAAY,EAAE,CA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KAAK;YACb,YAAY,EAAE,KAAK,CAAC,KAAK;YACzB,aAAa,EAAE,KAAK,CAAC,MAAM;YAC3B,mBAAmB,EAAE,KAAK,CAAC,YAAY;YACvC,cAAc,EAAE,KAAK,CAAC,OAAO;YAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* Persistence is owned by round-transaction.ts so reject paths remain
|
|
18
18
|
* side-effect free and accepted decisions can be replayed idempotently.
|
|
19
19
|
*/
|
|
20
|
-
import type { LoopStore } from "./loop-store.js";
|
|
21
|
-
import type {
|
|
22
|
-
import type { SelfEvaluation, StopReason, VerificationFlag } from "./protocol.js";
|
|
20
|
+
import type { LoopStore, VaultEntry } from "./loop-store.js";
|
|
21
|
+
import type { MachineObservation } from "./protocol.js";
|
|
22
|
+
import type { SelfEvaluation, RoundVerificationStatus, StopReason, VerificationFlag } from "./protocol.js";
|
|
23
23
|
/** Input to a single round processing step. */
|
|
24
24
|
export interface RoundProcessInput {
|
|
25
25
|
loopId: string;
|
|
@@ -32,13 +32,20 @@ export interface RoundProcessInput {
|
|
|
32
32
|
lastSelfEval?: SelfEvaluation;
|
|
33
33
|
/** How many consecutive rounds have been rejected by enforcement. */
|
|
34
34
|
consecutiveRejections: number;
|
|
35
|
+
/** L4 (v3.7.x): which check rejected the previous round — lets uniform
|
|
36
|
+
* escalation rows act on their own streak, not an unrelated one. */
|
|
37
|
+
lastRejectionCheck?: string;
|
|
35
38
|
/** v1.18: Evidence snapshots from configured providers. */
|
|
36
|
-
evidenceSnapshots?:
|
|
39
|
+
evidenceSnapshots?: MachineObservation[];
|
|
37
40
|
/** Success values from already committed rounds. */
|
|
38
41
|
successTrajectory?: boolean[];
|
|
39
42
|
/** v2.13: Files from skipped backtrack rounds. Passed to verification
|
|
40
43
|
* gate for post-backtrack workspace restore check. */
|
|
41
44
|
backtrackSkippedFiles?: string[];
|
|
45
|
+
/** M3 (v3.7.x): git fingerprint of each skipped file as recorded at its
|
|
46
|
+
* failed round — machine proof of "untouched since the rollback" for
|
|
47
|
+
* the restore check. */
|
|
48
|
+
backtrackSkippedFingerprints?: Record<string, string>;
|
|
42
49
|
/** v2.12: Git HEAD of the backtrack restore point. The verification gate
|
|
43
50
|
* checks the workspace returns to this commit before accepting work. */
|
|
44
51
|
backtrackTargetGitHead?: string;
|
|
@@ -59,6 +66,18 @@ export interface RoundProcessResult {
|
|
|
59
66
|
backtrackSkippedDiscoveries?: string[];
|
|
60
67
|
/** v2.10: Which enforcement rule triggered the backtrack. */
|
|
61
68
|
backtrackTriggerRule?: string;
|
|
69
|
+
/** v3.7.1: Rounds rolled back (exclusive range above the restore point).
|
|
70
|
+
* Derived from committed facts + the in-flight attempt — rejected
|
|
71
|
+
* payloads are not durable history and never become a source. */
|
|
72
|
+
backtrackFailedRounds?: number[];
|
|
73
|
+
/** v3.7.1: One approach per failed round (committed output_summary or the
|
|
74
|
+
* in-flight attempt's), truncated — what must NOT be repeated. */
|
|
75
|
+
backtrackApproaches?: string[];
|
|
76
|
+
/** v3.7.1: Falsified assumptions from the failed rounds. */
|
|
77
|
+
backtrackWrongAssumptions?: string[];
|
|
78
|
+
/** M3 (v3.7.x): per-file git fingerprint at the failed round — lets the
|
|
79
|
+
* restore check prove a skipped file was never touched since the rollback. */
|
|
80
|
+
backtrackSkippedFingerprints?: Record<string, string>;
|
|
62
81
|
/** Verification flags from this round (for injection into next prompt). */
|
|
63
82
|
verificationFlags: VerificationFlag[];
|
|
64
83
|
/** Enforcement action for observability. */
|
|
@@ -69,6 +88,11 @@ export interface RoundProcessResult {
|
|
|
69
88
|
roundSuccess: boolean;
|
|
70
89
|
/** Whether the verification gate returned "contradicted". */
|
|
71
90
|
gateContradicted: boolean;
|
|
91
|
+
/** v3.8: The round-level verification posture, derived from the ACTIVE
|
|
92
|
+
* contract's item statuses and this round's claims: `trusted` (everything
|
|
93
|
+
* claimed is machine-backed), `insufficient` (claims unbacked, nothing
|
|
94
|
+
* contradicted), `contradicted` (a machine fact denies a claim). */
|
|
95
|
+
verificationStatus: RoundVerificationStatus;
|
|
72
96
|
/** Updated consecutiveRejections count — caller must persist. */
|
|
73
97
|
newConsecutiveRejections: number;
|
|
74
98
|
/** Which enforcement check fired (set when action is "reject" or "terminate").
|
|
@@ -80,13 +104,6 @@ export interface RoundProcessResult {
|
|
|
80
104
|
/** Whether the caller should push roundSuccess onto the success trajectory.
|
|
81
105
|
* false when gateContradicted or when action is "reject". */
|
|
82
106
|
shouldPushSuccessTrajectory: boolean;
|
|
83
|
-
/** v2.12: True when this round's intent_drift was waived via substantive
|
|
84
|
-
* drift_clarification. The caller uses this to track clarification streaks.
|
|
85
|
-
* v3.3.1: false when R7 itself rejected/terminated on a weak or missing
|
|
86
|
-
* clarification (the caller increments the streak); undefined when R7 did
|
|
87
|
-
* not participate in the decision — a higher-priority rule's rejection
|
|
88
|
-
* must never touch the streak. */
|
|
89
|
-
clarificationAccepted?: boolean;
|
|
90
107
|
/** v2.13: Git HEAD commit hash of the backtrack target round.
|
|
91
108
|
* Set when action is "backtrack". The verification gate uses this
|
|
92
109
|
* to check that the agent restored the workspace before working. */
|
|
@@ -96,6 +113,31 @@ export interface RoundProcessResult {
|
|
|
96
113
|
* not still dirty (agent must restore workspace first). */
|
|
97
114
|
backtrackSkippedFiles?: string[];
|
|
98
115
|
}
|
|
116
|
+
/** v3.8.1: The rolled-back branch's facts — the ONE derivation of which rounds
|
|
117
|
+
* failed, which approaches must not be repeated, which assumptions were
|
|
118
|
+
* falsified, and which files (with their failed-round git fingerprints) the
|
|
119
|
+
* agent must restore.
|
|
120
|
+
*
|
|
121
|
+
* Sources are COMMITTED rounds above the restore point; rejected attempts are
|
|
122
|
+
* not durable history and never become a source. The in-flight attempt that
|
|
123
|
+
* triggered the rollback is the one exception — its evaluation lives in this
|
|
124
|
+
* process, not in committed history.
|
|
125
|
+
*
|
|
126
|
+
* Extracted from the coordinator's inline walk so it is unit-testable without
|
|
127
|
+
* driving a whole rollback, and so the prompt, the state file and the
|
|
128
|
+
* committed decision all describe one event. */
|
|
129
|
+
export declare function deriveBacktrackRecoveryFacts(input: {
|
|
130
|
+
currentRound: number;
|
|
131
|
+
restoreRound: number;
|
|
132
|
+
vaultEntries: VaultEntry[];
|
|
133
|
+
selfEval: SelfEvaluation;
|
|
134
|
+
}): {
|
|
135
|
+
skippedFiles: string[];
|
|
136
|
+
skippedFingerprints: Record<string, string>;
|
|
137
|
+
failedRounds: number[];
|
|
138
|
+
approaches: string[];
|
|
139
|
+
wrongAssumptions: string[];
|
|
140
|
+
};
|
|
99
141
|
export declare class RoundCoordinator {
|
|
100
142
|
private store;
|
|
101
143
|
constructor(store?: LoopStore);
|
|
@@ -108,10 +150,7 @@ export declare class RoundCoordinator {
|
|
|
108
150
|
* - Managing heartbeat / signal handlers (runtime only)
|
|
109
151
|
* - Memory injection (both paths, before calling processRound)
|
|
110
152
|
* - Transactional feedback commit (accepted rounds only)
|
|
111
|
-
* - State file I/O (both paths, after compiling)
|
|
112
|
-
|
|
113
|
-
* @param driftClarificationStreak v2.12: Current clarification streak
|
|
114
|
-
* from session state. Passed through to enforceRound for R7 escalation. */
|
|
115
|
-
processRound(input: RoundProcessInput, driftClarificationStreak?: number): RoundProcessResult;
|
|
153
|
+
* - State file I/O (both paths, after compiling) */
|
|
154
|
+
processRound(input: RoundProcessInput): RoundProcessResult;
|
|
116
155
|
}
|
|
117
156
|
//# sourceMappingURL=round-coordinator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round-coordinator.d.ts","sourceRoot":"","sources":["../src/round-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"round-coordinator.d.ts","sourceRoot":"","sources":["../src/round-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA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