@zhixuan92/multi-model-agent-core 4.2.2 → 4.3.0
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/README.md +1 -1
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +4 -3
- package/dist/config/schema.js.map +1 -1
- package/dist/error-codes.d.ts +1 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/error-codes.js +2 -0
- package/dist/error-codes.js.map +1 -1
- package/dist/events/telemetry-types.d.ts +24 -20
- package/dist/events/telemetry-types.d.ts.map +1 -1
- package/dist/identity/auth-token-store.d.ts +36 -0
- package/dist/identity/auth-token-store.d.ts.map +1 -1
- package/dist/identity/auth-token-store.js +71 -2
- package/dist/identity/auth-token-store.js.map +1 -1
- package/dist/identity/cwd-validator.d.ts.map +1 -1
- package/dist/identity/cwd-validator.js +15 -3
- package/dist/identity/cwd-validator.js.map +1 -1
- package/dist/identity/main-model-resolver.d.ts +14 -0
- package/dist/identity/main-model-resolver.d.ts.map +1 -0
- package/dist/identity/main-model-resolver.js +83 -0
- package/dist/identity/main-model-resolver.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/intake/brief-compiler-slots/delegate.d.ts +10 -11
- package/dist/intake/brief-compiler-slots/delegate.d.ts.map +1 -1
- package/dist/intake/brief-compiler-slots/delegate.js +12 -14
- package/dist/intake/brief-compiler-slots/delegate.js.map +1 -1
- package/dist/intake/brief-compiler-slots/execute-plan.js +3 -1
- package/dist/intake/brief-compiler-slots/execute-plan.js.map +1 -1
- package/dist/intake/context-overflow-estimator.d.ts +33 -0
- package/dist/intake/context-overflow-estimator.d.ts.map +1 -0
- package/dist/intake/context-overflow-estimator.js +36 -0
- package/dist/intake/context-overflow-estimator.js.map +1 -0
- package/dist/intake/pipeline.d.ts.map +1 -1
- package/dist/intake/pipeline.js +46 -0
- package/dist/intake/pipeline.js.map +1 -1
- package/dist/intake/plan-extractor.d.ts.map +1 -1
- package/dist/intake/plan-extractor.js +10 -1
- package/dist/intake/plan-extractor.js.map +1 -1
- package/dist/intake/types.d.ts +1 -0
- package/dist/intake/types.d.ts.map +1 -1
- package/dist/lifecycle/diff-tracker.d.ts +17 -1
- package/dist/lifecycle/diff-tracker.d.ts.map +1 -1
- package/dist/lifecycle/diff-tracker.js +115 -2
- package/dist/lifecycle/diff-tracker.js.map +1 -1
- package/dist/lifecycle/handlers/annotate-completion-handler.d.ts +9 -0
- package/dist/lifecycle/handlers/annotate-completion-handler.d.ts.map +1 -0
- package/dist/lifecycle/handlers/annotate-completion-handler.js +171 -0
- package/dist/lifecycle/handlers/annotate-completion-handler.js.map +1 -0
- package/dist/lifecycle/handlers/annotate-criteria-handler.d.ts +3 -0
- package/dist/lifecycle/handlers/annotate-criteria-handler.d.ts.map +1 -0
- package/dist/lifecycle/handlers/annotate-criteria-handler.js +67 -0
- package/dist/lifecycle/handlers/annotate-criteria-handler.js.map +1 -0
- package/dist/lifecycle/handlers/baseline-handlers.d.ts.map +1 -1
- package/dist/lifecycle/handlers/baseline-handlers.js +106 -71
- package/dist/lifecycle/handlers/baseline-handlers.js.map +1 -1
- package/dist/lifecycle/handlers/review-handler.d.ts +3 -0
- package/dist/lifecycle/handlers/review-handler.d.ts.map +1 -0
- package/dist/lifecycle/handlers/review-handler.js +141 -0
- package/dist/lifecycle/handlers/review-handler.js.map +1 -0
- package/dist/lifecycle/handlers/rework-handler.d.ts +3 -0
- package/dist/lifecycle/handlers/rework-handler.d.ts.map +1 -0
- package/dist/lifecycle/handlers/rework-handler.js +77 -0
- package/dist/lifecycle/handlers/rework-handler.js.map +1 -0
- package/dist/lifecycle/handlers/terminal-handlers.d.ts.map +1 -1
- package/dist/lifecycle/handlers/terminal-handlers.js +16 -3
- package/dist/lifecycle/handlers/terminal-handlers.js.map +1 -1
- package/dist/lifecycle/lifecycle-context.d.ts +4 -0
- package/dist/lifecycle/lifecycle-context.d.ts.map +1 -1
- package/dist/lifecycle/lifecycle-driver.d.ts.map +1 -1
- package/dist/lifecycle/lifecycle-driver.js +12 -7
- package/dist/lifecycle/lifecycle-driver.js.map +1 -1
- package/dist/lifecycle/parallel-criteria-routes.d.ts +1 -1
- package/dist/lifecycle/parallel-criteria-routes.d.ts.map +1 -1
- package/dist/lifecycle/parallel-criteria-routes.js +21 -1
- package/dist/lifecycle/parallel-criteria-routes.js.map +1 -1
- package/dist/lifecycle/shared-compute.d.ts +9 -0
- package/dist/lifecycle/shared-compute.d.ts.map +1 -1
- package/dist/lifecycle/shared-compute.js +35 -3
- package/dist/lifecycle/shared-compute.js.map +1 -1
- package/dist/lifecycle/stage-plan-builder.d.ts.map +1 -1
- package/dist/lifecycle/stage-plan-builder.js +65 -85
- package/dist/lifecycle/stage-plan-builder.js.map +1 -1
- package/dist/lifecycle/stage-plan-types.d.ts +48 -0
- package/dist/lifecycle/stage-plan-types.d.ts.map +1 -1
- package/dist/lifecycle/stage-progression.d.ts.map +1 -1
- package/dist/lifecycle/stage-progression.js +17 -24
- package/dist/lifecycle/stage-progression.js.map +1 -1
- package/dist/lifecycle/task-runner.d.ts.map +1 -1
- package/dist/lifecycle/task-runner.js +12 -1
- package/dist/lifecycle/task-runner.js.map +1 -1
- package/dist/model-profiles.json +192 -53
- package/dist/providers/anthropic-messages-adapter.d.ts +8 -0
- package/dist/providers/anthropic-messages-adapter.d.ts.map +1 -1
- package/dist/providers/anthropic-messages-adapter.js +16 -1
- package/dist/providers/anthropic-messages-adapter.js.map +1 -1
- package/dist/providers/file-tracker.d.ts +12 -0
- package/dist/providers/file-tracker.d.ts.map +1 -1
- package/dist/providers/file-tracker.js +16 -0
- package/dist/providers/file-tracker.js.map +1 -1
- package/dist/providers/provider-factory.d.ts.map +1 -1
- package/dist/providers/provider-factory.js +27 -2
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/providers/runner-shell-types.d.ts +14 -0
- package/dist/providers/runner-shell-types.d.ts.map +1 -1
- package/dist/providers/runner-shell.d.ts.map +1 -1
- package/dist/providers/runner-shell.js +38 -6
- package/dist/providers/runner-shell.js.map +1 -1
- package/dist/providers/tool-implementations.d.ts +12 -0
- package/dist/providers/tool-implementations.d.ts.map +1 -1
- package/dist/providers/tool-implementations.js +33 -0
- package/dist/providers/tool-implementations.js.map +1 -1
- package/dist/reporting/annotate-completion-parser.d.ts +39 -0
- package/dist/reporting/annotate-completion-parser.d.ts.map +1 -0
- package/dist/reporting/annotate-completion-parser.js +43 -0
- package/dist/reporting/annotate-completion-parser.js.map +1 -0
- package/dist/reporting/compose-running-headline.d.ts +15 -1
- package/dist/reporting/compose-running-headline.d.ts.map +1 -1
- package/dist/reporting/compose-running-headline.js +76 -1
- package/dist/reporting/compose-running-headline.js.map +1 -1
- package/dist/reporting/report-parser-slots/research-report.d.ts +1 -1
- package/dist/review/default-engines.d.ts.map +1 -1
- package/dist/review/default-engines.js +8 -4
- package/dist/review/default-engines.js.map +1 -1
- package/dist/review/parse-review-report.d.ts +6 -0
- package/dist/review/parse-review-report.d.ts.map +1 -0
- package/dist/review/parse-review-report.js +40 -0
- package/dist/review/parse-review-report.js.map +1 -0
- package/dist/review/reviewer-engine.d.ts +12 -3
- package/dist/review/reviewer-engine.d.ts.map +1 -1
- package/dist/review/reviewer-engine.js +4 -3
- package/dist/review/reviewer-engine.js.map +1 -1
- package/dist/review/templates/annotate-completion.d.ts +12 -0
- package/dist/review/templates/annotate-completion.d.ts.map +1 -0
- package/dist/review/templates/annotate-completion.js +72 -0
- package/dist/review/templates/annotate-completion.js.map +1 -0
- package/dist/review/templates/quality-review.d.ts +3 -0
- package/dist/review/templates/quality-review.d.ts.map +1 -0
- package/dist/review/templates/quality-review.js +40 -0
- package/dist/review/templates/quality-review.js.map +1 -0
- package/dist/review/templates/rework.d.ts +3 -0
- package/dist/review/templates/rework.d.ts.map +1 -0
- package/dist/review/templates/rework.js +42 -0
- package/dist/review/templates/rework.js.map +1 -0
- package/dist/review/templates/shared.d.ts +32 -0
- package/dist/review/templates/shared.d.ts.map +1 -1
- package/dist/review/templates/spec-review.d.ts +1 -16
- package/dist/review/templates/spec-review.d.ts.map +1 -1
- package/dist/review/templates/spec-review.js +23 -31
- package/dist/review/templates/spec-review.js.map +1 -1
- package/dist/stores/context-block-project-cap.d.ts +14 -0
- package/dist/stores/context-block-project-cap.d.ts.map +1 -0
- package/dist/stores/context-block-project-cap.js +68 -0
- package/dist/stores/context-block-project-cap.js.map +1 -0
- package/dist/stores/context-block-tool.d.ts +2 -0
- package/dist/stores/context-block-tool.d.ts.map +1 -1
- package/dist/stores/context-block-tool.js +3 -2
- package/dist/stores/context-block-tool.js.map +1 -1
- package/dist/stores/file-backed-context-block-store.d.ts +8 -1
- package/dist/stores/file-backed-context-block-store.d.ts.map +1 -1
- package/dist/stores/file-backed-context-block-store.js +116 -4
- package/dist/stores/file-backed-context-block-store.js.map +1 -1
- package/dist/tools/audit/plan-audit-criteria.d.ts +35 -0
- package/dist/tools/audit/plan-audit-criteria.d.ts.map +1 -0
- package/dist/tools/audit/plan-audit-criteria.js +136 -0
- package/dist/tools/audit/plan-audit-criteria.js.map +1 -0
- package/dist/tools/audit/plan-audit-verdict.d.ts +15 -0
- package/dist/tools/audit/plan-audit-verdict.d.ts.map +1 -0
- package/dist/tools/audit/plan-audit-verdict.js +44 -0
- package/dist/tools/audit/plan-audit-verdict.js.map +1 -0
- package/dist/tools/audit/schema.d.ts +1 -0
- package/dist/tools/audit/schema.d.ts.map +1 -1
- package/dist/tools/audit/schema.js +6 -3
- package/dist/tools/audit/schema.js.map +1 -1
- package/dist/tools/audit/tool-config.d.ts +3 -0
- package/dist/tools/audit/tool-config.d.ts.map +1 -1
- package/dist/tools/audit/tool-config.js +8 -0
- package/dist/tools/audit/tool-config.js.map +1 -1
- package/dist/tools/delegate/implementer-criteria.d.ts +31 -47
- package/dist/tools/delegate/implementer-criteria.d.ts.map +1 -1
- package/dist/tools/delegate/implementer-criteria.js +60 -88
- package/dist/tools/delegate/implementer-criteria.js.map +1 -1
- package/dist/tools/delegate/tool-config.js +4 -4
- package/dist/tools/delegate/tool-config.js.map +1 -1
- package/dist/tools/execute-plan/implementer-criteria.d.ts +42 -37
- package/dist/tools/execute-plan/implementer-criteria.d.ts.map +1 -1
- package/dist/tools/execute-plan/implementer-criteria.js +79 -79
- package/dist/tools/execute-plan/implementer-criteria.js.map +1 -1
- package/dist/tools/execute-plan/tool-config.d.ts.map +1 -1
- package/dist/tools/execute-plan/tool-config.js +23 -13
- package/dist/tools/execute-plan/tool-config.js.map +1 -1
- package/dist/types/enums.d.ts +2 -2
- package/dist/types/run-result.d.ts +58 -0
- package/dist/types/run-result.d.ts.map +1 -1
- package/dist/types/task-spec.d.ts +14 -0
- package/dist/types/task-spec.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/lifecycle/handlers/quality-chain-handlers.d.ts +0 -22
- package/dist/lifecycle/handlers/quality-chain-handlers.d.ts.map +0 -1
- package/dist/lifecycle/handlers/quality-chain-handlers.js +0 -369
- package/dist/lifecycle/handlers/quality-chain-handlers.js.map +0 -1
- package/dist/lifecycle/handlers/review-diff-handler.d.ts +0 -31
- package/dist/lifecycle/handlers/review-diff-handler.d.ts.map +0 -1
- package/dist/lifecycle/handlers/review-diff-handler.js +0 -168
- package/dist/lifecycle/handlers/review-diff-handler.js.map +0 -1
- package/dist/lifecycle/handlers/run-verify-command-handler.d.ts +0 -25
- package/dist/lifecycle/handlers/run-verify-command-handler.d.ts.map +0 -1
- package/dist/lifecycle/handlers/run-verify-command-handler.js +0 -84
- package/dist/lifecycle/handlers/run-verify-command-handler.js.map +0 -1
- package/dist/lifecycle/handlers/spec-chain-handlers.d.ts +0 -21
- package/dist/lifecycle/handlers/spec-chain-handlers.d.ts.map +0 -1
- package/dist/lifecycle/handlers/spec-chain-handlers.js +0 -287
- package/dist/lifecycle/handlers/spec-chain-handlers.js.map +0 -1
- package/dist/review/templates/diff-review.d.ts +0 -11
- package/dist/review/templates/diff-review.d.ts.map +0 -1
- package/dist/review/templates/diff-review.js +0 -39
- package/dist/review/templates/diff-review.js.map +0 -1
- package/dist/review/templates/quality-review-artifact.d.ts +0 -16
- package/dist/review/templates/quality-review-artifact.d.ts.map +0 -1
- package/dist/review/templates/quality-review-artifact.js +0 -46
- package/dist/review/templates/quality-review-artifact.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outer LRU sweep for the context-block project directory.
|
|
3
|
+
*
|
|
4
|
+
* Walks all project-hash subdirectories under `contextBlocksRoot`. If the
|
|
5
|
+
* count exceeds `maxProjects`, removes (rm -rf) the oldest-mtime project
|
|
6
|
+
* directories until the count is at or below cap. mtime of the project
|
|
7
|
+
* directory is used as the recency signal — directory mtime updates
|
|
8
|
+
* whenever a file inside is added/removed, so it tracks last activity.
|
|
9
|
+
*
|
|
10
|
+
* For empty project dirs (no files), the dir's own mtime is the signal,
|
|
11
|
+
* which is stable from creation; they typically rank lower than active
|
|
12
|
+
* projects and fall off first.
|
|
13
|
+
*
|
|
14
|
+
* No-op when the count is at or under cap. Synchronous (called once at
|
|
15
|
+
* daemon startup, low expected cost).
|
|
16
|
+
*/
|
|
17
|
+
import * as fs from 'node:fs';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
/**
|
|
20
|
+
* Per-project recency signal — the value used to decide LRU ordering.
|
|
21
|
+
* For non-empty dirs: max(mtime of any file). For empty dirs: dir mtime.
|
|
22
|
+
*
|
|
23
|
+
* This helper is exported so the storage migration (A1.7) can use the
|
|
24
|
+
* same calculation. Without sharing, the two code paths can drift and
|
|
25
|
+
* different "recent" projects survive a sweep vs a migration.
|
|
26
|
+
*/
|
|
27
|
+
export function computeProjectRecencyMs(projectDir) {
|
|
28
|
+
let mtimeMs = 0;
|
|
29
|
+
try {
|
|
30
|
+
const files = fs.readdirSync(projectDir);
|
|
31
|
+
if (files.length === 0) {
|
|
32
|
+
mtimeMs = fs.statSync(projectDir).mtimeMs;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
for (const f of files) {
|
|
36
|
+
try {
|
|
37
|
+
const m = fs.statSync(path.join(projectDir, f)).mtimeMs;
|
|
38
|
+
if (m > mtimeMs)
|
|
39
|
+
mtimeMs = m;
|
|
40
|
+
}
|
|
41
|
+
catch { /* skip */ }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch { /* skip */ }
|
|
46
|
+
return mtimeMs;
|
|
47
|
+
}
|
|
48
|
+
export function sweepProjectCap(contextBlocksRoot, maxProjects) {
|
|
49
|
+
if (!fs.existsSync(contextBlocksRoot))
|
|
50
|
+
return { kept: 0, evicted: 0 };
|
|
51
|
+
const entries = fs.readdirSync(contextBlocksRoot, { withFileTypes: true });
|
|
52
|
+
const projects = entries
|
|
53
|
+
.filter(e => e.isDirectory())
|
|
54
|
+
.map(e => ({ name: e.name, mtimeMs: computeProjectRecencyMs(path.join(contextBlocksRoot, e.name)) }));
|
|
55
|
+
if (projects.length <= maxProjects)
|
|
56
|
+
return { kept: projects.length, evicted: 0 };
|
|
57
|
+
projects.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
58
|
+
const keep = projects.slice(0, maxProjects);
|
|
59
|
+
const drop = projects.slice(maxProjects);
|
|
60
|
+
for (const p of drop) {
|
|
61
|
+
try {
|
|
62
|
+
fs.rmSync(path.join(contextBlocksRoot, p.name), { recursive: true, force: true });
|
|
63
|
+
}
|
|
64
|
+
catch { /* skip */ }
|
|
65
|
+
}
|
|
66
|
+
return { kept: keep.length, evicted: drop.length };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=context-block-project-cap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-block-project-cap.js","sourceRoot":"","sources":["../../src/stores/context-block-project-cap.ts"],"names":[],"mappings":"AAAA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AW,EAAE,CAAC;SAC5B,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxG,IAAI,QAAQ,CAAC,MAAM,IAAI,WAAW;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACjF,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC;YAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;IACjH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -22,6 +22,7 @@ export interface ContextBlockStore {
|
|
|
22
22
|
* UUID. Returns the id, length, and sha256 hash. */
|
|
23
23
|
register(content: string, opts?: {
|
|
24
24
|
id?: string;
|
|
25
|
+
ttlMs?: number;
|
|
25
26
|
}): RegisteredBlock;
|
|
26
27
|
/** Fetch content by id. Returns `undefined` if the id is unknown or
|
|
27
28
|
* the entry has expired. Touches the LRU access time on success. */
|
|
@@ -83,6 +84,7 @@ export declare class InMemoryContextBlockStore implements ContextBlockStore {
|
|
|
83
84
|
constructor(opts?: InMemoryContextBlockStoreOptions);
|
|
84
85
|
register(content: string, opts?: {
|
|
85
86
|
id?: string;
|
|
87
|
+
ttlMs?: number;
|
|
86
88
|
}): RegisteredBlock;
|
|
87
89
|
get(id: string): string | undefined;
|
|
88
90
|
delete(id: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-block-tool.d.ts","sourceRoot":"","sources":["../../src/stores/context-block-tool.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"context-block-tool.d.ts","sourceRoot":"","sources":["../../src/stores/context-block-tool.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe,CAAC;IACnF;yEACqE;IACrE,GAAG,CAAC,EAAE,EAAE,MA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SAAS;IAenC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI3B;sEACkE;IAClE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKrB;qCACiC;IACjC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKvB;0EACsE;IACtE,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAYpD,kEAAkE;IAClE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI5B,oDAAoD;IACpD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,gBAAgB;CAgBzB"}
|
|
@@ -46,7 +46,8 @@ export class InMemoryContextBlockStore {
|
|
|
46
46
|
process.stderr.write(`[mma] WARN context-block ${id} is ${(byteSize / 1024 / 1024).toFixed(1)} MiB (>10 MiB)\n`);
|
|
47
47
|
}
|
|
48
48
|
const now = Date.now();
|
|
49
|
-
|
|
49
|
+
const entryTtl = opts.ttlMs ?? this._ttlMs;
|
|
50
|
+
this.entries.set(id, { content, addedAtMs: now, ttlMs: entryTtl, lastAccessTick: ++this.tick, pinCount: 0 });
|
|
50
51
|
this.evictIfOverBound();
|
|
51
52
|
return {
|
|
52
53
|
id,
|
|
@@ -59,7 +60,7 @@ export class InMemoryContextBlockStore {
|
|
|
59
60
|
if (!entry)
|
|
60
61
|
return undefined;
|
|
61
62
|
const now = Date.now();
|
|
62
|
-
if (now - entry.addedAtMs >
|
|
63
|
+
if (now - entry.addedAtMs > entry.ttlMs) {
|
|
63
64
|
// Expired — do not revive
|
|
64
65
|
this.entries.delete(id);
|
|
65
66
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-block-tool.js","sourceRoot":"","sources":["../../src/stores/context-block-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA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C,EAAE,QAAQ,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,oDAAoD;IACpD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3C,IAAI,QAA4B,CAAC;YACjC,IAAI,UAAU,GAAG,QAAQ,CAAC;YAC1B,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACvC,sEAAsE;gBACtE,IAAI,KAAK,CAAC,QAAQ,GAAG,CAAC;oBAAE,SAAS;gBACjC,IAAI,KAAK,CAAC,cAAc,GAAG,UAAU,EAAE,CAAC;oBACtC,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC;oBAClC,QAAQ,GAAG,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;YACD,IAAI,QAAQ;gBAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;;gBACvC,MAAM,CAAC,oCAAoC;QAClD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -10,9 +10,10 @@ export interface FileBackedContextBlockStoreOptions {
|
|
|
10
10
|
maxTotalBytes?: number;
|
|
11
11
|
/** Override `os.homedir()` — used by tests for filesystem isolation. */
|
|
12
12
|
homeDir?: string;
|
|
13
|
+
maxBlocksPerProject?: number;
|
|
13
14
|
}
|
|
14
15
|
export declare class FileBackedContextBlockStore implements ContextBlockStore {
|
|
15
|
-
/** Absolute root: `<homeDir>/.multi-model
|
|
16
|
+
/** Absolute root: `<homeDir>/.multi-model/context-blocks/<sha256(projectCwd)>`.
|
|
16
17
|
* Public so tests can read meta files directly without re-deriving the path. */
|
|
17
18
|
readonly rootDir: string;
|
|
18
19
|
private _ttlMs;
|
|
@@ -24,8 +25,10 @@ export declare class FileBackedContextBlockStore implements ContextBlockStore {
|
|
|
24
25
|
* protection signal, not a persistence concern. Lost on restart;
|
|
25
26
|
* TTL-based GC handles the recovery side. */
|
|
26
27
|
private pinCounts;
|
|
28
|
+
private readonly maxBlocksPerProject;
|
|
27
29
|
constructor(projectCwd: string, opts?: FileBackedContextBlockStoreOptions);
|
|
28
30
|
register(content: string, opts?: {
|
|
31
|
+
ttlMs?: number;
|
|
29
32
|
id?: string;
|
|
30
33
|
}): RegisteredBlock;
|
|
31
34
|
get(id: string): string | undefined;
|
|
@@ -56,6 +59,8 @@ export declare class FileBackedContextBlockStore implements ContextBlockStore {
|
|
|
56
59
|
* random nonce so concurrent writers don't collide.
|
|
57
60
|
*/
|
|
58
61
|
private atomicWrite;
|
|
62
|
+
/** TTL pass first; if still at or above maxBlocksPerProject, evict oldest-mtime block(s) until under cap. */
|
|
63
|
+
private sweepInnerLruIfNeeded;
|
|
59
64
|
/**
|
|
60
65
|
* Oldest-first eviction loop until total disk usage + incoming bytes
|
|
61
66
|
* fits under maxTotalBytes. Pinned entries are skipped (matches
|
|
@@ -63,5 +68,7 @@ export declare class FileBackedContextBlockStore implements ContextBlockStore {
|
|
|
63
68
|
* batch and shouldn't be evicted mid-run).
|
|
64
69
|
*/
|
|
65
70
|
private evictUntilFits;
|
|
71
|
+
/** Scan this project's meta files for one whose recorded sha256 matches `sha256`. Returns the id, or null. */
|
|
72
|
+
private findByContentSha;
|
|
66
73
|
}
|
|
67
74
|
//# sourceMappingURL=file-backed-context-block-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-backed-context-block-store.d.ts","sourceRoot":"","sources":["../../src/stores/file-backed-context-block-store.ts"],"names":[],"mappings":"AA0CA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAcjC,MAAM,WAAW,kCAAkC;IACjD,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"file-backed-context-block-store.d.ts","sourceRoot":"","sources":["../../src/stores/file-backed-context-block-store.ts"],"names":[],"mappings":"AA0CA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAcjC,MAAM,WAAW,kCAAkC;IACjD,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,2BAA4B,YAAW,iBAAiB;IACnE;qFACiF;IACjF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAK;IACxB;;kDAE8C;IAC9C,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;gBAEjC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,kCAAuC;IAqB7E,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,eAAe;IA0DtF,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAoBnC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAO3B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIrB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAMvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI5B,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAuBpD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;qCACiC;IACjC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,qEAAqE;IACrE,KAAK,IAAI,IAAI;IAKb;4CACwC;IACxC,gBAAgB,IAAI,MAAM;IAc1B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,OAAO;IAef,OAAO,CAAC,QAAQ;IAkBhB,OAAO,CAAC,WAAW;IAKnB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAYnB,6GAA6G;IAC7G,OAAO,CAAC,qBAAqB;IAqC7B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAwBtB,8GAA8G;IAC9G,OAAO,CAAC,gBAAgB;CAczB"}
|
|
@@ -45,7 +45,7 @@ const DEFAULT_GC_INTERVAL_MS = 60 * 60 * 1000;
|
|
|
45
45
|
const DEFAULT_MAX_BLOCK_BYTES = 1 * 1024 * 1024;
|
|
46
46
|
const DEFAULT_MAX_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
47
47
|
export class FileBackedContextBlockStore {
|
|
48
|
-
/** Absolute root: `<homeDir>/.multi-model
|
|
48
|
+
/** Absolute root: `<homeDir>/.multi-model/context-blocks/<sha256(projectCwd)>`.
|
|
49
49
|
* Public so tests can read meta files directly without re-deriving the path. */
|
|
50
50
|
rootDir;
|
|
51
51
|
_ttlMs;
|
|
@@ -57,27 +57,62 @@ export class FileBackedContextBlockStore {
|
|
|
57
57
|
* protection signal, not a persistence concern. Lost on restart;
|
|
58
58
|
* TTL-based GC handles the recovery side. */
|
|
59
59
|
pinCounts = new Map();
|
|
60
|
+
maxBlocksPerProject;
|
|
60
61
|
constructor(projectCwd, opts = {}) {
|
|
61
62
|
const home = opts.homeDir ?? os.homedir();
|
|
62
|
-
|
|
63
|
+
let canonical;
|
|
64
|
+
try {
|
|
65
|
+
canonical = fs.realpathSync(path.resolve(projectCwd));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Path doesn't exist on disk yet — fall back to absolute. The store is
|
|
69
|
+
// still usable for callers who pass a future cwd; symlink-collapse
|
|
70
|
+
// semantics only kick in once the path exists.
|
|
71
|
+
canonical = path.resolve(projectCwd);
|
|
72
|
+
}
|
|
73
|
+
const projectHash = createHash('sha256').update(canonical).digest('hex');
|
|
63
74
|
this.rootDir = path.join(home, '.multi-model', 'context-blocks', projectHash);
|
|
64
75
|
this._ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS;
|
|
65
76
|
this.gcCheckIntervalMs = opts.gcCheckIntervalMs ?? DEFAULT_GC_INTERVAL_MS;
|
|
66
77
|
this.maxBlockBytes = opts.maxBlockBytes ?? DEFAULT_MAX_BLOCK_BYTES;
|
|
67
78
|
this.maxTotalBytes = opts.maxTotalBytes ?? DEFAULT_MAX_TOTAL_BYTES;
|
|
79
|
+
this.maxBlocksPerProject = opts.maxBlocksPerProject ?? 500;
|
|
68
80
|
this.ensureRoot();
|
|
69
81
|
}
|
|
70
82
|
register(content, opts = {}) {
|
|
83
|
+
const sha256 = createHash('sha256').update(content).digest('hex');
|
|
84
|
+
// 4.2.3+: fall back to the class-level _ttlMs default (configured at
|
|
85
|
+
// construction) rather than a hardcoded constant. Earlier draft of
|
|
86
|
+
// the plan literally said `?? 28_800_000` which broke the
|
|
87
|
+
// "lazy-deletes on get when entry is past TTL" pre-existing test —
|
|
88
|
+
// that test constructs the store with `ttlMs: 1` and then calls
|
|
89
|
+
// `register('x')` (no opts), expecting the per-call TTL to inherit
|
|
90
|
+
// the class default.
|
|
91
|
+
const ttlMs = opts.ttlMs ?? this._ttlMs;
|
|
92
|
+
// DEDUPE: look for existing block in this project with matching content sha
|
|
93
|
+
if (!opts.id) {
|
|
94
|
+
const existing = this.findByContentSha(sha256);
|
|
95
|
+
if (existing) {
|
|
96
|
+
// Bump mtime + reset TTL on the existing block
|
|
97
|
+
const now = Date.now();
|
|
98
|
+
const metaContent = JSON.parse(fs.readFileSync(this.metaPath(existing), 'utf8'));
|
|
99
|
+
metaContent.ttlMs = ttlMs;
|
|
100
|
+
metaContent.createdAt = now;
|
|
101
|
+
fs.writeFileSync(this.metaPath(existing), JSON.stringify(metaContent), { mode: 0o600 });
|
|
102
|
+
fs.utimesSync(this.contentPath(existing), now / 1000, now / 1000);
|
|
103
|
+
fs.utimesSync(this.metaPath(existing), now / 1000, now / 1000);
|
|
104
|
+
return { id: existing, lengthChars: content.length, sha256 };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
71
107
|
const byteSize = Buffer.byteLength(content, 'utf8');
|
|
72
108
|
if (byteSize > this.maxBlockBytes) {
|
|
73
109
|
throw new Error(`Context block exceeds per-block cap of ${this.maxBlockBytes} bytes (got ${byteSize}).`);
|
|
74
110
|
}
|
|
75
111
|
const id = opts.id ?? randomUUID();
|
|
76
112
|
const now = Date.now();
|
|
77
|
-
const sha256 = createHash('sha256').update(content).digest('hex');
|
|
78
113
|
const meta = {
|
|
79
114
|
createdAt: now,
|
|
80
|
-
ttlMs
|
|
115
|
+
ttlMs,
|
|
81
116
|
lengthChars: content.length,
|
|
82
117
|
sha256,
|
|
83
118
|
};
|
|
@@ -87,6 +122,7 @@ export class FileBackedContextBlockStore {
|
|
|
87
122
|
this.lastSweepMs = now;
|
|
88
123
|
}
|
|
89
124
|
this.evictUntilFits(byteSize);
|
|
125
|
+
this.sweepInnerLruIfNeeded();
|
|
90
126
|
this.atomicWrite(this.contentPath(id), content);
|
|
91
127
|
this.atomicWrite(this.metaPath(id), JSON.stringify(meta) + '\n');
|
|
92
128
|
return { id, lengthChars: content.length, sha256 };
|
|
@@ -251,6 +287,63 @@ export class FileBackedContextBlockStore {
|
|
|
251
287
|
}
|
|
252
288
|
fs.renameSync(tmpPath, targetPath);
|
|
253
289
|
}
|
|
290
|
+
/** TTL pass first; if still at or above maxBlocksPerProject, evict oldest-mtime block(s) until under cap. */
|
|
291
|
+
sweepInnerLruIfNeeded() {
|
|
292
|
+
if (!fs.existsSync(this.rootDir))
|
|
293
|
+
return;
|
|
294
|
+
// TTL pass
|
|
295
|
+
const now = Date.now();
|
|
296
|
+
const files = fs.readdirSync(this.rootDir);
|
|
297
|
+
for (const file of files) {
|
|
298
|
+
if (!file.endsWith('.meta.json'))
|
|
299
|
+
continue;
|
|
300
|
+
try {
|
|
301
|
+
const meta = JSON.parse(fs.readFileSync(path.join(this.rootDir, file), 'utf8'));
|
|
302
|
+
if (typeof meta.createdAt === 'number' && typeof meta.ttlMs === 'number' && now > meta.createdAt + meta.ttlMs) {
|
|
303
|
+
const id = file.slice(0, -'.meta.json'.length);
|
|
304
|
+
try {
|
|
305
|
+
fs.unlinkSync(path.join(this.rootDir, `${id}.txt`));
|
|
306
|
+
}
|
|
307
|
+
catch { }
|
|
308
|
+
try {
|
|
309
|
+
fs.unlinkSync(path.join(this.rootDir, `${id}.meta.json`));
|
|
310
|
+
}
|
|
311
|
+
catch { }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch { /* skip malformed */ }
|
|
315
|
+
}
|
|
316
|
+
// LRU pass
|
|
317
|
+
let blockIds = fs.readdirSync(this.rootDir)
|
|
318
|
+
.filter(f => f.endsWith('.txt'))
|
|
319
|
+
.map(f => f.slice(0, -'.txt'.length));
|
|
320
|
+
while (blockIds.length >= this.maxBlocksPerProject) {
|
|
321
|
+
// Find oldest-mtime block
|
|
322
|
+
let oldestId = null;
|
|
323
|
+
let oldestMtime = Infinity;
|
|
324
|
+
for (const id of blockIds) {
|
|
325
|
+
try {
|
|
326
|
+
const m = fs.statSync(path.join(this.rootDir, `${id}.txt`)).mtimeMs;
|
|
327
|
+
if (m < oldestMtime) {
|
|
328
|
+
oldestMtime = m;
|
|
329
|
+
oldestId = id;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
catch { /* skip */ }
|
|
333
|
+
}
|
|
334
|
+
if (!oldestId)
|
|
335
|
+
break;
|
|
336
|
+
try {
|
|
337
|
+
fs.unlinkSync(path.join(this.rootDir, `${oldestId}.txt`));
|
|
338
|
+
}
|
|
339
|
+
catch { }
|
|
340
|
+
try {
|
|
341
|
+
fs.unlinkSync(path.join(this.rootDir, `${oldestId}.meta.json`));
|
|
342
|
+
}
|
|
343
|
+
catch { }
|
|
344
|
+
blockIds = blockIds.filter(i => i !== oldestId);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
254
347
|
/**
|
|
255
348
|
* Oldest-first eviction loop until total disk usage + incoming bytes
|
|
256
349
|
* fits under maxTotalBytes. Pinned entries are skipped (matches
|
|
@@ -286,5 +379,24 @@ export class FileBackedContextBlockStore {
|
|
|
286
379
|
total -= c.bytes;
|
|
287
380
|
}
|
|
288
381
|
}
|
|
382
|
+
/** Scan this project's meta files for one whose recorded sha256 matches `sha256`. Returns the id, or null. */
|
|
383
|
+
findByContentSha(sha256) {
|
|
384
|
+
if (!fs.existsSync(this.rootDir))
|
|
385
|
+
return null;
|
|
386
|
+
const files = fs.readdirSync(this.rootDir);
|
|
387
|
+
for (const file of files) {
|
|
388
|
+
if (!file.endsWith('.meta.json'))
|
|
389
|
+
continue;
|
|
390
|
+
try {
|
|
391
|
+
const meta = JSON.parse(fs.readFileSync(path.join(this.rootDir, file), 'utf8'));
|
|
392
|
+
if (meta.sha256 === sha256)
|
|
393
|
+
return file.slice(0, -'.meta.json'.length);
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
// Skip malformed meta files
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
289
401
|
}
|
|
290
402
|
//# sourceMappingURL=file-backed-context-block-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-backed-context-block-store.js","sourceRoot":"","sources":["../../src/stores/file-backed-context-block-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAMlC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/C,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9C,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAsBlD,MAAM,OAAO,2BAA2B;IACtC;qFACiF;IACxE,OAAO,CAAS;IACjB,MAAM,CAAS;IACf,iBAAiB,CAAS;IAC1B,aAAa,CAAS;IACtB,aAAa,CAAS;IACtB,WAAW,GAAG,CAAC,CAAC;IACxB;;kDAE8C;IACtC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE9C,YAAY,UAAkB,EAAE,OAA2C,EAAE;QAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAC1C,MAAM,WAAW,GAAG,U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KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IAED,8GAA8G;IACtG,gBAAgB,CAAC,MAAc;QACrC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAAE,SAAS;YAC3C,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBAChF,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM;oBAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACzE,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan-audit failure-mode taxonomy (4.2.3+).
|
|
3
|
+
*
|
|
4
|
+
* Drives the parallel-criteria fan-out for `auditType: 'plan'` audits.
|
|
5
|
+
* Each numbered entry below becomes one sub-worker assigned to a single
|
|
6
|
+
* verification dimension. Sub-workers run on the existing complex tier
|
|
7
|
+
* with read-only tools (read_file / grep / glob / list_files); they
|
|
8
|
+
* derive source files to verify from the plan itself, then ground each
|
|
9
|
+
* finding in actual file-and-line evidence.
|
|
10
|
+
*
|
|
11
|
+
* A perspective emitting zero findings means "this dimension passes for
|
|
12
|
+
* this plan." That is the EXPECTED outcome for several perspectives on
|
|
13
|
+
* a clean plan; the merge annotator does NOT inflate severity to fill
|
|
14
|
+
* a quota.
|
|
15
|
+
*
|
|
16
|
+
* Contrast with DOC_AUDIT_FAILURE_MODES (in implementer-criteria.ts):
|
|
17
|
+
* those 11 categories are prose-INTERNAL coherence (ambiguity,
|
|
18
|
+
* contradiction, drift between sections). The 8 perspectives below are
|
|
19
|
+
* EXTERNAL coherence — does the plan match the codebase?
|
|
20
|
+
*/
|
|
21
|
+
import { type CriterionEntry } from '../criteria-types.js';
|
|
22
|
+
/** Orientation block — goes at the top of every plan-audit sub-worker
|
|
23
|
+
* prompt. Contrast with AUDIT_PURPOSE_ORIENTATION (prose-coherence
|
|
24
|
+
* audit): plan-audit sub-workers verify EXTERNAL coherence (plan vs
|
|
25
|
+
* codebase), not internal-coherence. */
|
|
26
|
+
export declare const PLAN_AUDIT_PURPOSE_ORIENTATION: string;
|
|
27
|
+
export declare const EVIDENCE_RULE_PLAN_AUDIT: string;
|
|
28
|
+
export declare const SCOPE_RULE_PLAN_AUDIT: string;
|
|
29
|
+
export declare const ANNOTATOR_AWARENESS_PLAN_AUDIT: string;
|
|
30
|
+
export declare const PLAN_AUDIT_FAILURE_MODES: string;
|
|
31
|
+
/** Parsed criterion array for the parallel-criteria fan-out. Eight
|
|
32
|
+
* sub-workers, one per verification perspective. Derived from
|
|
33
|
+
* PLAN_AUDIT_FAILURE_MODES so prose and dispatcher stay in lockstep. */
|
|
34
|
+
export declare const PLAN_AUDIT_CRITERIA: readonly CriterionEntry[];
|
|
35
|
+
//# sourceMappingURL=plan-audit-criteria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-audit-criteria.d.ts","sourceRoot":"","sources":["../../../src/tools/audit/plan-audit-criteria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE1E;;;yCAGyC;AACzC,eAAO,MAAM,8BAA8B,QAsC/B,CAAC;AAEb,eAAO,MAAM,wBAAwB,QAOzB,CAAC;AAEb,eAAO,MAAM,qBAAqB,QAKtB,CAAC;AAEb,eAAO,MAAM,8BAA8B,QAO/B,CAAC;AAGb,eAAO,MAAM,wBAAwB,QA4CzB,CAAC;AAEb;;yEAEyE;AACzE,eAAO,MAAM,mBAAmB,EAAE,SAAS,cAAc,EAA4C,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan-audit failure-mode taxonomy (4.2.3+).
|
|
3
|
+
*
|
|
4
|
+
* Drives the parallel-criteria fan-out for `auditType: 'plan'` audits.
|
|
5
|
+
* Each numbered entry below becomes one sub-worker assigned to a single
|
|
6
|
+
* verification dimension. Sub-workers run on the existing complex tier
|
|
7
|
+
* with read-only tools (read_file / grep / glob / list_files); they
|
|
8
|
+
* derive source files to verify from the plan itself, then ground each
|
|
9
|
+
* finding in actual file-and-line evidence.
|
|
10
|
+
*
|
|
11
|
+
* A perspective emitting zero findings means "this dimension passes for
|
|
12
|
+
* this plan." That is the EXPECTED outcome for several perspectives on
|
|
13
|
+
* a clean plan; the merge annotator does NOT inflate severity to fill
|
|
14
|
+
* a quota.
|
|
15
|
+
*
|
|
16
|
+
* Contrast with DOC_AUDIT_FAILURE_MODES (in implementer-criteria.ts):
|
|
17
|
+
* those 11 categories are prose-INTERNAL coherence (ambiguity,
|
|
18
|
+
* contradiction, drift between sections). The 8 perspectives below are
|
|
19
|
+
* EXTERNAL coherence — does the plan match the codebase?
|
|
20
|
+
*/
|
|
21
|
+
import { parseCriteria } from '../criteria-types.js';
|
|
22
|
+
/** Orientation block — goes at the top of every plan-audit sub-worker
|
|
23
|
+
* prompt. Contrast with AUDIT_PURPOSE_ORIENTATION (prose-coherence
|
|
24
|
+
* audit): plan-audit sub-workers verify EXTERNAL coherence (plan vs
|
|
25
|
+
* codebase), not internal-coherence. */
|
|
26
|
+
export const PLAN_AUDIT_PURPOSE_ORIENTATION = [
|
|
27
|
+
'Why this audit exists:',
|
|
28
|
+
'You are auditing a CODE-EXECUTION PLAN against a real codebase. The plan will subsequently be dispatched to literal-following workers via mma-execute-plan; if the plan names a method, file, type, or signature that does not match the codebase as it exists today, the worker will freeze on the contradiction or produce broken code. Your job: verify every plan claim against actual codebase ground truth.',
|
|
29
|
+
'',
|
|
30
|
+
'Your job is NOT prose-quality (that is the default audit\'s job). Your job is external coherence: for every named symbol, file path, signature, or import in the plan, the codebase must contain it as described — UNLESS the plan task is the one creating it. (See "How to classify a plan\'s mention of X" below.)',
|
|
31
|
+
'',
|
|
32
|
+
'Tool surface: read_file / grep / glob / list_files. The plan itself is in your filePaths input (one file). Source files are NOT pre-listed — you derive them from the plan\'s "Files: Modify:" / "Test:" / "Create:" blocks and from import statements in code blocks, then grep / read them yourself under cwd.',
|
|
33
|
+
'',
|
|
34
|
+
'A finding without an actual file-and-line reference for the source side is speculation, not a load-bearing finding. Drop it. If a perspective has no findings to flag for this plan, that is the correct outcome — say so via the standard "No findings for this criterion." string and move on.',
|
|
35
|
+
'',
|
|
36
|
+
'— BEFORE FLAGGING — How to classify a plan\'s mention of X (REQUIRED triage step):',
|
|
37
|
+
'',
|
|
38
|
+
'Plans contain TWO different kinds of symbol mention. Confusing them is the #1 way plan-audits over-flag and produce false positives. Before any SYMBOL EXISTENCE / SIGNATURE MATCH / IMPORT GRAPH finding, classify the mention:',
|
|
39
|
+
'',
|
|
40
|
+
'**USE intent** — the plan TREATS X as already existing in the codebase. The task ASSUMES the symbol is there. Examples:',
|
|
41
|
+
' • method calls: `store.register(...)`, `obj.helper(...)`, `await provider.run(...)`',
|
|
42
|
+
' • property/field access: `config.someField`, `result.cost`, `this._ttlMs`',
|
|
43
|
+
' • import statements: `import { X } from "./bar.js"`',
|
|
44
|
+
' • type references: `function f(arg: X)`, `: Promise<X>`, `: ExistingInterface`',
|
|
45
|
+
' • test code calling production code: `expect(store.register(...))`',
|
|
46
|
+
'',
|
|
47
|
+
'**DEFINE intent** — the plan CREATES X in this task. X is the deliverable. Examples:',
|
|
48
|
+
' • function/method declarations: `function foo()`, `private foo()`, `static foo()`, `async foo()`',
|
|
49
|
+
' • class/interface/type declarations: `class Foo {}`, `interface Bar {}`, `type Q = ...`, `enum E {}`',
|
|
50
|
+
' • exported constants: `export const baz = ...`, `export function ...`',
|
|
51
|
+
' • new fields added to existing types: `interface ExistingType { newField: X }`',
|
|
52
|
+
' • new option keys on existing methods: `register(content: string, opts: { newOpt: X })`',
|
|
53
|
+
' • new test files via "Test: <path> (new)"',
|
|
54
|
+
' • new modules via "New: <path>" or "Create: <path>"',
|
|
55
|
+
'',
|
|
56
|
+
'**Verification rule by intent:**',
|
|
57
|
+
' • USE intent → the symbol MUST exist in the named source file. If grep returns no match → flag (CRITICAL, "did you mean: <nearest match>").',
|
|
58
|
+
' • DEFINE intent → the symbol MAY NOT exist yet. The task is the one adding it; that is the deliverable. **DO NOT FLAG.** This is the most common false-positive trap in plan audits.',
|
|
59
|
+
' • DEFINE intent + symbol DOES already exist in source → flag MEDIUM "task is obsolete; this deliverable already shipped — plan needs trimming."',
|
|
60
|
+
'',
|
|
61
|
+
'**Task scope = a unit.** Each `### Task X.Y:` heading + its `Files:` block + its numbered steps + their code blocks form ONE UNIT. Read the unit as a whole before flagging. Do not extract a symbol from a code block in isolation. Specifically: a `private findByContentSha(...) { … }` definition appearing inside Task A1.4\'s code block, where the task\'s `Files:` block names the implementation file as `Modify:`, is the task INTRODUCING that helper — not the task ASSUMING it already exists. Look at the task\'s intent before flagging the symbol.',
|
|
62
|
+
'',
|
|
63
|
+
'Heuristic for fast classification: if the plan\'s code block has a function/method declaration syntax ON THE SAME LINE as the symbol name, it\'s DEFINE intent. If the symbol appears as a callee, an imported name, a type annotation, or a property access, it\'s USE intent.',
|
|
64
|
+
].join('\n');
|
|
65
|
+
export const EVIDENCE_RULE_PLAN_AUDIT = [
|
|
66
|
+
'Evidence grounding (REQUIRED for every finding):',
|
|
67
|
+
'- Plan side: quote the exact line from the plan, with task ID + section reference (e.g. "Plan A1.4 step 3 line: `store.registerBlock(content, opts)`").',
|
|
68
|
+
'- Source side: file path + line number + actual content (e.g. "`packages/core/src/stores/file-backed-context-block-store.ts:113` defines `register(content, opts)` — no method named `registerBlock`").',
|
|
69
|
+
'- For SYMBOL-EXISTENCE findings: include the nearest match (Levenshtein) the worker found in the source. Example: "did you mean `register`? (Levenshtein distance 5)".',
|
|
70
|
+
'- For SIGNATURE-MATCH findings: quote BOTH the plan\'s call (with parameter names/types) AND the source\'s actual signature.',
|
|
71
|
+
'- A finding without both sides is speculation. Drop it.',
|
|
72
|
+
].join('\n');
|
|
73
|
+
export const SCOPE_RULE_PLAN_AUDIT = [
|
|
74
|
+
'Scope:',
|
|
75
|
+
'- The plan markdown (your one filePath input) plus the source files the plan directly references (in "Files: Modify:" / "Test:" / "Create:" lines, or via `import` statements in code blocks).',
|
|
76
|
+
'- Use grep / read_file targeted at the symbols and paths the plan names. DO NOT do an enumeration of the entire codebase.',
|
|
77
|
+
'- Out of scope: prose-quality issues in the plan (use auditType=default for that), suggestions for refactoring the plan\'s recommendations, and any source files the plan does not reference.',
|
|
78
|
+
].join('\n');
|
|
79
|
+
export const ANNOTATOR_AWARENESS_PLAN_AUDIT = [
|
|
80
|
+
'After your output, an annotator validates each finding against this plan-audit-specific rubric:',
|
|
81
|
+
'- Does the finding cite both plan-side and source-side evidence (with file:line for the source)?',
|
|
82
|
+
'- Is the finding categorized correctly by perspective (1 PATH / 2 SYMBOL / 3 SIGNATURE / 4 IMPORT / 5 TEST HARNESS / 6 STEP SEQUENCE / 7 CROSS-TASK / 8 VERIFY CMD)?',
|
|
83
|
+
'- Is the severity calibrated to actual dispatch impact (CRITICAL only when the task would BLOCK; HIGH for ambiguity that produces wrong artifact; MEDIUM for recoverable; LOW for cosmetic)?',
|
|
84
|
+
'- Does the finding name a specific task ID (e.g. "A1.4") so the merge annotator can group findings by task to compute per-task verdicts?',
|
|
85
|
+
'Self-check before emitting. Findings missing source-side evidence are downgraded to LOW or dropped — but findings backed by file:line citations from a real file are FULLY VALID, do NOT downgrade them as "speculation."',
|
|
86
|
+
].join('\n');
|
|
87
|
+
export const PLAN_AUDIT_FAILURE_MODES = [
|
|
88
|
+
'Plan-audit perspectives — applicable to code-execution plans being audited against a real codebase. Each perspective is one verification dimension; emitting zero findings for a perspective means "this dimension passes for this plan." Do not invent findings to hit a quota — if a perspective has nothing to flag, stay silent for that dimension. Apply each perspective end-to-end across every task in the plan. Use read_file / grep / glob / list_files to ground every finding in actual file-and-line evidence; findings without a real source-side reference are not load-bearing and must be dropped.',
|
|
89
|
+
'',
|
|
90
|
+
'1. PATH EXISTENCE — every line under a task\'s "Files:" block must resolve correctly per its label. Sub-rules: (a) "Modify: <path>" → file MUST exist on disk; missing = CRITICAL (the task cannot start). (b) "Test: <path>" or "Test: <path> (new)" → parent directory MUST exist; the test file itself may or may not exist. (c) "New: <path>" or "Create: <path>" → parent directory MUST exist AND the file MUST NOT exist (if it does, the task is obsolete — plan needs trimming, MEDIUM). Use list_files / read_file to verify. CRITICAL on missing modify-targets or missing parent dirs. MEDIUM on already-existing create-targets.',
|
|
91
|
+
'',
|
|
92
|
+
'2. SYMBOL EXISTENCE — for every method / type / class / function / imported identifier appearing inside ```ts``` or ```typescript``` code blocks under a task: FIRST classify the mention as USE or DEFINE intent (see the orientation block above). ONLY flag USE-intent mentions where grep against the named source file returns no match. DEFINE-intent mentions are the task\'s deliverable — DO NOT FLAG. Plan says `store.registerBlock(...)` (USE — method call on existing object) against `file-backed-context-block-store.ts`? grep the file; if not found, CRITICAL with nearest match. Plan defines `private findByContentSha(...) { … }` (DEFINE — declaration syntax) inside a Modify-target code block? skip — the task is creating the helper. Always include the actual nearest match (Levenshtein) on USE-intent findings so the plan can be fixed in one edit.',
|
|
93
|
+
'',
|
|
94
|
+
'3. SIGNATURE MATCH — when the plan\'s code uses a method with specific parameters or expects a specific return shape, the actual signature in the source must match. Same intent rule applies: ONLY flag for USE-intent mentions (calls or imports). When the plan DEFINES a method or extends an interface signature, that\'s the deliverable — don\'t flag. Plan calls `register(content, { ttlMs: 60_000 })` (USE) but actual signature is `register(content, opts: { id?: string })` with no `ttlMs`? CRITICAL — call would fail at build. Plan ALSO has a step adding `ttlMs?: number` to the interface (DEFINE)? skip the DEFINE; flag only the call site if the call appears BEFORE the interface-extension step within the task\'s numbered sequence (out-of-order — see perspective 6).',
|
|
95
|
+
'',
|
|
96
|
+
'4. IMPORT GRAPH — every `import { X } from \'…\'` line in code blocks must resolve under the same intent rule. Imports inside test code are USE intent (the imported symbol must exist somewhere). Imports of NEW modules the task creates (e.g. `import { sweepProjectCap } from \'./context-block-project-cap.js\'` when the same task\'s "Files: New:" block lists `context-block-project-cap.ts`) are DEFINE-adjacent — don\'t flag the import itself, but DO flag if the task forgets to also add the corresponding `exports` entry in the workspace package.json (HIGH — the build will fail).',
|
|
97
|
+
'',
|
|
98
|
+
'5. TEST HARNESS AVAILABILITY — when the plan introduces test code, every helper / factory / fixture the test USES (calls / imports) must exist at the named path. `mockProvider`, `startTestServerWithAgents`, `mkdtempSync`, `mockAdapter`, etc. — verify via grep. **However**: if the task explicitly says it adds a new option to an existing helper (e.g. "extend `startTestServerWithAgents` to accept `configOverrides`"), that\'s DEFINE intent — don\'t flag the new option, but DO flag if the test code uses the new option BEFORE the task\'s numbered step that adds it (out-of-order, perspective 6). Helper truly missing (no path, no related task) = HIGH.',
|
|
99
|
+
'',
|
|
100
|
+
'6. STEP SEQUENCE WITHIN TASK — within a single task, the numbered steps must be executable in order. Step 4 says "verify the test passes" — was step 3 the implementation that the test exercises? Step 7 references `helper()` — was it defined by an earlier step or in source? No step depends on output from a later step. Severity MEDIUM unless the dependency would actually halt execution (then HIGH).',
|
|
101
|
+
'',
|
|
102
|
+
'7. CROSS-TASK DEPENDENCIES — when task B\'s code uses something task A introduces (a method, a type, a config field), the plan\'s task ordering must reflect the dependency. Plan A1.5 calls `findByContentSha()` defined by A1.4 but A1.5 appears earlier? CRITICAL — execution would fail. Less severe: dependency exists but is undeclared in the task description (no "depends on A1.4" note). MEDIUM.',
|
|
103
|
+
'',
|
|
104
|
+
'8. VERIFICATION COMMAND VALIDITY — every "Run: <command>" / "verify" instruction in the plan must work with the project\'s actual tooling. Plan says `npm run validate-things` — does package.json have that script? Plan says `npx vitest run tests/foo.test.ts` — does that path exist (after the task\'s implementation lands)? Plan says `cargo test` in a TypeScript project? CRITICAL. Vague verification ("run the test") with no concrete command? MEDIUM — workable but the worker has to guess.',
|
|
105
|
+
'',
|
|
106
|
+
'9. TASK GRANULARITY — each task should be implementable in one focused sub-agent run. Flag tasks that are oversized for single-run execution. Concrete signals (any one or in combination): the task touches more than 3 distinct source files; the task\'s code blocks contain more than ~40 net lines of diff; the task mixes unrelated concerns (e.g. extending a config schema AND adding a new module AND wiring a CLI flag in one task heading); the task lists more than ~6 numbered steps. Severity HIGH when the task clearly exceeds standard-tier capacity (would force escalation to complex tier or thrash through review/rework rounds); MEDIUM when borderline. Suggested fix: split into atomic sub-tasks, one per file or one per concept, each with its own "Files:" block and numbered steps. The audit-fix loop iterates: author re-runs plan-audit, sees tasks downsized, re-audits until clean. This perspective is the upstream complement to perspective 6 (STEP SEQUENCE WITHIN TASK) — perspective 6 catches ordering bugs WITHIN a task; this one catches "task is too big to be one task at all."',
|
|
107
|
+
'',
|
|
108
|
+
'Severity calibration for plan audits:',
|
|
109
|
+
'- critical: plan claim contradicts codebase ground truth in a way that BLOCKS dispatch — task cannot start as written. Examples: missing modify-target file (perspective 1), wrong method name (perspective 2), wrong signature/return type (perspective 3), missing module export (perspective 4), out-of-order task dependency (perspective 7), wrong tooling (perspective 8).',
|
|
110
|
+
'- high: load-bearing ambiguity that risks wrong implementation. Plan signature is consistent with itself but multiple matching symbols exist in the source and the plan doesn\'t disambiguate. Test harness missing in the form claimed but the worker could synthesize. Step depends on later step in a recoverable but ambiguous way. The task may execute, but produces an ambiguous artifact.',
|
|
111
|
+
'- medium: step ordering issue, cross-task dependency unstated but inferable, verify command vague but recoverable, missing parent dirs for create-targets. Fixable by reordering or adding a sentence; doesn\'t block dispatch.',
|
|
112
|
+
'- low: stylistic, missing metadata, naming preference. Cosmetic.',
|
|
113
|
+
'',
|
|
114
|
+
'Per-task verdict (the merge-annotator computes this from all sub-worker findings):',
|
|
115
|
+
'- EXECUTABLE: zero CRITICAL or HIGH findings against this task across all 8 perspectives.',
|
|
116
|
+
'- PARTIAL: one or more HIGH findings, no CRITICAL. Task may execute but produces an ambiguous result.',
|
|
117
|
+
'- BLOCKED: one or more CRITICAL findings. Task cannot be dispatched as written; a literal worker would freeze.',
|
|
118
|
+
'',
|
|
119
|
+
'Output format for each finding:',
|
|
120
|
+
'- Task ID (e.g., "A1.4") that the finding affects.',
|
|
121
|
+
'- Perspective number (1-8) and name.',
|
|
122
|
+
'- Plan claim: quote the line + section reference.',
|
|
123
|
+
'- Source reality: file path + line number + actual content.',
|
|
124
|
+
'- Severity (critical / high / medium / low).',
|
|
125
|
+
'- Suggested fix: concrete edit (e.g. "rename `registerBlock` → `register` in plan A1.4 step 3", or "rename source method to match plan").',
|
|
126
|
+
'',
|
|
127
|
+
'Anti-patterns to avoid:',
|
|
128
|
+
'- Speculation without source-file evidence. If you can\'t open the file and find the line, drop the finding.',
|
|
129
|
+
'- Flagging a perspective on prose-quality grounds. That\'s the default audit\'s job, not yours. You only flag external coherence (plan vs codebase).',
|
|
130
|
+
'- Inventing findings to fill quota. Zero findings on a perspective is the correct outcome when the dimension passes.',
|
|
131
|
+
].join('\n');
|
|
132
|
+
/** Parsed criterion array for the parallel-criteria fan-out. Eight
|
|
133
|
+
* sub-workers, one per verification perspective. Derived from
|
|
134
|
+
* PLAN_AUDIT_FAILURE_MODES so prose and dispatcher stay in lockstep. */
|
|
135
|
+
export const PLAN_AUDIT_CRITERIA = parseCriteria(PLAN_AUDIT_FAILURE_MODES);
|
|
136
|
+
//# sourceMappingURL=plan-audit-criteria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-audit-criteria.js","sourceRoot":"","sources":["../../../src/tools/audit/plan-audit-criteria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAuB,MAAM,sBAAsB,CAAC;AAE1E;;;yCAGyC;AACzC,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,wBAAwB;IACxB,mZAAmZ;IACnZ,EAAE;IACF,uTAAuT;IACvT,EAAE;IACF,kTAAkT;IAClT,EAAE;IACF,kSAAkS;IAClS,EAAE;IACF,oFAAoF;IACpF,EAAE;IACF,kOAAkO;IAClO,EAAE;IACF,yHAAyH;IACzH,uFAAuF;IACvF,6EAA6E;IAC7E,uDAAuD;IACvD,kFAAkF;IAClF,sEAAsE;IACtE,EAAE;IACF,sFAAsF;IACtF,oGAAoG;IACpG,wGAAwG;IACxG,yEAAyE;IACzE,kFAAkF;IAClF,2FAA2F;IAC3F,6CAA6C;IAC7C,uDAAuD;IACvD,EAAE;IACF,kCAAkC;IAClC,+IAA+I;IAC/I,wLAAwL;IACxL,mJAAmJ;IACnJ,EAAE;IACF,oiBAAoiB;IACpiB,EAAE;IACF,iRAAiR;CAClR,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,kDAAkD;IAClD,yJAAyJ;IACzJ,yMAAyM;IACzM,wKAAwK;IACxK,8HAA8H;IAC9H,yDAAyD;CAC1D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ;IACR,gMAAgM;IAChM,2HAA2H;IAC3H,+LAA+L;CAChM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,iGAAiG;IACjG,kGAAkG;IAClG,sKAAsK;IACtK,8LAA8L;IAC9L,0IAA0I;IAC1I,2NAA2N;CAC5N,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAGb,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,qlBAAqlB;IACrlB,EAAE;IACF,+mBAA+mB;IAC/mB,EAAE;IACF,o1BAAo1B;IACp1B,EAAE;IACF,kwBAAkwB;IAClwB,EAAE;IACF,skBAAskB;IACtkB,EAAE;IACF,6oBAA6oB;IAC7oB,EAAE;IACF,iZAAiZ;IACjZ,EAAE;IACF,4YAA4Y;IAC5Y,EAAE;IACF,2eAA2e;IAC3e,EAAE;IACF,+jCAA+jC;IAC/jC,EAAE;IACF,uCAAuC;IACvC,kXAAkX;IAClX,mYAAmY;IACnY,iOAAiO;IACjO,kEAAkE;IAClE,EAAE;IACF,oFAAoF;IACpF,2FAA2F;IAC3F,uGAAuG;IACvG,gHAAgH;IAChH,EAAE;IACF,iCAAiC;IACjC,oDAAoD;IACpD,sCAAsC;IACtC,mDAAmD;IACnD,6DAA6D;IAC7D,8CAA8C;IAC9C,2IAA2I;IAC3I,EAAE;IACF,yBAAyB;IACzB,8GAA8G;IAC9G,sJAAsJ;IACtJ,sHAAsH;CACvH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;yEAEyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAA8B,aAAa,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type PlanTaskVerdict = 'EXECUTABLE' | 'PARTIAL' | 'BLOCKED';
|
|
2
|
+
export interface PlanAuditFinding {
|
|
3
|
+
taskId: string;
|
|
4
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
5
|
+
}
|
|
6
|
+
export declare function derivePlanTaskVerdicts(findings: ReadonlyArray<PlanAuditFinding>): Map<string, PlanTaskVerdict>;
|
|
7
|
+
export interface PlanAuditSummary {
|
|
8
|
+
text: string;
|
|
9
|
+
executable: string[];
|
|
10
|
+
partial: string[];
|
|
11
|
+
blocked: string[];
|
|
12
|
+
nextBlocker: string | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function composePlanAuditSummary(allTaskIds: ReadonlyArray<string>, verdicts: ReadonlyMap<string, PlanTaskVerdict>): PlanAuditSummary;
|
|
15
|
+
//# sourceMappingURL=plan-audit-verdict.d.ts.map
|