loopforge 2.11.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +4 -4
  2. package/dist/audit.d.ts +50 -0
  3. package/dist/audit.d.ts.map +1 -0
  4. package/dist/audit.js +158 -0
  5. package/dist/audit.js.map +1 -0
  6. package/dist/canonical-state.d.ts +21 -9
  7. package/dist/canonical-state.d.ts.map +1 -1
  8. package/dist/canonical-state.js +34 -16
  9. package/dist/canonical-state.js.map +1 -1
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +16 -6
  12. package/dist/cli.js.map +1 -1
  13. package/dist/cognitive-governance.d.ts +40 -0
  14. package/dist/cognitive-governance.d.ts.map +1 -0
  15. package/dist/cognitive-governance.js +126 -0
  16. package/dist/cognitive-governance.js.map +1 -0
  17. package/dist/enforcement-gate.d.ts +8 -3
  18. package/dist/enforcement-gate.d.ts.map +1 -1
  19. package/dist/enforcement-gate.js +419 -92
  20. package/dist/enforcement-gate.js.map +1 -1
  21. package/dist/engine.d.ts +47 -7
  22. package/dist/engine.d.ts.map +1 -1
  23. package/dist/engine.js +303 -60
  24. package/dist/engine.js.map +1 -1
  25. package/dist/evidence-claims.d.ts +50 -0
  26. package/dist/evidence-claims.d.ts.map +1 -0
  27. package/dist/evidence-claims.js +134 -0
  28. package/dist/evidence-claims.js.map +1 -0
  29. package/dist/generate-schema.js +6 -1
  30. package/dist/generate-schema.js.map +1 -1
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/loop-compiler.d.ts +41 -3
  36. package/dist/loop-compiler.d.ts.map +1 -1
  37. package/dist/loop-compiler.js +310 -38
  38. package/dist/loop-compiler.js.map +1 -1
  39. package/dist/loop-projection.d.ts +26 -0
  40. package/dist/loop-projection.d.ts.map +1 -0
  41. package/dist/loop-projection.js +142 -0
  42. package/dist/loop-projection.js.map +1 -0
  43. package/dist/loop-store.d.ts +91 -41
  44. package/dist/loop-store.d.ts.map +1 -1
  45. package/dist/loop-store.js +243 -173
  46. package/dist/loop-store.js.map +1 -1
  47. package/dist/mcp/round-lifecycle.d.ts +216 -0
  48. package/dist/mcp/round-lifecycle.d.ts.map +1 -0
  49. package/dist/mcp/round-lifecycle.js +926 -0
  50. package/dist/mcp/round-lifecycle.js.map +1 -0
  51. package/dist/mcp/server.d.ts +3 -2
  52. package/dist/mcp/server.d.ts.map +1 -1
  53. package/dist/mcp/server.js +65 -9
  54. package/dist/mcp/server.js.map +1 -1
  55. package/dist/mcp/session.d.ts +47 -139
  56. package/dist/mcp/session.d.ts.map +1 -1
  57. package/dist/mcp/session.js +284 -784
  58. package/dist/mcp/session.js.map +1 -1
  59. package/dist/mcp/tools.d.ts +23 -1
  60. package/dist/mcp/tools.d.ts.map +1 -1
  61. package/dist/mcp/tools.js +270 -79
  62. package/dist/mcp/tools.js.map +1 -1
  63. package/dist/policy-metrics.d.ts +11 -0
  64. package/dist/policy-metrics.d.ts.map +1 -1
  65. package/dist/policy-metrics.js +118 -21
  66. package/dist/policy-metrics.js.map +1 -1
  67. package/dist/policy.d.ts +26 -1
  68. package/dist/policy.d.ts.map +1 -1
  69. package/dist/policy.js +13 -2
  70. package/dist/policy.js.map +1 -1
  71. package/dist/prompt-assembler.d.ts +34 -1
  72. package/dist/prompt-assembler.d.ts.map +1 -1
  73. package/dist/prompt-assembler.js +320 -42
  74. package/dist/prompt-assembler.js.map +1 -1
  75. package/dist/protocol.d.ts +169 -1
  76. package/dist/protocol.d.ts.map +1 -1
  77. package/dist/protocol.js +39 -0
  78. package/dist/protocol.js.map +1 -1
  79. package/dist/replay.d.ts +5 -5
  80. package/dist/replay.d.ts.map +1 -1
  81. package/dist/replay.js +9 -8
  82. package/dist/replay.js.map +1 -1
  83. package/dist/round-coordinator.d.ts +6 -3
  84. package/dist/round-coordinator.d.ts.map +1 -1
  85. package/dist/round-coordinator.js +38 -19
  86. package/dist/round-coordinator.js.map +1 -1
  87. package/dist/round-driver.d.ts +9 -4
  88. package/dist/round-driver.d.ts.map +1 -1
  89. package/dist/round-driver.js +15 -7
  90. package/dist/round-driver.js.map +1 -1
  91. package/dist/round-transaction.d.ts +7 -3
  92. package/dist/round-transaction.d.ts.map +1 -1
  93. package/dist/round-transaction.js +93 -88
  94. package/dist/round-transaction.js.map +1 -1
  95. package/dist/self-eval.d.ts +31 -1
  96. package/dist/self-eval.d.ts.map +1 -1
  97. package/dist/self-eval.js +115 -12
  98. package/dist/self-eval.js.map +1 -1
  99. package/dist/storage.d.ts +3 -4
  100. package/dist/storage.d.ts.map +1 -1
  101. package/dist/storage.js +5 -4
  102. package/dist/storage.js.map +1 -1
  103. package/dist/token-utils.d.ts +20 -7
  104. package/dist/token-utils.d.ts.map +1 -1
  105. package/dist/token-utils.js +68 -9
  106. package/dist/token-utils.js.map +1 -1
  107. package/dist/verification-gate.d.ts +54 -2
  108. package/dist/verification-gate.d.ts.map +1 -1
  109. package/dist/verification-gate.js +433 -25
  110. package/dist/verification-gate.js.map +1 -1
  111. package/loop_policy.json +35 -8
  112. package/package.json +3 -2
  113. package/skills/perception/SKILL.md +24 -6
  114. package/dist/backends/interface.d.ts +0 -39
  115. package/dist/backends/interface.d.ts.map +0 -1
  116. package/dist/backends/interface.js +0 -6
  117. package/dist/backends/interface.js.map +0 -1
@@ -3,15 +3,20 @@
3
3
  * Single source of truth for tokenization and similarity functions used
4
4
  * by the compiler, verification gate, and canonical state renderer.
5
5
  *
6
- * The Unicode token regex covers CJK Unified Ideographs (U+4E00–U+9FFF)
7
- * plus CJK Extension A (U+3400–U+4DBF), ensuring consistent similarity
8
- * scores across all modules.
6
+ * Latin alphanumerics tokenize as whole words; consecutive CJK characters
7
+ * tokenize as overlapping 2-grams (a lone CJK character is its own token)
8
+ * so CJK similarity takes intermediate values instead of collapsing to
9
+ * 0/1. The ranges cover Unified Ideographs, Compatibility Ideographs and
10
+ * Extensions B–F (surrogate-pair code points the legacy regex missed).
9
11
  */
10
- /** Tokenize text into a set of lowercase words and CJK characters.
11
- * Regex covers Latin alphanumeric + CJK Unified + CJK Extension A. */
12
+ /** Tokenize text into a set of lowercase ASCII words and CJK bigrams.
13
+ * Scripts are tokenized independently, so mixed text yields per-script
14
+ * tokens (e.g. "修复bug重入" → {修复, bug, 重入}). */
12
15
  export declare function tokenize(text: string): Set<string>;
13
- /** Jaccard similarity in [0, 1]. Returns 1 when either set is empty
14
- * (empty descriptions never match anything, so they don't false-positive). */
16
+ /** Jaccard similarity in [0, 1]. Returns 0 when either side is empty —
17
+ * an empty description carries no information and must not match
18
+ * everything (a score of 1 would make `[""]` a wildcard that falsely
19
+ * marks sub-goals done or suppresses criteria milestones). */
15
20
  export declare function jaccardSimilarity(left: string, right: string): number;
16
21
  /** Filter null/undefined/empty strings, trim, and deduplicate via Set. */
17
22
  export declare function unique(values: Array<string | null | undefined>): string[];
@@ -22,4 +27,12 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
22
27
  * `loop_lineage.round` (with `lineage.round` fallback). Returns 0 if
23
28
  * the entry has no recognizable round field. */
24
29
  export declare function entryRound(entry: Record<string, unknown>): number;
30
+ /** Stable 8-hex item ID derived from normalized text — used for
31
+ * c-/cr-/sg-XXXXXXXX constraint, criterion, and sub-goal IDs.
32
+ * Previously copy-pasted in prompt-assembler, canonical-state, and
33
+ * loop-compiler; consolidation must not change the hash strategy
34
+ * (deterministic across rounds). */
35
+ export declare function deriveItemId(text: string): string;
36
+ /** Stable-ID shape shared by constraint/criterion/sub-goal references. */
37
+ export declare const STABLE_ID_RE: RegExp;
25
38
  //# sourceMappingURL=token-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token-utils.d.ts","sourceRoot":"","sources":["../src/token-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;uEACuE;AACvE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GA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EAA0E;AAC1E,eAAO,MAAM,YAAY,QAA4B,CAAC"}
@@ -3,23 +3,68 @@
3
3
  * Single source of truth for tokenization and similarity functions used
4
4
  * by the compiler, verification gate, and canonical state renderer.
5
5
  *
6
- * The Unicode token regex covers CJK Unified Ideographs (U+4E00–U+9FFF)
7
- * plus CJK Extension A (U+3400–U+4DBF), ensuring consistent similarity
8
- * scores across all modules.
6
+ * Latin alphanumerics tokenize as whole words; consecutive CJK characters
7
+ * tokenize as overlapping 2-grams (a lone CJK character is its own token)
8
+ * so CJK similarity takes intermediate values instead of collapsing to
9
+ * 0/1. The ranges cover Unified Ideographs, Compatibility Ideographs and
10
+ * Extensions B–F (surrogate-pair code points the legacy regex missed).
9
11
  */
12
+ import { createHash } from "node:crypto";
10
13
  // ── Tokenization & similarity ──────────────────────────────────────────────
11
- /** Tokenize text into a set of lowercase words and CJK characters.
12
- * Regex covers Latin alphanumeric + CJK Unified + CJK Extension A. */
14
+ /** CJK ranges: Unified Ideographs (U+3400–U+9FFF), Compatibility Ideographs
15
+ * (U+F900–U+FAFF), Extensions B–F (U+20000–U+2FA1F). */
16
+ function isCjkCodePoint(code) {
17
+ return (code >= 0x3400 && code <= 0x9fff)
18
+ || (code >= 0xf900 && code <= 0xfaff)
19
+ || (code >= 0x20000 && code <= 0x2fa1f);
20
+ }
21
+ /** Tokenize text into a set of lowercase ASCII words and CJK bigrams.
22
+ * Scripts are tokenized independently, so mixed text yields per-script
23
+ * tokens (e.g. "修复bug重入" → {修复, bug, 重入}). */
13
24
  export function tokenize(text) {
14
- return new Set(text.toLowerCase().match(/[a-z0-9㐀-鿿]+/g) ?? []);
25
+ const tokens = new Set();
26
+ let ascii = "";
27
+ let cjk = [];
28
+ const flushAscii = () => { if (ascii.length > 0) {
29
+ tokens.add(ascii);
30
+ ascii = "";
31
+ } };
32
+ const flushCjk = () => {
33
+ if (cjk.length === 1)
34
+ tokens.add(cjk[0]);
35
+ else
36
+ for (let i = 0; i + 1 < cjk.length; i++)
37
+ tokens.add(cjk[i] + cjk[i + 1]);
38
+ cjk = [];
39
+ };
40
+ for (const ch of text.toLowerCase()) {
41
+ const code = ch.codePointAt(0) ?? 0;
42
+ if ((code >= 0x30 && code <= 0x39) || (code >= 0x61 && code <= 0x7a)) {
43
+ flushCjk();
44
+ ascii += ch;
45
+ }
46
+ else if (isCjkCodePoint(code)) {
47
+ flushAscii();
48
+ cjk.push(ch);
49
+ }
50
+ else {
51
+ flushAscii();
52
+ flushCjk();
53
+ }
54
+ }
55
+ flushAscii();
56
+ flushCjk();
57
+ return tokens;
15
58
  }
16
- /** Jaccard similarity in [0, 1]. Returns 1 when either set is empty
17
- * (empty descriptions never match anything, so they don't false-positive). */
59
+ /** Jaccard similarity in [0, 1]. Returns 0 when either side is empty —
60
+ * an empty description carries no information and must not match
61
+ * everything (a score of 1 would make `[""]` a wildcard that falsely
62
+ * marks sub-goals done or suppresses criteria milestones). */
18
63
  export function jaccardSimilarity(left, right) {
19
64
  const a = tokenize(left);
20
65
  const b = tokenize(right);
21
66
  if (a.size === 0 || b.size === 0)
22
- return 1;
67
+ return 0;
23
68
  let intersection = 0;
24
69
  for (const value of a)
25
70
  if (b.has(value))
@@ -49,4 +94,18 @@ export function entryRound(entry) {
49
94
  const rnd = lin.round;
50
95
  return typeof rnd === "number" && Number.isInteger(rnd) ? rnd : 0;
51
96
  }
97
+ // ── Stable ID derivation (v2.14: single source of truth) ───────────────────
98
+ /** Stable 8-hex item ID derived from normalized text — used for
99
+ * c-/cr-/sg-XXXXXXXX constraint, criterion, and sub-goal IDs.
100
+ * Previously copy-pasted in prompt-assembler, canonical-state, and
101
+ * loop-compiler; consolidation must not change the hash strategy
102
+ * (deterministic across rounds). */
103
+ export function deriveItemId(text) {
104
+ return createHash("sha256")
105
+ .update(text.trim().replace(/\s+/g, " ").toLowerCase())
106
+ .digest("hex")
107
+ .slice(0, 8);
108
+ }
109
+ /** Stable-ID shape shared by constraint/criterion/sub-goal references. */
110
+ export const STABLE_ID_RE =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O,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,8EAA8E;AAE9E;;;;qCAIqC;AACrC,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;SACtD,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,yBAAyB,CAAC"}
@@ -12,15 +12,63 @@
12
12
  * modified). Flags become hard constraints — the agent
13
13
  * must respond in the next round.
14
14
  */
15
- import type { VaultEntry } from "./backends/interface.js";
15
+ import type { VaultEntry } from "./loop-store.js";
16
16
  import type { ProviderSnapshot } from "./evidence-provider.js";
17
17
  import type { SelfEvaluation, VerificationResult } from "./protocol.js";
18
+ export declare const CHECK_PROGRESS_REGRESSION = "progress_regression";
19
+ export declare const CHECK_EMPTY_CHANGE_WITH_PASSING = "empty_change_with_passing";
20
+ export declare const CHECK_SUCCESS_WITH_REMAINING_CRITERIA = "success_with_remaining_criteria";
21
+ export declare const CHECK_SUCCESS_WITHOUT_VERIFIED_EVIDENCE = "success_without_verified_evidence";
22
+ export declare const CHECK_OUTCOME_SUCCESS_CONTRADICTION = "outcome_success_contradiction";
23
+ export declare const CHECK_SUCCESS_CLAIM_CONFLICT = "success_claim_conflict";
24
+ export declare const CHECK_BLOCKED_WITHOUT_BLOCKER = "blocked_without_blocker";
25
+ export declare const CHECK_RETROACTIVE_CLAIM_BAD_ROUND = "retroactive_claim_bad_round";
26
+ export declare const CHECK_RETROACTIVE_CLAIM_UNVERIFIED = "retroactive_claim_unverified";
27
+ export declare const CHECK_DUPLICATE_CONSTRAINT_DISCOVERY = "duplicate_constraint_discovery";
28
+ export declare const CHECK_RECURRING_VIOLATION = "recurring_violation";
29
+ export declare const CHECK_RETRACT_FRESH_CONSTRAINT = "retract_fresh_constraint";
30
+ export declare const CHECK_EVIDENCE_INTEGRITY = "evidence_integrity";
31
+ export declare const CHECK_REQUIRED_COMMAND_FAILED = "required_command_failed";
32
+ export declare const CHECK_COMMAND_EVIDENCE_MISMATCH = "command_evidence_mismatch";
33
+ export declare const CHECK_INTENT_DRIFT = "intent_drift";
34
+ export declare const CHECK_SUBGOAL_DRIFT = "subgoal_drift";
35
+ export declare const CHECK_BACKTRACK_WORKSPACE_NOT_RESTORED = "backtrack_workspace_not_restored";
36
+ export declare const CHECK_CRITERIA_CLAIMS_UNVERIFIED = "criteria_claims_unverified";
37
+ /** v3.2: success declared with no machine-verified observation this round
38
+ * (providerStatus ≠ verified). Warn-level: the round still commits, but its
39
+ * success never enters the trajectory and trust drops. */
40
+ export declare const CHECK_SUCCESS_UNVERIFIED = "success_unverified";
18
41
  /** Extract the round number from a vault entry's loop_lineage.
19
42
  * Returns 0 if the entry has no lineage or no round field.
20
43
  * In practice, persistLoopLineage always writes round ≥ 1, so 0
21
44
  * unambiguously means "not a valid round entry" in this context.
22
45
  * Exported for reuse by enforcement-gate.ts. */
23
46
  export declare function entryRound(entry: VaultEntry): number;
47
+ export interface EvidenceStatus {
48
+ /** Whether this round produced a machine-verified observation. */
49
+ providerStatus: "verified" | "unavailable" | "absent";
50
+ /** Git snapshot exists and diffed file changes this round. */
51
+ gitObserved: boolean;
52
+ /** A passed after-phase command snapshot exists. */
53
+ commandVerified: boolean;
54
+ /** Agent-reported test_results agree with a passed command's parsed stdout. */
55
+ testsMachineBacked: boolean;
56
+ /** Agent-reported files_changed equals the git diff set exactly. */
57
+ reportedFilesMatch: boolean;
58
+ }
59
+ /** v3.2: Derive the machine-verification status of a round. The verification
60
+ * capability is modeled explicitly (verified / unavailable / absent) instead
61
+ * of letting evidence-dependent checks silently disappear when snapshots are
62
+ * missing — the fix for the "weakest when it matters most" gap. */
63
+ export declare function deriveEvidenceStatus(selfEval: SelfEvaluation, evidenceSnapshots: ProviderSnapshot[]): EvidenceStatus;
64
+ /** v3.2: Per-round machine progress — whether git observed file changes in
65
+ * each of the last `lookback` committed rounds, rebuilt from the feedback
66
+ * entries' roundEvidence snapshots (already persisted at commit). Returns
67
+ * null when fewer than `lookback` rounds carry git snapshots — the machine
68
+ * signal is unavailable and callers (R4/R5 on the heuristic path) keep
69
+ * their legacy skip. The snapshot shape is parsed defensively here because
70
+ * this module must not import round-transaction (import cycle). */
71
+ export declare function machineProgressSeries(vaultEntries: VaultEntry[], currentRound: number, lookback: number): boolean[] | null;
24
72
  interface ParsedTestCounts {
25
73
  passed: number;
26
74
  failed: number;
@@ -51,6 +99,10 @@ export declare function verifySelfEvaluation(selfEval: SelfEvaluation, currentRo
51
99
  /** v2.13: Files from skipped backtrack rounds. If the agent's
52
100
  * files_changed overlaps significantly with these, the workspace
53
101
  * was not properly restored before working. */
54
- backtrackSkippedFiles?: string[]): VerificationResult;
102
+ backtrackSkippedFiles?: string[],
103
+ /** v2.12: Git HEAD commit of the backtrack restore point. When set, the
104
+ * current git snapshot must sit at this commit — otherwise the workspace
105
+ * was not restored and the round cannot be accepted. */
106
+ backtrackTargetGitHead?: string): VerificationResult;
55
107
  export {};
56
108
  //# sourceMappingURL=verification-gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verification-gate.d.ts","sourceRoot":"","sources":["../src/verification-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAoB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAQ1F;;;;iDAIiD;AAC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