@iowarp/clio-coder 0.3.7 → 0.3.8
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/CHANGELOG.md +31 -0
- package/README.md +7 -2
- package/dist/{acp-SK4MD6MM.js → acp-U67UHUK2.js} +13 -13
- package/dist/{agents-2FN2K6ME.js → agents-YU6SGALZ.js} +35 -33
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-QIYZWM5I.js → auth-5ZPJOIVG.js} +32 -24
- package/dist/builtins-C6JMZVV6.js +17 -0
- package/dist/{chunk-YD734TPH.js → chunk-26LEYJZH.js} +2 -2
- package/dist/{chunk-TSHXZTOQ.js → chunk-2HEJ2F35.js} +5 -5
- package/dist/{chunk-WJHBC77E.js → chunk-2HFZQUHL.js} +5 -5
- package/dist/{chunk-FO5ZOVUY.js → chunk-3BINW3FP.js} +5 -5
- package/dist/{chunk-EOOQZZDE.js → chunk-4SPRNWDE.js} +18 -18
- package/dist/{chunk-EBEFWSGL.js → chunk-5DHKRSMQ.js} +7 -7
- package/dist/{chunk-OBMAI2DP.js → chunk-5H3GB5BO.js} +11 -9
- package/dist/{chunk-JTSEDYVQ.js → chunk-5Q2VVUKB.js} +7 -7
- package/dist/{chunk-VQNODYQ4.js → chunk-7RFXX52T.js} +294 -3704
- package/dist/{chunk-XEGB6BCN.js → chunk-7RGZWPB6.js} +5 -5
- package/dist/{chunk-GH5622CP.js → chunk-A2NJGIB3.js} +2 -2
- package/dist/{chunk-CEYBNUGC.js → chunk-A3WNZD3P.js} +323 -27
- package/dist/{chunk-D4MDIG46.js → chunk-B5CSFE7B.js} +7 -7
- package/dist/{chunk-2SFS6XQE.js → chunk-DGSYXYMX.js} +3 -2
- package/dist/{chunk-ZWLZP4ZT.js → chunk-DYIM5TJT.js} +98 -12
- package/dist/{chunk-KCMKRQX4.js → chunk-E77JEWSD.js} +42 -49
- package/dist/{chunk-J7PIKKWC.js → chunk-EMYUUSFG.js} +7 -7
- package/dist/{chunk-JRIO5UD2.js → chunk-EQ63NRB7.js} +5 -5
- package/dist/{chunk-UVDSQ6LW.js → chunk-FBVTI2TJ.js} +74 -28
- package/dist/{chunk-BMWK7ZIZ.js → chunk-FHJEP5SW.js} +13 -13
- package/dist/{chunk-FOT2FX5J.js → chunk-GN57SG4G.js} +7 -7
- package/dist/{chunk-SROCI7ZU.js → chunk-GPIEI3LY.js} +5 -5
- package/dist/{chunk-UFQ3F4FW.js → chunk-GU2UIAFZ.js} +4 -4
- package/dist/{chunk-UND3GU2L.js → chunk-H7IXIC72.js} +2 -2
- package/dist/{chunk-VREKEFLL.js → chunk-HLE42MG7.js} +3 -3
- package/dist/{chunk-465YSENW.js → chunk-IFBNV6H6.js} +3 -3
- package/dist/{chunk-LADCF22A.js → chunk-IGWKHNIQ.js} +113 -54
- package/dist/chunk-IIZWH4XA.js +172 -0
- package/dist/{chunk-UHXRNZ2J.js → chunk-IJ7RPIYJ.js} +4 -4
- package/dist/{chunk-M4AKACEO.js → chunk-J3YUBZWY.js} +2 -2
- package/dist/{chunk-AB4XIIVB.js → chunk-JOZYP4GM.js} +6 -6
- package/dist/{chunk-ZGH7FGS5.js → chunk-K4XHGFR5.js} +742 -12
- package/dist/{chunk-EELBMBT6.js → chunk-KTYTFRMB.js} +62 -5
- package/dist/chunk-LU7P4LHA.js +33 -0
- package/dist/{chunk-DQA7QLMD.js → chunk-ME6CCNFO.js} +9 -24
- package/dist/{chunk-KZ2H5X4G.js → chunk-MXKJU4JB.js} +88 -14
- package/dist/{chunk-DMD2AGVS.js → chunk-N22QMJKY.js} +20 -18
- package/dist/chunk-NMPKI6XL.js +3006 -0
- package/dist/chunk-NUGM5KR6.js +165 -0
- package/dist/{chunk-5C77SEEY.js → chunk-P43ETTHK.js} +2 -2
- package/dist/{chunk-JNXPYBB4.js → chunk-PMDBGQSJ.js} +2 -2
- package/dist/chunk-PT7HYKEM.js +165 -0
- package/dist/{chunk-GEYXPTRF.js → chunk-RWSI4YD7.js} +2 -2
- package/dist/{chunk-C4JBQ5SR.js → chunk-TANS5ZJS.js} +6 -6
- package/dist/{chunk-YTYFXUI3.js → chunk-TB5666IT.js} +9 -9
- package/dist/{chunk-UUANF5CR.js → chunk-TLQJPP24.js} +375 -687
- package/dist/{chunk-OB5HIGJY.js → chunk-TT36MB5S.js} +2 -1
- package/dist/{chunk-DJNLUABN.js → chunk-TTHACPOM.js} +135 -17
- package/dist/{chunk-6M7VS3J3.js → chunk-TYPGUK6W.js} +4 -4
- package/dist/{chunk-THKY7CD7.js → chunk-U6MBIEMB.js} +108 -24
- package/dist/{chunk-PD3MESLB.js → chunk-VAWNZU7Z.js} +4 -4
- package/dist/{chunk-IR4CFBFN.js → chunk-VCBR6CU7.js} +12 -12
- package/dist/{chunk-WHJYKASB.js → chunk-VHN4MY6O.js} +2 -2
- package/dist/{chunk-MXI6J5JF.js → chunk-VWZOAB7K.js} +10 -10
- package/dist/{chunk-QCTRSGHQ.js → chunk-WLFILSD5.js} +36 -36
- package/dist/{chunk-5UJ6ECTS.js → chunk-WNIJTQQK.js} +6 -6
- package/dist/{chunk-4DWFMQDR.js → chunk-WSB3FPX7.js} +68 -20
- package/dist/{chunk-3HAPLH5M.js → chunk-WWCZ5F23.js} +112 -10
- package/dist/{chunk-X2KV5FXT.js → chunk-WXY7KU3G.js} +2 -2
- package/dist/{chunk-PPAMZ32Z.js → chunk-XK56QHLX.js} +6 -1
- package/dist/{chunk-DOOEX22V.js → chunk-XWSF374K.js} +4 -4
- package/dist/{chunk-6TUKSZVF.js → chunk-YS5VLNH5.js} +8 -8
- package/dist/{chunk-ZZMN5OM4.js → chunk-ZNLWCMVZ.js} +2 -2
- package/dist/{chunk-WHGPSPT5.js → chunk-ZVJ5BLO2.js} +2 -2
- package/dist/cli/index.js +31 -31
- package/dist/{clio-WBVQEBKO.js → clio-QVTYJ57A.js} +8 -8
- package/dist/code-nav-FGGFIE7L.js +2 -2
- package/dist/codewiki/build-worker.js +4 -4
- package/dist/{components-F7OEATSO.js → components-ZFA3SAER.js} +8 -8
- package/dist/{config-TRBL3RCF.js → config-LW5IJFQN.js} +58 -53
- package/dist/{configure-OLCVPHNM.js → configure-7XIZCOU4.js} +26 -21
- package/dist/{context-XEWE3MOJ.js → context-L3WL3X7K.js} +47 -41
- package/dist/{context-WFPKQSM6.js → context-N52ZA626.js} +22 -22
- package/dist/{context-MJIJ6GOX.js → context-Y6Y7QPR6.js} +12 -12
- package/dist/{context-clear-KNOS2JPB.js → context-clear-MBQRLSDQ.js} +47 -41
- package/dist/{context-index-SSR5ECNE.js → context-index-HVMFQHK3.js} +5 -5
- package/dist/{context-working-set-EUXAZI6N.js → context-working-set-GS6DSO7F.js} +14 -14
- package/dist/{dispatch-runner-B7MTOVKL.js → dispatch-runner-22ZCNOM3.js} +83 -55
- package/dist/{docs-FLJTIDSE.js → docs-7LQ23DLM.js} +8 -8
- package/dist/{doctor-RN4YKO2X.js → doctor-M7YEDGAE.js} +24 -20
- package/dist/{eval-RUBJVSNQ.js → eval-BEC2WHDA.js} +71 -19
- package/dist/{evidence-JZNBUOQZ.js → evidence-REJUMSKM.js} +62 -56
- package/dist/{evolve-FJVC4KKI.js → evolve-PY5ZBA5K.js} +41 -35
- package/dist/{extensions-IQL36S7K.js → extensions-HVKU65YU.js} +6 -6
- package/dist/{fleet-BDKYJFCP.js → fleet-7WZEWRFA.js} +72 -67
- package/dist/{fleet-commands-ZFIWZSB3.js → fleet-commands-UVHWM76J.js} +10 -10
- package/dist/{fleet-graph-Y6HPXIVF.js → fleet-graph-6ULH7PES.js} +13 -13
- package/dist/{fleet-preflight-BHSNPBMH.js → fleet-preflight-J53T6CCE.js} +5 -5
- package/dist/{fleet-validate-BIYREGIK.js → fleet-validate-72PC4SLA.js} +17 -17
- package/dist/{init-LQUB5COQ.js → init-OG3TPGQG.js} +61 -56
- package/dist/{library-NJAHIGG4.js → library-CNTMPLRF.js} +18 -18
- package/dist/{memory-OG6HOYKM.js → memory-6IS7F275.js} +43 -37
- package/dist/{models-5ZG5XY7J.js → models-ENRJDA5W.js} +33 -28
- package/dist/{monitor-TJ7AMTGB.js → monitor-XLDVO7TN.js} +56 -38
- package/dist/{orchestrator-WZYB54DM.js → orchestrator-6KSPYRHA.js} +421 -303
- package/dist/{paths-XUC7GS6E.js → paths-DBXMZMDU.js} +5 -5
- package/dist/registry-LG64LTF4.js +11 -0
- package/dist/{reset-PXQT45IY.js → reset-RZ4ER727.js} +10 -10
- package/dist/{run-FQ74YF62.js → run-Y2CNK5RU.js} +79 -74
- package/dist/{share-FW7SVCL3.js → share-A55GYP6Z.js} +16 -16
- package/dist/{skills-7E7IRB3R.js → skills-ALC5J6AT.js} +19 -19
- package/dist/{skills-eval-LI75W6OK.js → skills-eval-JPBEBYQU.js} +52 -47
- package/dist/support-MIETYA5E.js +38 -0
- package/dist/{targets-4CIFKCTW.js → targets-VGNXIR3S.js} +42 -33
- package/dist/{terminal-lease-WUZY7ZV5.js → terminal-lease-WOBR64YA.js} +3 -3
- package/dist/{uninstall-7FV7IP4E.js → uninstall-ZJF5H5ZN.js} +8 -8
- package/dist/{upgrade-K2HVIVMQ.js → upgrade-FUSUAGHR.js} +27 -25
- package/dist/{usage-GTZELZQX.js → usage-N4MKVHKD.js} +51 -46
- package/dist/{verifiers-RLAHT27O.js → verifiers-YAWOJ3H2.js} +13 -13
- package/dist/{verify-BX3BRKH5.js → verify-LTDHYBGY.js} +9 -9
- package/dist/{wiki-generate-ASIFASCN.js → wiki-generate-6M7GHTBJ.js} +66 -61
- package/dist/worker/entry.js +68 -61
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +1 -1
- package/docs/artifact-versions.md +6 -5
- package/docs/built-in-agents.md +1 -1
- package/docs/commands-and-modes.md +2 -2
- package/docs/configuration-and-targets.md +8 -3
- package/docs/context-engine.md +1 -1
- package/docs/documentation-guide.md +1 -1
- package/docs/eval-runner.md +1 -1
- package/docs/evals-internal.md +1 -1
- package/docs/evidence-and-memory.md +70 -6
- package/docs/evolution.md +1 -1
- package/docs/extensions-and-sharing.md +1 -1
- package/docs/fleet-dispatch.md +34 -9
- package/docs/glossary.md +21 -1
- package/docs/installation-and-lifecycle.md +1 -1
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +1 -1
- package/docs/observability.md +2 -2
- package/docs/proactive-memory.md +1 -1
- package/docs/prompt-envelope-and-tools.md +4 -2
- package/docs/provider-adapter-cookbook.md +1 -1
- package/docs/release-cut-checklist.md +41 -38
- package/docs/safety-model.md +1 -1
- package/docs/scientific-validation.md +1 -1
- package/docs/skills-marketplace.md +1 -1
- package/docs/tool-usage.md +1 -1
- package/docs/trace-store.md +1 -1
- package/docs/tui-design.md +1 -1
- package/docs/worker-dispatch-mechanics.md +1 -1
- package/package.json +1 -2
- package/src/cli/argv.ts +5 -0
- package/src/cli/configure.ts +107 -23
- package/src/cli/doctor.ts +5 -1
- package/src/cli/evidence.ts +30 -25
- package/src/cli/fleet-preflight.ts +2 -12
- package/src/cli/shared.ts +1 -0
- package/src/cli/targets.ts +4 -1
- package/src/cli/validate-model.ts +60 -5
- package/src/core/bus-events.ts +25 -0
- package/src/core/commit-attribution.ts +4 -4
- package/src/core/path-boundary.ts +100 -0
- package/src/domains/agents/extension.ts +2 -11
- package/src/domains/agents/fleet-contract.ts +30 -12
- package/src/domains/agents/recipe.ts +7 -1
- package/src/domains/agents/registry.ts +73 -5
- package/src/domains/agents/result-contract.ts +128 -17
- package/src/domains/agents/write-boundary.ts +15 -50
- package/src/domains/context/project-rules.ts +51 -1
- package/src/domains/dispatch/assignment-reconcile.ts +22 -5
- package/src/domains/dispatch/assignment-store.ts +151 -14
- package/src/domains/dispatch/contract.ts +15 -1
- package/src/domains/dispatch/delegation-plan.ts +2 -5
- package/src/domains/dispatch/execution-role.ts +9 -1
- package/src/domains/dispatch/extension.ts +156 -67
- package/src/domains/dispatch/fleet-run.ts +57 -3
- package/src/domains/dispatch/gate-role-prompts.ts +38 -0
- package/src/domains/dispatch/index.ts +3 -1
- package/src/domains/dispatch/intent-requirements.ts +40 -0
- package/src/domains/dispatch/intent.ts +84 -8
- package/src/domains/dispatch/path-scope.ts +370 -0
- package/src/domains/dispatch/receipt-integrity.ts +2 -1
- package/src/domains/dispatch/types.ts +14 -7
- package/src/domains/dispatch/validation.ts +6 -3
- package/src/domains/dispatch/write-boundary-enforcer.ts +45 -0
- package/src/domains/dispatch/write-boundary.ts +201 -22
- package/src/domains/eval/metrics/evidence.ts +79 -2
- package/src/domains/eval/runners/clio-run.ts +12 -2
- package/src/domains/evidence/build.ts +69 -11
- package/src/domains/evidence/index.ts +21 -0
- package/src/domains/evidence/provenance.ts +46 -11
- package/src/domains/evidence/trust-projection.ts +274 -0
- package/src/domains/evidence/trust-status.ts +145 -17
- package/src/domains/evidence/types.ts +4 -0
- package/src/domains/extensions/discovery.ts +88 -1
- package/src/domains/extensions/resources.ts +20 -8
- package/src/domains/extensions/state.ts +6 -2
- package/src/domains/extensions/types.ts +4 -1
- package/src/domains/lifecycle/doctor.ts +140 -1
- package/src/domains/prompts/contract.ts +3 -5
- package/src/domains/providers/extension.ts +30 -2
- package/src/domains/resources/common-loader.ts +3 -0
- package/src/domains/resources/prompts/loader.ts +119 -14
- package/src/domains/safety/policy-engine.ts +5 -5
- package/src/domains/safety/run-effects.ts +64 -1
- package/src/domains/safety/scope.ts +7 -12
- package/src/engine/acp/server.ts +4 -1
- package/src/engine/prompt-templates.ts +18 -1
- package/src/engine/worker-runtime.ts +6 -3
- package/src/interactive/dispatch-board.ts +53 -3
- package/src/interactive/interactive-event-projection.ts +14 -0
- package/src/interactive/overlays/settings.ts +141 -47
- package/src/interactive/slash-commands.ts +7 -2
- package/src/interactive/view/artifacts.ts +42 -9
- package/src/interactive/view/view-overlay.ts +15 -3
- package/src/interactive/worker-receipts.ts +14 -2
- package/src/interactive/worker-stream.ts +8 -0
- package/src/tools/dispatch-admission.ts +12 -13
- package/src/tools/dispatch-arguments.ts +27 -0
- package/src/tools/dispatch-plan.ts +29 -0
- package/src/tools/dispatch-runner.ts +48 -13
- package/src/tools/monitor.ts +13 -0
- package/src/tools/worker-evidence.ts +19 -13
- package/src/worker/spec-contract.ts +2 -1
|
@@ -5,7 +5,26 @@ import {
|
|
|
5
5
|
readAuditRows,
|
|
6
6
|
readSessionEntriesForId,
|
|
7
7
|
responseModelIdObservationFromRecord
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YS5VLNH5.js";
|
|
9
|
+
import {
|
|
10
|
+
RUN_RECEIPT_INTEGRITY_ALGORITHM,
|
|
11
|
+
RUN_RECEIPT_INTEGRITY_VERSION,
|
|
12
|
+
adaptFinishContractCompletionStatus,
|
|
13
|
+
adaptGateDecisionReviewStatus,
|
|
14
|
+
adaptGroundedEvidenceValidationStatus,
|
|
15
|
+
composeTrustStatus,
|
|
16
|
+
inspectRunReceiptTrustStatus,
|
|
17
|
+
isReceiptIntegrity,
|
|
18
|
+
isTrustStatusIdentifier,
|
|
19
|
+
loadEvalArtifact,
|
|
20
|
+
normalizeTrustStatus,
|
|
21
|
+
parseEvalArtifactV4,
|
|
22
|
+
redactArtifactForStorage,
|
|
23
|
+
retiredIntegrityVersionOf,
|
|
24
|
+
sumEvalHarnessMetrics,
|
|
25
|
+
verifyReceiptIntegrity,
|
|
26
|
+
withReceiptIntegrity
|
|
27
|
+
} from "./chunk-K4XHGFR5.js";
|
|
9
28
|
import {
|
|
10
29
|
applyTaskWorktree,
|
|
11
30
|
captureWorkspaceSnapshot,
|
|
@@ -13,26 +32,19 @@ import {
|
|
|
13
32
|
createTaskWorktree,
|
|
14
33
|
createWriteBoundaryEnforcer,
|
|
15
34
|
gitCheckoutRoot
|
|
16
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-MXKJU4JB.js";
|
|
17
36
|
import {
|
|
18
37
|
executionPlanAncestors,
|
|
19
38
|
spliceExecutionPlan
|
|
20
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-J3YUBZWY.js";
|
|
21
40
|
import {
|
|
22
41
|
parseRigorOverride,
|
|
23
42
|
resolveRigor
|
|
24
43
|
} from "./chunk-RVG5JXAL.js";
|
|
25
44
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
loadEvalArtifact,
|
|
30
|
-
parseEvalArtifactV4,
|
|
31
|
-
redactArtifactForStorage,
|
|
32
|
-
sumEvalHarnessMetrics,
|
|
33
|
-
verifyReceiptIntegrity,
|
|
34
|
-
withReceiptIntegrity
|
|
35
|
-
} from "./chunk-ZGH7FGS5.js";
|
|
45
|
+
FLEET_COMMAND_BASE_ENV,
|
|
46
|
+
normalizeWriteBoundary
|
|
47
|
+
} from "./chunk-E77JEWSD.js";
|
|
36
48
|
import {
|
|
37
49
|
LOCAL_NODE_ID,
|
|
38
50
|
computeSettingsFingerprint,
|
|
@@ -43,11 +55,7 @@ import {
|
|
|
43
55
|
receiptAttestationFields,
|
|
44
56
|
routeFactVerdict,
|
|
45
57
|
spawnNativeWorker
|
|
46
|
-
} from "./chunk-
|
|
47
|
-
import {
|
|
48
|
-
FLEET_COMMAND_BASE_ENV,
|
|
49
|
-
normalizeWriteBoundary
|
|
50
|
-
} from "./chunk-KCMKRQX4.js";
|
|
58
|
+
} from "./chunk-2HEJ2F35.js";
|
|
51
59
|
import {
|
|
52
60
|
AGENT_LEDGER_PROMPT_MAX_CHARS,
|
|
53
61
|
RETRYABLE_OUTCOMES,
|
|
@@ -69,6 +77,8 @@ import {
|
|
|
69
77
|
claudeSubprocessPermissionConfigForAutonomy,
|
|
70
78
|
competeStanceLiner,
|
|
71
79
|
createRunEffectsRecorder,
|
|
80
|
+
declaredScopeReplacementDiagnostic,
|
|
81
|
+
declaredScopeReplacementNotice,
|
|
72
82
|
describeCallAction,
|
|
73
83
|
isBoundedGateRolePrompt,
|
|
74
84
|
isClaudeCanonicalTool,
|
|
@@ -77,6 +87,7 @@ import {
|
|
|
77
87
|
networkToolsDisabled,
|
|
78
88
|
projectExecutionHandoffs,
|
|
79
89
|
renderAgentLedger,
|
|
90
|
+
resolveDispatchPathScope,
|
|
80
91
|
resolveToolBudgetEnvelope,
|
|
81
92
|
responseSchemaConflictsWithTools,
|
|
82
93
|
runKindSupportsLiveSteering,
|
|
@@ -84,11 +95,7 @@ import {
|
|
|
84
95
|
serializeWorkerRuntimeDescriptor,
|
|
85
96
|
toolPromptHintsForNames,
|
|
86
97
|
validateJobSpec
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import {
|
|
89
|
-
WRITE_ROOT_REFUSED_TOOLS,
|
|
90
|
-
assessFinishContract
|
|
91
|
-
} from "./chunk-OBMAI2DP.js";
|
|
98
|
+
} from "./chunk-A3WNZD3P.js";
|
|
92
99
|
import {
|
|
93
100
|
decideRoute,
|
|
94
101
|
defaultRoutingIntent,
|
|
@@ -106,7 +113,7 @@ import {
|
|
|
106
113
|
routingIntentRejection,
|
|
107
114
|
sameRouteIdentity,
|
|
108
115
|
toRouteCandidate
|
|
109
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-P43ETTHK.js";
|
|
110
117
|
import {
|
|
111
118
|
appliesRecipeResultContract,
|
|
112
119
|
gateRouteCorrelation,
|
|
@@ -114,15 +121,14 @@ import {
|
|
|
114
121
|
requestExecutionRole,
|
|
115
122
|
routeCorrelationFactsForRun,
|
|
116
123
|
withAttemptRole
|
|
117
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-H7IXIC72.js";
|
|
118
125
|
import {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} from "./chunk-CMZWFGD2.js";
|
|
126
|
+
WRITE_ROOT_REFUSED_TOOLS,
|
|
127
|
+
assessFinishContract
|
|
128
|
+
} from "./chunk-5H3GB5BO.js";
|
|
123
129
|
import {
|
|
124
130
|
compareCodepoints
|
|
125
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-A2NJGIB3.js";
|
|
126
132
|
import {
|
|
127
133
|
isSkillActivation
|
|
128
134
|
} from "./chunk-GOXNB3AO.js";
|
|
@@ -134,9 +140,10 @@ import {
|
|
|
134
140
|
import {
|
|
135
141
|
parseJsonObjectPayload,
|
|
136
142
|
parseVerifierResult,
|
|
143
|
+
pathBoundaryCovers,
|
|
137
144
|
resultContractAuthorship,
|
|
138
145
|
validateRecipeResult
|
|
139
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-TTHACPOM.js";
|
|
140
147
|
import {
|
|
141
148
|
agentSpecFingerprint,
|
|
142
149
|
assertAgentSpecPolicy,
|
|
@@ -160,6 +167,11 @@ import {
|
|
|
160
167
|
import {
|
|
161
168
|
canonicalizeExistingPath
|
|
162
169
|
} from "./chunk-ECH6PKUQ.js";
|
|
170
|
+
import {
|
|
171
|
+
canonicalJson,
|
|
172
|
+
endpointIdentityHash,
|
|
173
|
+
parseAgentLedgerBody
|
|
174
|
+
} from "./chunk-CMZWFGD2.js";
|
|
163
175
|
import {
|
|
164
176
|
truncateUtf8
|
|
165
177
|
} from "./chunk-6XLNIQDB.js";
|
|
@@ -171,44 +183,54 @@ import {
|
|
|
171
183
|
canonicalizeWireModelId,
|
|
172
184
|
firstRuntimeResolutionError,
|
|
173
185
|
isDispatchEligibleRuntime,
|
|
174
|
-
resolveEffectivePricing,
|
|
175
186
|
resolveModelCapabilities,
|
|
176
187
|
resolveRuntimeTarget,
|
|
177
188
|
runtimeResolutionWarnings,
|
|
178
189
|
runtimeTargetSnapshot
|
|
179
|
-
} from "./chunk-
|
|
180
|
-
import {
|
|
181
|
-
targetRequiresAuth
|
|
182
|
-
} from "./chunk-JRIO5UD2.js";
|
|
190
|
+
} from "./chunk-7RFXX52T.js";
|
|
183
191
|
import {
|
|
184
192
|
ceilChars
|
|
185
|
-
} from "./chunk-
|
|
186
|
-
import {
|
|
187
|
-
DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS,
|
|
188
|
-
DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
|
|
189
|
-
DEFAULT_SETTINGS,
|
|
190
|
-
THINKING_LEVELS
|
|
191
|
-
} from "./chunk-4DGYLA73.js";
|
|
192
|
-
import {
|
|
193
|
-
atomicWrite
|
|
194
|
-
} from "./chunk-FO5ZOVUY.js";
|
|
195
|
-
import {
|
|
196
|
-
assertSafeId
|
|
197
|
-
} from "./chunk-R346GLFC.js";
|
|
193
|
+
} from "./chunk-RWSI4YD7.js";
|
|
198
194
|
import {
|
|
199
195
|
attributeCommitMessage,
|
|
200
196
|
gitCommitAttributionEnabled,
|
|
201
197
|
reportCommitAttributionDiagnostic,
|
|
202
198
|
withManagedGitCommitAttributionEnvironment
|
|
203
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-B5CSFE7B.js";
|
|
204
200
|
import {
|
|
205
201
|
MAX_TIMER_DELAY_MS,
|
|
206
202
|
rawDurationMs
|
|
207
203
|
} from "./chunk-FQ4SKYE4.js";
|
|
204
|
+
import {
|
|
205
|
+
BusChannels
|
|
206
|
+
} from "./chunk-TT36MB5S.js";
|
|
207
|
+
import {
|
|
208
|
+
atomicWrite
|
|
209
|
+
} from "./chunk-3BINW3FP.js";
|
|
210
|
+
import {
|
|
211
|
+
assertSafeId
|
|
212
|
+
} from "./chunk-R346GLFC.js";
|
|
213
|
+
import {
|
|
214
|
+
AI_AGENT_NAME
|
|
215
|
+
} from "./chunk-6EJMN2Y3.js";
|
|
216
|
+
import {
|
|
217
|
+
readClioVersion,
|
|
218
|
+
readPiMonoVersion,
|
|
219
|
+
resolvePackageRoot
|
|
220
|
+
} from "./chunk-IWHMRKLL.js";
|
|
221
|
+
import {
|
|
222
|
+
DEFAULT_DELEGATION_CONNECT_TIMEOUT_MS,
|
|
223
|
+
DEFAULT_DELEGATION_TURN_TIMEOUT_MS,
|
|
224
|
+
DEFAULT_SETTINGS,
|
|
225
|
+
THINKING_LEVELS
|
|
226
|
+
} from "./chunk-4DGYLA73.js";
|
|
208
227
|
import {
|
|
209
228
|
GUARDRAIL_DEFAULTS,
|
|
210
229
|
resolveGuardrail
|
|
211
230
|
} from "./chunk-4ZG3XFUR.js";
|
|
231
|
+
import {
|
|
232
|
+
targetRequiresAuth
|
|
233
|
+
} from "./chunk-EQ63NRB7.js";
|
|
212
234
|
import {
|
|
213
235
|
FILE_LOCK_ACQUIRE_TIMEOUT_MS,
|
|
214
236
|
withStateFileLock,
|
|
@@ -225,16 +247,8 @@ import {
|
|
|
225
247
|
stateRootRemoved
|
|
226
248
|
} from "./chunk-BNAZZHFG.js";
|
|
227
249
|
import {
|
|
228
|
-
|
|
229
|
-
} from "./chunk-
|
|
230
|
-
import {
|
|
231
|
-
BusChannels
|
|
232
|
-
} from "./chunk-OB5HIGJY.js";
|
|
233
|
-
import {
|
|
234
|
-
readClioVersion,
|
|
235
|
-
readPiMonoVersion,
|
|
236
|
-
resolvePackageRoot
|
|
237
|
-
} from "./chunk-IWHMRKLL.js";
|
|
250
|
+
resolveEffectivePricing
|
|
251
|
+
} from "./chunk-PT7HYKEM.js";
|
|
238
252
|
import {
|
|
239
253
|
init_esm_shims
|
|
240
254
|
} from "./chunk-3R73A4XB.js";
|
|
@@ -1438,6 +1452,39 @@ function agentLedgerContribution(id, runId) {
|
|
|
1438
1452
|
return { posted: contribution.posted, refused: contribution.refused, digest };
|
|
1439
1453
|
}
|
|
1440
1454
|
|
|
1455
|
+
// src/domains/dispatch/intent-requirements.ts
|
|
1456
|
+
init_esm_shims();
|
|
1457
|
+
function renderDispatchIntentRequirements(intent) {
|
|
1458
|
+
if (intent === void 0 || intent.expectedOutputs.length === 0 && intent.verification.length === 0) return null;
|
|
1459
|
+
const lines = [
|
|
1460
|
+
"# Declared Result Requirements",
|
|
1461
|
+
"These entries are requirements to satisfy and verify. They are not evidence that an output exists or a check passed."
|
|
1462
|
+
];
|
|
1463
|
+
if (intent.expectedOutputs.length > 0) {
|
|
1464
|
+
lines.push("", "Expected outputs:", ...intent.expectedOutputs.map((output) => `- ${output}`));
|
|
1465
|
+
}
|
|
1466
|
+
if (intent.verification.length > 0) {
|
|
1467
|
+
lines.push(
|
|
1468
|
+
"",
|
|
1469
|
+
"Verification requirements:",
|
|
1470
|
+
...intent.verification.map(
|
|
1471
|
+
(entry) => `- ${entry.check} must pass within its declared timeout of ${entry.timeoutMs}ms`
|
|
1472
|
+
)
|
|
1473
|
+
);
|
|
1474
|
+
}
|
|
1475
|
+
return lines.join("\n");
|
|
1476
|
+
}
|
|
1477
|
+
function renderDispatchReviewerTask(originalTask, builderRunId, cycle, intent) {
|
|
1478
|
+
const requirements = renderDispatchIntentRequirements(intent);
|
|
1479
|
+
return [
|
|
1480
|
+
`Review the work of builder run ${builderRunId} (review cycle ${cycle}).`,
|
|
1481
|
+
"The builder's final answer is provided as input data; verify it against the workspace, do not trust it blindly.",
|
|
1482
|
+
"Original task the builder was given:",
|
|
1483
|
+
originalTask,
|
|
1484
|
+
...requirements === null ? [] : [requirements]
|
|
1485
|
+
].join("\n\n");
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1441
1488
|
// src/domains/dispatch/receipt-findings.ts
|
|
1442
1489
|
init_esm_shims();
|
|
1443
1490
|
import { createHash as createHash12 } from "node:crypto";
|
|
@@ -3906,6 +3953,12 @@ async function reconcileOrphanAssignments(deps) {
|
|
|
3906
3953
|
const summary = { recovered: 0, abandoned: 0 };
|
|
3907
3954
|
for (const record of deps.listRunning()) {
|
|
3908
3955
|
if (record.status !== "running") continue;
|
|
3956
|
+
if (deps.ownerAlive(record)) continue;
|
|
3957
|
+
if (record.verdictOwner !== void 0) {
|
|
3958
|
+
await deps.settle(record.assignmentId, record.assignmentId, "failed", record.verdictOwner);
|
|
3959
|
+
summary.abandoned += 1;
|
|
3960
|
+
continue;
|
|
3961
|
+
}
|
|
3909
3962
|
const views = record.attempts.map((runId) => deps.lookupAttempt(runId)).filter((view) => view !== null);
|
|
3910
3963
|
const succeeded = views.find((view) => view.succeeded);
|
|
3911
3964
|
if (succeeded) {
|
|
@@ -3934,10 +3987,15 @@ var MAX_ASSIGNMENT_RECORDS = 1e3;
|
|
|
3934
3987
|
function storePath2() {
|
|
3935
3988
|
return join4(clioStateDir(), "assignments.json");
|
|
3936
3989
|
}
|
|
3990
|
+
function validProcessOwner(value) {
|
|
3991
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
3992
|
+
const owner = value;
|
|
3993
|
+
return Number.isSafeInteger(owner.pid) && (owner.pid ?? 0) > 0 && typeof owner.processBirthToken === "string" && typeof owner.acquiredAt === "string" && Number.isFinite(Date.parse(owner.acquiredAt));
|
|
3994
|
+
}
|
|
3937
3995
|
function validRecord2(value) {
|
|
3938
3996
|
if (typeof value !== "object" || value === null) return false;
|
|
3939
3997
|
const record = value;
|
|
3940
|
-
return typeof record.assignmentId === "string" && Array.isArray(record.attempts) && record.attempts.every((runId) => typeof runId === "string") && (record.terminalRunId === null || typeof record.terminalRunId === "string") && (record.status === "running" || record.status === "succeeded" || record.status === "failed" || record.status === "canceled" || record.status === "timed_out");
|
|
3998
|
+
return typeof record.assignmentId === "string" && Array.isArray(record.attempts) && record.attempts.every((runId) => typeof runId === "string") && (record.terminalRunId === null || typeof record.terminalRunId === "string") && (record.verdictOwner === void 0 || record.verdictOwner === "fleet") && (record.processOwner === void 0 || validProcessOwner(record.processOwner)) && (record.status === "running" || record.status === "succeeded" || record.status === "failed" || record.status === "canceled" || record.status === "timed_out");
|
|
3941
3999
|
}
|
|
3942
4000
|
function readStore3() {
|
|
3943
4001
|
const path2 = storePath2();
|
|
@@ -3951,7 +4009,24 @@ function readStore3() {
|
|
|
3951
4009
|
}
|
|
3952
4010
|
}
|
|
3953
4011
|
function copyRecord2(record) {
|
|
3954
|
-
return {
|
|
4012
|
+
return {
|
|
4013
|
+
...record,
|
|
4014
|
+
attempts: [...record.attempts],
|
|
4015
|
+
...record.processOwner === void 0 ? {} : { processOwner: { ...record.processOwner } }
|
|
4016
|
+
};
|
|
4017
|
+
}
|
|
4018
|
+
var defaultProcessOwnerProbe = {
|
|
4019
|
+
birthToken: processBirthToken,
|
|
4020
|
+
tokenProvesDeath: BIRTH_TOKEN_SOURCE_AVAILABLE,
|
|
4021
|
+
alive: processAlive
|
|
4022
|
+
};
|
|
4023
|
+
function assignmentProcessOwnerAlive(record, probe = defaultProcessOwnerProbe) {
|
|
4024
|
+
const owner = record.processOwner;
|
|
4025
|
+
if (owner === void 0) return false;
|
|
4026
|
+
const current = probe.birthToken(owner.pid);
|
|
4027
|
+
if (current === null || current !== owner.processBirthToken) return false;
|
|
4028
|
+
if (probe.tokenProvesDeath === false) return probe.alive?.(owner.pid) ?? false;
|
|
4029
|
+
return true;
|
|
3955
4030
|
}
|
|
3956
4031
|
function writeStore3(assignments) {
|
|
3957
4032
|
const file = {
|
|
@@ -3996,41 +4071,75 @@ async function renameStoredAssignment(fromAssignmentId, toAssignmentId) {
|
|
|
3996
4071
|
});
|
|
3997
4072
|
return copyRecord2(result);
|
|
3998
4073
|
}
|
|
3999
|
-
function
|
|
4000
|
-
|
|
4074
|
+
function currentProcessOwner() {
|
|
4075
|
+
const token = processBirthToken();
|
|
4076
|
+
if (token === null) throw new Error("dispatch: cannot establish assignment owner process birth token");
|
|
4077
|
+
return {
|
|
4078
|
+
pid: process.pid,
|
|
4079
|
+
processBirthToken: token,
|
|
4080
|
+
acquiredAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
function openRecord(assignmentId) {
|
|
4084
|
+
return {
|
|
4001
4085
|
assignmentId,
|
|
4002
|
-
|
|
4003
|
-
|
|
4086
|
+
attempts: [],
|
|
4087
|
+
terminalRunId: null,
|
|
4088
|
+
status: "running",
|
|
4089
|
+
processOwner: currentProcessOwner()
|
|
4090
|
+
};
|
|
4091
|
+
}
|
|
4092
|
+
function ensureRunningProcessOwner(record) {
|
|
4093
|
+
if (record.status !== "running" || record.processOwner !== void 0) return record;
|
|
4094
|
+
return { ...record, processOwner: currentProcessOwner() };
|
|
4095
|
+
}
|
|
4096
|
+
function clearProcessOwner(record) {
|
|
4097
|
+
const result = { ...record };
|
|
4098
|
+
delete result.processOwner;
|
|
4099
|
+
return result;
|
|
4100
|
+
}
|
|
4101
|
+
function registerAssignment(assignmentId) {
|
|
4102
|
+
return updateRecord(assignmentId, (current) => ensureRunningProcessOwner(current ?? openRecord(assignmentId)));
|
|
4103
|
+
}
|
|
4104
|
+
function claimAssignmentVerdict(assignmentId, owner) {
|
|
4105
|
+
return updateRecord(assignmentId, (current) => ({
|
|
4106
|
+
...ensureRunningProcessOwner(current ?? openRecord(assignmentId)),
|
|
4107
|
+
verdictOwner: owner
|
|
4108
|
+
}));
|
|
4004
4109
|
}
|
|
4005
4110
|
function recordAssignmentAttempt(assignmentId, runId) {
|
|
4006
4111
|
return updateRecord(assignmentId, (current) => {
|
|
4007
|
-
const base = current ??
|
|
4112
|
+
const base = ensureRunningProcessOwner(current ?? openRecord(assignmentId));
|
|
4008
4113
|
return base.attempts.includes(runId) ? base : { ...base, attempts: [...base.attempts, runId] };
|
|
4009
4114
|
});
|
|
4010
4115
|
}
|
|
4011
4116
|
function failQueuedAssignment(assignmentId) {
|
|
4012
4117
|
return updateRecord(assignmentId, (current) => {
|
|
4013
|
-
const base = current ??
|
|
4014
|
-
|
|
4118
|
+
const base = current ?? openRecord(assignmentId);
|
|
4119
|
+
if (base.verdictOwner !== void 0) return base;
|
|
4120
|
+
return base.status === "running" ? clearProcessOwner({ ...base, status: "failed" }) : base;
|
|
4015
4121
|
});
|
|
4016
4122
|
}
|
|
4017
4123
|
function timeoutStoredAssignment(assignmentId) {
|
|
4018
4124
|
return updateRecord(assignmentId, (current) => {
|
|
4019
|
-
const base = current ??
|
|
4020
|
-
|
|
4125
|
+
const base = current ?? openRecord(assignmentId);
|
|
4126
|
+
if (base.verdictOwner !== void 0) return base;
|
|
4127
|
+
return base.status === "running" ? clearProcessOwner({ ...base, status: "timed_out" }) : base;
|
|
4021
4128
|
});
|
|
4022
4129
|
}
|
|
4023
4130
|
function cancelStoredAssignment(assignmentId) {
|
|
4024
4131
|
return updateRecord(assignmentId, (current) => {
|
|
4025
|
-
const base = current ??
|
|
4026
|
-
|
|
4132
|
+
const base = current ?? openRecord(assignmentId);
|
|
4133
|
+
if (base.verdictOwner !== void 0) return base;
|
|
4134
|
+
return base.status === "running" ? clearProcessOwner({ ...base, status: "canceled" }) : base;
|
|
4027
4135
|
});
|
|
4028
4136
|
}
|
|
4029
|
-
function settleStoredAssignment(assignmentId, terminalRunId, status) {
|
|
4137
|
+
function settleStoredAssignment(assignmentId, terminalRunId, status, owner) {
|
|
4030
4138
|
return updateRecord(assignmentId, (current) => {
|
|
4031
|
-
const base = current ??
|
|
4139
|
+
const base = current ?? openRecord(assignmentId);
|
|
4032
4140
|
const attempts = base.attempts.includes(terminalRunId) ? base.attempts : [...base.attempts, terminalRunId];
|
|
4033
|
-
return { ...base, attempts
|
|
4141
|
+
if (base.verdictOwner !== owner) return { ...base, attempts };
|
|
4142
|
+
return clearProcessOwner({ ...base, attempts, terminalRunId, status });
|
|
4034
4143
|
});
|
|
4035
4144
|
}
|
|
4036
4145
|
|
|
@@ -7304,6 +7413,7 @@ function recordWorkerRunEffect(recorder, event) {
|
|
|
7304
7413
|
if (event.type === "tool_execution_end") recorder.finish(toolCallId, event.isError === true);
|
|
7305
7414
|
}
|
|
7306
7415
|
var DISPATCH_DRAIN_GRACE_MS = 2e3;
|
|
7416
|
+
var RUN_WRITE_TARGET_HISTORY = 512;
|
|
7307
7417
|
async function awaitEventDrain(drained, graceMs = DISPATCH_DRAIN_GRACE_MS) {
|
|
7308
7418
|
let timer;
|
|
7309
7419
|
const grace = new Promise((resolve5) => {
|
|
@@ -7391,9 +7501,10 @@ function mergeRouteWarningDetail(routeWarning, base) {
|
|
|
7391
7501
|
function pickOrchestratorScope(safety) {
|
|
7392
7502
|
return safety.scopes.workspace;
|
|
7393
7503
|
}
|
|
7394
|
-
function pickWorkerScope(safety, requestedActions) {
|
|
7504
|
+
function pickWorkerScope(safety, requestedActions, pathScope) {
|
|
7395
7505
|
if (requestedActions.every((action) => action === "read")) return safety.scopes.readonly;
|
|
7396
|
-
return safety.scopes.workspace;
|
|
7506
|
+
if (pathScope.writeBoundaries.length === 0) return safety.scopes.workspace;
|
|
7507
|
+
return { ...safety.scopes.workspace, allowedWriteRoots: pathScope.writeBoundaries };
|
|
7397
7508
|
}
|
|
7398
7509
|
function deriveRequestedActions(tools, safety) {
|
|
7399
7510
|
const actions = /* @__PURE__ */ new Set();
|
|
@@ -7520,6 +7631,10 @@ function projectContextProvenanceFor(tier, messages) {
|
|
|
7520
7631
|
function hasPersonaOverride(req) {
|
|
7521
7632
|
return typeof req.systemPrompt === "string" && req.systemPrompt.trim().length > 0;
|
|
7522
7633
|
}
|
|
7634
|
+
function hasCallerPersonaOverride(req) {
|
|
7635
|
+
if (!hasPersonaOverride(req)) return false;
|
|
7636
|
+
return !isBoundedGateRolePrompt({ role: req.gate?.role, autonomy: req.autonomy, systemPrompt: req.systemPrompt });
|
|
7637
|
+
}
|
|
7523
7638
|
function personaOverrideFor(req, staticCompositionHash) {
|
|
7524
7639
|
if (!hasPersonaOverride(req) || staticCompositionHash === null) return null;
|
|
7525
7640
|
return { promptHash: staticCompositionHash };
|
|
@@ -7556,19 +7671,6 @@ function renderWorkerProjectContext(project, options = {}) {
|
|
|
7556
7671
|
function workerProjectContextIncludesVerification(body) {
|
|
7557
7672
|
return body.includes("\nVerification expectations:\n");
|
|
7558
7673
|
}
|
|
7559
|
-
var PATH_TOKEN_RE = /(?:[\w.-]+\/)+[\w.-]+|\b[\w-]+\.[A-Za-z0-9]{1,8}\b/g;
|
|
7560
|
-
function workerWorkingContextPaths(req) {
|
|
7561
|
-
const out = /* @__PURE__ */ new Set();
|
|
7562
|
-
for (const root of req.writeRoots ?? []) out.add(root);
|
|
7563
|
-
const text = `${req.task}
|
|
7564
|
-
${req.briefing ?? ""}`;
|
|
7565
|
-
for (const match of text.matchAll(PATH_TOKEN_RE)) {
|
|
7566
|
-
const token = match[0];
|
|
7567
|
-
if (token.startsWith("http://") || token.startsWith("https://")) continue;
|
|
7568
|
-
out.add(token);
|
|
7569
|
-
}
|
|
7570
|
-
return [...out];
|
|
7571
|
-
}
|
|
7572
7674
|
function buildDynamicPromptMessages(req, dynamicContext = {}) {
|
|
7573
7675
|
const messages = [];
|
|
7574
7676
|
if (dynamicContext.workspace) {
|
|
@@ -7589,6 +7691,10 @@ function buildDynamicPromptMessages(req, dynamicContext = {}) {
|
|
|
7589
7691
|
const body = `Safety posture: autonomy ${autonomy}. ${workerSafetyOneLiner(autonomy, permission)} Worker permission routing: ${permission}.`;
|
|
7590
7692
|
messages.push({ id: "dispatch-safety-posture", body, contentHash: sha2565(body) });
|
|
7591
7693
|
}
|
|
7694
|
+
const requirements = renderDispatchIntentRequirements(req.intent);
|
|
7695
|
+
if (requirements !== null) {
|
|
7696
|
+
messages.push({ id: "dispatch-intent-requirements", body: requirements, contentHash: sha2565(requirements) });
|
|
7697
|
+
}
|
|
7592
7698
|
if (req.competeStance !== void 0) {
|
|
7593
7699
|
const body = competeStanceLiner(req.competeStance);
|
|
7594
7700
|
messages.push({ id: "dispatch-compete-stance", body, contentHash: sha2565(body) });
|
|
@@ -7719,9 +7825,6 @@ function explicitToolCapability(providers, target, wireModelId) {
|
|
|
7719
7825
|
const fromKnowledgeBase = hit?.entry.capabilities?.tools;
|
|
7720
7826
|
return typeof fromKnowledgeBase === "boolean" ? fromKnowledgeBase : null;
|
|
7721
7827
|
}
|
|
7722
|
-
function writeConfinedRequest(req) {
|
|
7723
|
-
return req.writeRoots !== void 0 && req.writeRoots.length > 0;
|
|
7724
|
-
}
|
|
7725
7828
|
function effectiveToolNames(allowedTools, target, writeConfined = false, denied = /* @__PURE__ */ new Set()) {
|
|
7726
7829
|
if (!targetToolCapability(target)) return [];
|
|
7727
7830
|
const networkStripped = networkToolsDisabled();
|
|
@@ -7866,7 +7969,7 @@ function readWorkerTargets(settings) {
|
|
|
7866
7969
|
const targetOrder = settings?.targets?.map((target) => target.id) ?? [];
|
|
7867
7970
|
return { workerDefault, workerProfiles, agentBindings, targetOrder };
|
|
7868
7971
|
}
|
|
7869
|
-
function resolveDispatchAdmissionStage(req, recipe, safety) {
|
|
7972
|
+
function resolveDispatchAdmissionStage(req, recipe, safety, pathScope) {
|
|
7870
7973
|
const recipeTools = recipe.tools;
|
|
7871
7974
|
const candidateTools = recipeTools && recipeTools.length > 0 ? Array.from(recipeTools) : [];
|
|
7872
7975
|
const allowedTools = applyToolProfile(candidateTools, req.toolProfile, { agentId: req.agentId, task: req.task });
|
|
@@ -7879,7 +7982,7 @@ function resolveDispatchAdmissionStage(req, recipe, safety) {
|
|
|
7879
7982
|
}
|
|
7880
7983
|
const requestedActions = deriveRequestedActions(allowedTools, safety);
|
|
7881
7984
|
const orchScope = pickOrchestratorScope(safety);
|
|
7882
|
-
const workerScope = pickWorkerScope(safety, requestedActions);
|
|
7985
|
+
const workerScope = pickWorkerScope(safety, requestedActions, pathScope);
|
|
7883
7986
|
const verdict = admit(
|
|
7884
7987
|
{
|
|
7885
7988
|
requestedScope: workerScope,
|
|
@@ -7903,7 +8006,7 @@ function resolveDelegationAdmissionStage(req, safety) {
|
|
|
7903
8006
|
const allowedTools = applyToolProfile([], req.toolProfile);
|
|
7904
8007
|
const requestedActions = deriveRequestedActions(allowedTools, safety);
|
|
7905
8008
|
const orchScope = pickOrchestratorScope(safety);
|
|
7906
|
-
const workerScope = pickWorkerScope(safety, requestedActions);
|
|
8009
|
+
const workerScope = pickWorkerScope(safety, requestedActions, resolveDispatchPathScope(req));
|
|
7907
8010
|
const verdict = admit(
|
|
7908
8011
|
{
|
|
7909
8012
|
requestedScope: workerScope,
|
|
@@ -7970,9 +8073,8 @@ function buildDispatchWorkerSpec(input, config) {
|
|
|
7970
8073
|
};
|
|
7971
8074
|
}
|
|
7972
8075
|
if (input.req.responseSchema !== void 0) spec.responseSchema = input.req.responseSchema;
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
}
|
|
8076
|
+
const workerResultContract = appliesRecipeResultContract(input.req.gate?.role) ? input.req.resultContractOverride ?? input.recipe?.resultContract : void 0;
|
|
8077
|
+
if (workerResultContract) spec.resultContract = workerResultContract;
|
|
7976
8078
|
const product = input.req.product ?? input.recipe?.product;
|
|
7977
8079
|
if (product) spec.product = product;
|
|
7978
8080
|
const resolutionSnapshot = runtimeTargetSnapshot(input.target.runtimeResolution);
|
|
@@ -8005,10 +8107,7 @@ function buildDispatchWorkerSpec(input, config) {
|
|
|
8005
8107
|
if (escalation) spec.escalation = { timeoutMs: escalation.timeoutMs, fallback: escalation.fallback };
|
|
8006
8108
|
}
|
|
8007
8109
|
assertRuntimeCanHonorWorkerPermissionMode(input.target.runtime, spec.onPermission);
|
|
8008
|
-
if (input.
|
|
8009
|
-
const jobCwd = input.req.cwd !== void 0 && input.req.cwd.length > 0 ? input.req.cwd : process.cwd();
|
|
8010
|
-
spec.writeRoots = input.req.writeRoots.map((root) => resolvePath(jobCwd, root));
|
|
8011
|
-
}
|
|
8110
|
+
if (input.pathScope.writeBoundaries.length > 0) spec.writeRoots = [...input.pathScope.writeBoundaries];
|
|
8012
8111
|
assertWriteRootsEnforceable(input.target.runtime, spec.writeRoots);
|
|
8013
8112
|
if (input.admission.toolProfile !== void 0) spec.toolProfile = input.admission.toolProfile;
|
|
8014
8113
|
spec.autonomy = input.effectiveAutonomy;
|
|
@@ -8403,6 +8502,15 @@ function createDispatchBundle(context, options) {
|
|
|
8403
8502
|
const active = /* @__PURE__ */ new Map();
|
|
8404
8503
|
const targetCooldowns = /* @__PURE__ */ new Map();
|
|
8405
8504
|
const ownedReservations = /* @__PURE__ */ new Set();
|
|
8505
|
+
const runWriteTargets = /* @__PURE__ */ new Map();
|
|
8506
|
+
const recordRunWriteTargets = (runId, paths) => {
|
|
8507
|
+
runWriteTargets.set(runId, paths);
|
|
8508
|
+
while (runWriteTargets.size > RUN_WRITE_TARGET_HISTORY) {
|
|
8509
|
+
const oldest = runWriteTargets.keys().next();
|
|
8510
|
+
if (oldest.done === true) break;
|
|
8511
|
+
runWriteTargets.delete(oldest.value);
|
|
8512
|
+
}
|
|
8513
|
+
};
|
|
8406
8514
|
const capacityAdmission = createCapacityAdmissionController({
|
|
8407
8515
|
limits: () => {
|
|
8408
8516
|
const settings = getEffectiveSettings();
|
|
@@ -9005,6 +9113,19 @@ function createDispatchBundle(context, options) {
|
|
|
9005
9113
|
if (cooldownMs <= 0) return;
|
|
9006
9114
|
targetCooldowns.set(key, { until: now() + cooldownMs, reason: failureClass });
|
|
9007
9115
|
}
|
|
9116
|
+
function publishDispatchPathScope(req, pathScope) {
|
|
9117
|
+
const replacementDiagnostic = declaredScopeReplacementDiagnostic(pathScope);
|
|
9118
|
+
if (replacementDiagnostic !== null) {
|
|
9119
|
+
reportDispatchDiagnostic("typed scope replacement", new Error(replacementDiagnostic));
|
|
9120
|
+
}
|
|
9121
|
+
const notice = declaredScopeReplacementNotice(pathScope);
|
|
9122
|
+
if (notice !== null) {
|
|
9123
|
+
context.bus.emit(BusChannels.DispatchScopeNotice, {
|
|
9124
|
+
...notice,
|
|
9125
|
+
agentId: req.agentId
|
|
9126
|
+
});
|
|
9127
|
+
}
|
|
9128
|
+
}
|
|
9008
9129
|
async function resolveLifecycle(req, settings) {
|
|
9009
9130
|
const recipe = agents.get(req.agentId);
|
|
9010
9131
|
if (!recipe) {
|
|
@@ -9016,7 +9137,7 @@ function createDispatchBundle(context, options) {
|
|
|
9016
9137
|
`dispatch: agent '${req.agentId}' is a ${spec.audience} agent reserved for Clio internal orchestration`
|
|
9017
9138
|
);
|
|
9018
9139
|
}
|
|
9019
|
-
if (
|
|
9140
|
+
if (hasCallerPersonaOverride(req) && (spec.audience === "shadow" || spec.audience === "internal")) {
|
|
9020
9141
|
throw new Error(`dispatch: persona overrides are not allowed for ${spec.audience} agent '${req.agentId}'`);
|
|
9021
9142
|
}
|
|
9022
9143
|
const capabilityMismatch = req.gate !== void 0 ? null : assessCapabilityMismatch({
|
|
@@ -9028,7 +9149,9 @@ function createDispatchBundle(context, options) {
|
|
|
9028
9149
|
specs: agents.listSpecs()
|
|
9029
9150
|
});
|
|
9030
9151
|
if (capabilityMismatch?.verdict === "refuse") throw new Error(capabilityMismatch.detail);
|
|
9031
|
-
const
|
|
9152
|
+
const pathScope = resolveDispatchPathScope(req);
|
|
9153
|
+
publishDispatchPathScope(req, pathScope);
|
|
9154
|
+
const admission = resolveDispatchAdmissionStage(req, recipe, safety, pathScope);
|
|
9032
9155
|
const targets = readWorkerTargets(settings);
|
|
9033
9156
|
const target = resolveDispatchTarget(
|
|
9034
9157
|
req,
|
|
@@ -9046,7 +9169,7 @@ function createDispatchBundle(context, options) {
|
|
|
9046
9169
|
const sessionAutonomy = settings?.autonomy ?? "auto-edit";
|
|
9047
9170
|
const effectiveAutonomy = clampWorkerAutonomy(sessionAutonomy, req.autonomy);
|
|
9048
9171
|
const effectiveTools = withLedgerToolNarrowing(
|
|
9049
|
-
effectiveToolNames(admission.allowedTools, target,
|
|
9172
|
+
effectiveToolNames(admission.allowedTools, target, pathScope.writeBoundaries.length > 0, deniedToolNames(req)),
|
|
9050
9173
|
req
|
|
9051
9174
|
);
|
|
9052
9175
|
assertPostRuntimeToolCompatibility(req.agentId, spec, effectiveTools, target);
|
|
@@ -9071,7 +9194,7 @@ function createDispatchBundle(context, options) {
|
|
|
9071
9194
|
dynamic: false
|
|
9072
9195
|
},
|
|
9073
9196
|
cwd,
|
|
9074
|
-
workingContextPaths:
|
|
9197
|
+
workingContextPaths: pathScope.workingContextPaths
|
|
9075
9198
|
});
|
|
9076
9199
|
const systemPrompt = compiledWorkerPrompt.systemPrompt;
|
|
9077
9200
|
const budgetEnvelope = resolveEffectiveWorkerBudget({
|
|
@@ -9105,6 +9228,7 @@ function createDispatchBundle(context, options) {
|
|
|
9105
9228
|
const limitations = runtimeLimitations(runtimeKind, target.runtime.id);
|
|
9106
9229
|
return {
|
|
9107
9230
|
recipe,
|
|
9231
|
+
pathScope,
|
|
9108
9232
|
admission: effectiveAdmission,
|
|
9109
9233
|
target,
|
|
9110
9234
|
cwd,
|
|
@@ -9138,12 +9262,7 @@ function createDispatchBundle(context, options) {
|
|
|
9138
9262
|
function resolveAcpDelegationLifecycle(req, settings) {
|
|
9139
9263
|
const agentId = req.delegationAgentId;
|
|
9140
9264
|
if (!agentId) throw new Error("dispatch: missing delegationAgentId");
|
|
9141
|
-
|
|
9142
|
-
role: req.gate?.role,
|
|
9143
|
-
autonomy: req.autonomy,
|
|
9144
|
-
systemPrompt: req.systemPrompt
|
|
9145
|
-
});
|
|
9146
|
-
if (hasPersonaOverride(req) && !boundedGateRolePrompt) {
|
|
9265
|
+
if (hasCallerPersonaOverride(req)) {
|
|
9147
9266
|
throw new Error(`dispatch: persona overrides are not allowed for ACP delegation agent '${agentId}'`);
|
|
9148
9267
|
}
|
|
9149
9268
|
if (req.agentId && maybeAgents) {
|
|
@@ -9172,6 +9291,7 @@ function createDispatchBundle(context, options) {
|
|
|
9172
9291
|
);
|
|
9173
9292
|
}
|
|
9174
9293
|
const cwd = req.cwd ?? process.cwd();
|
|
9294
|
+
const pathScope = resolveDispatchPathScope(req);
|
|
9175
9295
|
const personaBody = workerPersonaBody(req, null, []);
|
|
9176
9296
|
const systemPrompt = personaBody;
|
|
9177
9297
|
const tier = configured.projectContext ?? "none";
|
|
@@ -9191,6 +9311,7 @@ function createDispatchBundle(context, options) {
|
|
|
9191
9311
|
const personaOverride = personaOverrideFor(req, staticCompositionHash);
|
|
9192
9312
|
return {
|
|
9193
9313
|
admission,
|
|
9314
|
+
pathScope,
|
|
9194
9315
|
agentConfig: configured,
|
|
9195
9316
|
cwd,
|
|
9196
9317
|
systemPrompt,
|
|
@@ -9215,6 +9336,7 @@ function createDispatchBundle(context, options) {
|
|
|
9215
9336
|
}
|
|
9216
9337
|
async function dispatchAcpDelegation(req, settings, timing, routeDecision, observer) {
|
|
9217
9338
|
const lifecycle = resolveAcpDelegationLifecycle(req, settings);
|
|
9339
|
+
publishDispatchPathScope(req, lifecycle.pathScope);
|
|
9218
9340
|
timing.decisionCompletedAt = new Date(now()).toISOString();
|
|
9219
9341
|
const targetId = `delegation:${lifecycle.agentConfig.id}`;
|
|
9220
9342
|
const runtimeId = "acp";
|
|
@@ -9526,6 +9648,7 @@ function createDispatchBundle(context, options) {
|
|
|
9526
9648
|
requestOrigin: lifecycle.requestOrigin,
|
|
9527
9649
|
task: req.task,
|
|
9528
9650
|
...req.intent !== void 0 ? { intent: structuredClone(req.intent) } : {},
|
|
9651
|
+
pathScope: structuredClone(lifecycle.pathScope.provenance),
|
|
9529
9652
|
targetId,
|
|
9530
9653
|
wireModelId,
|
|
9531
9654
|
runtimeId,
|
|
@@ -9961,6 +10084,7 @@ function createDispatchBundle(context, options) {
|
|
|
9961
10084
|
const spec = buildDispatchWorkerSpec(
|
|
9962
10085
|
{
|
|
9963
10086
|
req,
|
|
10087
|
+
pathScope: lifecycle.pathScope,
|
|
9964
10088
|
target: lifecycle.target,
|
|
9965
10089
|
admission: lifecycle.admission,
|
|
9966
10090
|
recipe: lifecycle.recipe,
|
|
@@ -10435,6 +10559,7 @@ function createDispatchBundle(context, options) {
|
|
|
10435
10559
|
outcomeCode,
|
|
10436
10560
|
lineage,
|
|
10437
10561
|
...req.intent !== void 0 ? { intent: structuredClone(req.intent) } : {},
|
|
10562
|
+
pathScope: structuredClone(lifecycle.pathScope.provenance),
|
|
10438
10563
|
identity,
|
|
10439
10564
|
node: placement?.node ?? LOCAL_RUN_NODE,
|
|
10440
10565
|
...receiptAttestationFields(worker.attestation?.() ?? null),
|
|
@@ -10769,6 +10894,8 @@ function createDispatchBundle(context, options) {
|
|
|
10769
10894
|
}
|
|
10770
10895
|
ledgerRef.update(envelope.id, ledgerPatch);
|
|
10771
10896
|
const receipt = ledgerRef.recordReceipt(envelope.id, sealRouteDecision(receiptDraft, routeObservation.decision));
|
|
10897
|
+
const writeRecordUsable = receipt.safety?.toolTelemetry?.coverage === "complete" && observedRunEffects.writeRecordComplete;
|
|
10898
|
+
recordRunWriteTargets(envelope.id, writeRecordUsable ? [...observedRunEffects.mutatedPaths] : null);
|
|
10772
10899
|
await ledgerRef.persist();
|
|
10773
10900
|
if (worktreeReceipt?.applied === true && req.taskWorktree !== void 0) {
|
|
10774
10901
|
try {
|
|
@@ -10972,10 +11099,11 @@ function createDispatchBundle(context, options) {
|
|
|
10972
11099
|
`dispatch: agent '${req.agentId}' is a ${agentSpec.audience} agent reserved for Clio internal orchestration`
|
|
10973
11100
|
);
|
|
10974
11101
|
}
|
|
10975
|
-
if (
|
|
11102
|
+
if (hasCallerPersonaOverride(req) && (agentSpec.audience === "shadow" || agentSpec.audience === "internal")) {
|
|
10976
11103
|
throw new Error(`dispatch: persona overrides are not allowed for ${agentSpec.audience} agent '${req.agentId}'`);
|
|
10977
11104
|
}
|
|
10978
|
-
const
|
|
11105
|
+
const pathScope = resolveDispatchPathScope(req);
|
|
11106
|
+
const admission = resolveDispatchAdmissionStage(req, recipe, safety, pathScope);
|
|
10979
11107
|
const targets = readWorkerTargets(settings);
|
|
10980
11108
|
const target = resolveDispatchTarget(
|
|
10981
11109
|
req,
|
|
@@ -10988,14 +11116,14 @@ function createDispatchBundle(context, options) {
|
|
|
10988
11116
|
);
|
|
10989
11117
|
enforceCapabilityGate(target.target.id, target.modelCapabilities, req.requiredCapabilities);
|
|
10990
11118
|
const effectiveTools = withLedgerToolNarrowing(
|
|
10991
|
-
effectiveToolNames(admission.allowedTools, target,
|
|
11119
|
+
effectiveToolNames(admission.allowedTools, target, pathScope.writeBoundaries.length > 0, deniedToolNames(req)),
|
|
10992
11120
|
req
|
|
10993
11121
|
);
|
|
10994
11122
|
assertPostRuntimeToolCompatibility(req.agentId, agentSpec, effectiveTools, target);
|
|
10995
11123
|
assertRuntimeCanHonorWorkerPermissionMode(target.runtime, settings?.workers.onPermission ?? "deny");
|
|
10996
11124
|
assertWorkerBudgetEnforceable(target.runtime, agentSpec.budget !== null || req.budget !== void 0);
|
|
10997
11125
|
assertResponseSchemaEnforceable(target.runtime, target.modelCapabilities, req.responseSchema, effectiveTools.length);
|
|
10998
|
-
assertWriteRootsEnforceable(target.runtime,
|
|
11126
|
+
assertWriteRootsEnforceable(target.runtime, pathScope.writeBoundaries);
|
|
10999
11127
|
assertProtectedArtifactsEnforceable(
|
|
11000
11128
|
target.runtime.id,
|
|
11001
11129
|
target.runtime.kind !== "subprocess",
|
|
@@ -11376,6 +11504,7 @@ function createDispatchBundle(context, options) {
|
|
|
11376
11504
|
const reconciledLedger = ledger;
|
|
11377
11505
|
const reconciled = await reconcileOrphanAssignments({
|
|
11378
11506
|
listRunning: () => listStoredAssignments().filter((record) => record.status === "running"),
|
|
11507
|
+
ownerAlive: assignmentProcessOwnerAlive,
|
|
11379
11508
|
lookupAttempt: (runId) => {
|
|
11380
11509
|
const envelope = reconciledLedger?.get(runId) ?? null;
|
|
11381
11510
|
if (!envelope) return null;
|
|
@@ -11385,7 +11514,7 @@ function createDispatchBundle(context, options) {
|
|
|
11385
11514
|
succeeded: envelope.outcome === "succeeded"
|
|
11386
11515
|
};
|
|
11387
11516
|
},
|
|
11388
|
-
settle: (assignmentId, terminalRunId, status) => settleStoredAssignment(assignmentId, terminalRunId, status)
|
|
11517
|
+
settle: (assignmentId, terminalRunId, status, owner) => settleStoredAssignment(assignmentId, terminalRunId, status, owner)
|
|
11389
11518
|
});
|
|
11390
11519
|
if ((reconciled.recovered > 0 || reconciled.abandoned > 0) && process.env.CLIO_CODER_INTERACTIVE !== "1") {
|
|
11391
11520
|
process.stderr.write(
|
|
@@ -11566,6 +11695,9 @@ function createDispatchBundle(context, options) {
|
|
|
11566
11695
|
if (!ledger) return null;
|
|
11567
11696
|
return ledger.get(runId);
|
|
11568
11697
|
},
|
|
11698
|
+
observedRunWrites(runId) {
|
|
11699
|
+
return runWriteTargets.get(runId) ?? null;
|
|
11700
|
+
},
|
|
11569
11701
|
assignments: {
|
|
11570
11702
|
get: (id) => assignments.get(id),
|
|
11571
11703
|
getStored: (id) => getStoredAssignment(id),
|
|
@@ -11708,9 +11840,6 @@ ${proposal.output}`).join("\n\n");
|
|
|
11708
11840
|
return `${source.subarray(0, end).toString("utf8")}${suffix}`;
|
|
11709
11841
|
}
|
|
11710
11842
|
var ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u;
|
|
11711
|
-
function insideBoundary(path2, boundary) {
|
|
11712
|
-
return boundary.some((root) => root.endsWith("/") ? path2.startsWith(root) : path2 === root);
|
|
11713
|
-
}
|
|
11714
11843
|
function malformed(detail) {
|
|
11715
11844
|
return { ok: false, reason: "delegation_plan_malformed", detail };
|
|
11716
11845
|
}
|
|
@@ -11755,7 +11884,7 @@ function validateDelegationPlan(input) {
|
|
|
11755
11884
|
} catch (error) {
|
|
11756
11885
|
return malformed(`task '${task.id}' has invalid writes: ${error instanceof Error ? error.message : String(error)}`);
|
|
11757
11886
|
}
|
|
11758
|
-
const outside = writes.find((path2) => !
|
|
11887
|
+
const outside = writes.find((path2) => !pathBoundaryCovers(input.writes, path2));
|
|
11759
11888
|
if (outside !== void 0) {
|
|
11760
11889
|
return {
|
|
11761
11890
|
ok: false,
|
|
@@ -12347,13 +12476,28 @@ async function executeFleetRun(input) {
|
|
|
12347
12476
|
dynamicPlans: []
|
|
12348
12477
|
};
|
|
12349
12478
|
await writeFleetRun(fleetRunRecord);
|
|
12479
|
+
await claimAssignmentVerdict(fleetRootId, "fleet");
|
|
12480
|
+
const fileStepAttempt = (terminalRunId) => recordAssignmentAttempt(fleetRootId, terminalRunId);
|
|
12481
|
+
const settleFleetAssignment = (cleanRun2) => settleStoredAssignment(
|
|
12482
|
+
fleetRootId,
|
|
12483
|
+
fleetRunRecord.steps.at(-1)?.result.terminalRunId ?? fleetRootId,
|
|
12484
|
+
cleanRun2 ? "succeeded" : "failed",
|
|
12485
|
+
"fleet"
|
|
12486
|
+
).catch(() => void 0);
|
|
12350
12487
|
const boundaryEnforcer = createWriteBoundaryEnforcer({
|
|
12351
12488
|
root: workspaceRoot,
|
|
12352
12489
|
rootId: fleetRootId,
|
|
12353
12490
|
boundaryFor: (stepId) => livePlan.steps.find((step) => step.id === stepId)?.writes,
|
|
12491
|
+
recordedWritesFor: (stepId) => {
|
|
12492
|
+
const step = livePlan.steps.find((entry) => entry.id === stepId);
|
|
12493
|
+
if (step === void 0 || step.kind !== "agent") return null;
|
|
12494
|
+
const receipt = receiptsByStep.get(stepId);
|
|
12495
|
+
if (receipt === void 0) return null;
|
|
12496
|
+
return dispatch.observedRunWrites?.(receipt.runId) ?? null;
|
|
12497
|
+
},
|
|
12354
12498
|
onVerdict(verdict, path2) {
|
|
12355
|
-
if (verdict.
|
|
12356
|
-
notice(`write boundary ${verdict.window}: ${verdict.detail
|
|
12499
|
+
if (verdict.detail === null) return;
|
|
12500
|
+
notice(`write boundary ${verdict.window}: ${verdict.detail} record=${path2}`, "write-boundary");
|
|
12357
12501
|
}
|
|
12358
12502
|
});
|
|
12359
12503
|
const receipts = [];
|
|
@@ -12384,6 +12528,7 @@ async function executeFleetRun(input) {
|
|
|
12384
12528
|
costUsd: receiptsByStep.get(stepId)?.costUsd ?? 0,
|
|
12385
12529
|
result: replayedResult
|
|
12386
12530
|
});
|
|
12531
|
+
await fileStepAttempt(replayedResult.terminalRunId);
|
|
12387
12532
|
}
|
|
12388
12533
|
const planStep = (stepId) => livePlan.steps.find((entry) => entry.id === stepId);
|
|
12389
12534
|
let validationFresh = false;
|
|
@@ -12728,6 +12873,7 @@ async function executeFleetRun(input) {
|
|
|
12728
12873
|
onStepSettled: async (step, stepResult) => {
|
|
12729
12874
|
fleetRunRecord.steps.push({ stepId: step.id, result: stepResult });
|
|
12730
12875
|
await writeFleetRun(fleetRunRecord);
|
|
12876
|
+
await fileStepAttempt(stepResult.terminalRunId);
|
|
12731
12877
|
},
|
|
12732
12878
|
spliceAfter(currentPlan, step, stepResult) {
|
|
12733
12879
|
if (stepResult.delegationPlan === void 0) return null;
|
|
@@ -12767,6 +12913,7 @@ async function executeFleetRun(input) {
|
|
|
12767
12913
|
} catch (error) {
|
|
12768
12914
|
fleetRunRecord.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12769
12915
|
await writeFleetRun(fleetRunRecord);
|
|
12916
|
+
await settleFleetAssignment(false);
|
|
12770
12917
|
throw error;
|
|
12771
12918
|
}
|
|
12772
12919
|
fleetRunRecord.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -12774,6 +12921,8 @@ async function executeFleetRun(input) {
|
|
|
12774
12921
|
const required = livePlan.steps.filter((step) => step.loop === void 0 && !result.unneeded.includes(step.id));
|
|
12775
12922
|
const failedLoops = result.loops.filter((loop) => !loop.resolved);
|
|
12776
12923
|
const succeededStepCount = required.filter((step) => result.results.get(step.id)?.succeeded === true).length;
|
|
12924
|
+
const cleanRun = failedLoops.length === 0 && result.skipped.length === 0 && succeededStepCount === required.length;
|
|
12925
|
+
await settleFleetAssignment(cleanRun);
|
|
12777
12926
|
return {
|
|
12778
12927
|
rootId: fleetRootId,
|
|
12779
12928
|
planHash: input.plan.hash,
|
|
@@ -12783,7 +12932,7 @@ async function executeFleetRun(input) {
|
|
|
12783
12932
|
requiredStepCount: required.length,
|
|
12784
12933
|
succeededStepCount,
|
|
12785
12934
|
resolvedLoopCount: result.loops.length - failedLoops.length,
|
|
12786
|
-
cleanRun
|
|
12935
|
+
cleanRun
|
|
12787
12936
|
};
|
|
12788
12937
|
}
|
|
12789
12938
|
|
|
@@ -12840,6 +12989,19 @@ function extractRunProvenance(receipt) {
|
|
|
12840
12989
|
if (receipt.autonomyEnforcement !== void 0) view.autonomyEnforcement = receipt.autonomyEnforcement;
|
|
12841
12990
|
return view;
|
|
12842
12991
|
}
|
|
12992
|
+
function admitRunProvenance(view, status) {
|
|
12993
|
+
const admitted = {};
|
|
12994
|
+
if (status === void 0 || status.artifactIntegrity.state === "verified") {
|
|
12995
|
+
if (view.pipeline !== void 0) admitted.pipeline = view.pipeline;
|
|
12996
|
+
if (view.personaOverride !== void 0) admitted.personaOverride = view.personaOverride;
|
|
12997
|
+
if (view.escalation !== void 0) admitted.escalation = view.escalation;
|
|
12998
|
+
}
|
|
12999
|
+
const autonomy = status?.autonomyEnforcement.state;
|
|
13000
|
+
if (view.autonomyEnforcement !== void 0 && (autonomy === "enforced" || autonomy === "approximated" || autonomy === "bypassed")) {
|
|
13001
|
+
admitted.autonomyEnforcement = view.autonomyEnforcement;
|
|
13002
|
+
}
|
|
13003
|
+
return admitted;
|
|
13004
|
+
}
|
|
12843
13005
|
function hasRunProvenance(view) {
|
|
12844
13006
|
return view.pipeline !== void 0 || view.personaOverride !== void 0 || view.escalation !== void 0 || view.autonomyEnforcement !== void 0;
|
|
12845
13007
|
}
|
|
@@ -12910,13 +13072,14 @@ function formatPersonaHashPrefix(promptHash2) {
|
|
|
12910
13072
|
if (promptHash2.length <= PERSONA_HASH_PREFIX_CHARS) return promptHash2;
|
|
12911
13073
|
return `${promptHash2.slice(0, PERSONA_HASH_PREFIX_CHARS)}...`;
|
|
12912
13074
|
}
|
|
12913
|
-
function provenanceTranscriptLines(
|
|
13075
|
+
function provenanceTranscriptLines(source, status) {
|
|
13076
|
+
const view = admitRunProvenance(source, status);
|
|
12914
13077
|
const lines = [];
|
|
12915
13078
|
if (view.pipeline !== void 0) {
|
|
12916
13079
|
const { fromRunId, position, inputBytes, inputTruncated } = view.pipeline;
|
|
12917
|
-
const
|
|
13080
|
+
const source2 = fromRunId ?? "unknown";
|
|
12918
13081
|
const truncation = inputTruncated ? "input truncated" : "not truncated";
|
|
12919
|
-
lines.push(`pipeline: step ${position}, input ${inputBytes} bytes from ${
|
|
13082
|
+
lines.push(`pipeline: step ${position}, input ${inputBytes} bytes from ${source2} (${truncation})`);
|
|
12920
13083
|
}
|
|
12921
13084
|
if (view.personaOverride !== void 0) {
|
|
12922
13085
|
lines.push(`persona override: prompt hash ${formatPersonaHashPrefix(view.personaOverride.promptHash)}`);
|
|
@@ -12926,14 +13089,15 @@ function provenanceTranscriptLines(view) {
|
|
|
12926
13089
|
lines.push(`escalations: ${requested} requested, ${approved} approved, ${denied} denied, ${timedOut} timed out`);
|
|
12927
13090
|
}
|
|
12928
13091
|
if (view.autonomyEnforcement !== void 0) {
|
|
12929
|
-
const {
|
|
13092
|
+
const { autonomy, externalMode, dangerousBypass } = view.autonomyEnforcement;
|
|
12930
13093
|
const mode = externalMode !== void 0 ? ` mode=${externalMode}` : "";
|
|
12931
13094
|
const bypass = dangerousBypass === true ? " dangerousBypass=true" : "";
|
|
12932
|
-
lines.push(`autonomy
|
|
13095
|
+
lines.push(`autonomy: ${autonomy}${mode}${bypass}`);
|
|
12933
13096
|
}
|
|
12934
13097
|
return lines;
|
|
12935
13098
|
}
|
|
12936
|
-
function provenanceCompactSuffix(
|
|
13099
|
+
function provenanceCompactSuffix(source, status) {
|
|
13100
|
+
const view = admitRunProvenance(source, status);
|
|
12937
13101
|
const parts = [];
|
|
12938
13102
|
if (view.pipeline !== void 0) {
|
|
12939
13103
|
const { fromRunId, position, inputBytes, inputTruncated } = view.pipeline;
|
|
@@ -12948,10 +13112,10 @@ function provenanceCompactSuffix(view) {
|
|
|
12948
13112
|
parts.push(`escalations=${requested}req/${approved}appr/${denied}deny/${timedOut}timeout`);
|
|
12949
13113
|
}
|
|
12950
13114
|
if (view.autonomyEnforcement !== void 0) {
|
|
12951
|
-
const {
|
|
13115
|
+
const { autonomy, externalMode, dangerousBypass } = view.autonomyEnforcement;
|
|
12952
13116
|
const mode = externalMode !== void 0 ? `/${externalMode}` : "";
|
|
12953
13117
|
const bypass = dangerousBypass === true ? "/bypass" : "";
|
|
12954
|
-
parts.push(`
|
|
13118
|
+
parts.push(`autonomy=${autonomy}${mode}${bypass}`);
|
|
12955
13119
|
}
|
|
12956
13120
|
return parts.length === 0 ? "" : ` ${parts.join(" ")}`;
|
|
12957
13121
|
}
|
|
@@ -12959,521 +13123,6 @@ function provenanceCompactSuffix(view) {
|
|
|
12959
13123
|
// src/domains/evidence/run-trust.ts
|
|
12960
13124
|
init_esm_shims();
|
|
12961
13125
|
|
|
12962
|
-
// src/domains/evidence/trust-status.ts
|
|
12963
|
-
init_esm_shims();
|
|
12964
|
-
var TRUST_STATUS_VERSION = 1;
|
|
12965
|
-
var TRUST_STATUS_MAX_ARTIFACT_REFERENCES = 16;
|
|
12966
|
-
var TRUST_STATUS_MAX_IDENTIFIER_LENGTH = 512;
|
|
12967
|
-
var TRUST_STATUS_AXES = [
|
|
12968
|
-
"artifactIntegrity",
|
|
12969
|
-
"validationGrounding",
|
|
12970
|
-
"independentReview",
|
|
12971
|
-
"contextProvenance",
|
|
12972
|
-
"autonomyEnforcement",
|
|
12973
|
-
"completionEvidence"
|
|
12974
|
-
];
|
|
12975
|
-
var TRUST_STATUS_STATES = {
|
|
12976
|
-
artifactIntegrity: ["verified", "failed", "absent", "unknown", "not_applicable"],
|
|
12977
|
-
validationGrounding: ["validated", "failed", "ungrounded", "absent", "unknown", "not_applicable"],
|
|
12978
|
-
independentReview: ["passed", "failed", "inconclusive", "not_independent", "absent", "unknown", "not_applicable"],
|
|
12979
|
-
contextProvenance: ["recorded", "invalid", "absent", "unknown", "not_applicable"],
|
|
12980
|
-
autonomyEnforcement: ["enforced", "approximated", "bypassed", "absent", "unknown", "not_applicable"],
|
|
12981
|
-
completionEvidence: ["evidenced", "incomplete", "limited", "absent", "unknown", "not_applicable"]
|
|
12982
|
-
};
|
|
12983
|
-
var SELF_REPORTED_ARTIFACT_KINDS = /* @__PURE__ */ new Set([
|
|
12984
|
-
"finish_contract_evidence",
|
|
12985
|
-
"run_receipt"
|
|
12986
|
-
]);
|
|
12987
|
-
var AXIS_STATES = {
|
|
12988
|
-
artifactIntegrity: new Set(TRUST_STATUS_STATES.artifactIntegrity),
|
|
12989
|
-
validationGrounding: new Set(TRUST_STATUS_STATES.validationGrounding),
|
|
12990
|
-
independentReview: new Set(TRUST_STATUS_STATES.independentReview),
|
|
12991
|
-
contextProvenance: new Set(TRUST_STATUS_STATES.contextProvenance),
|
|
12992
|
-
autonomyEnforcement: new Set(TRUST_STATUS_STATES.autonomyEnforcement),
|
|
12993
|
-
completionEvidence: new Set(TRUST_STATUS_STATES.completionEvidence)
|
|
12994
|
-
};
|
|
12995
|
-
var AXIS_SOURCES = {
|
|
12996
|
-
artifactIntegrity: /* @__PURE__ */ new Set(["receipt_integrity_verification", "compatibility"]),
|
|
12997
|
-
validationGrounding: /* @__PURE__ */ new Set(["run_receipt", "evidence_bundle", "compatibility"]),
|
|
12998
|
-
independentReview: /* @__PURE__ */ new Set(["gate_decision", "compatibility"]),
|
|
12999
|
-
contextProvenance: /* @__PURE__ */ new Set(["run_receipt", "evidence_bundle", "compatibility"]),
|
|
13000
|
-
autonomyEnforcement: /* @__PURE__ */ new Set(["run_receipt", "compatibility"]),
|
|
13001
|
-
completionEvidence: /* @__PURE__ */ new Set(["finish_contract", "compatibility"])
|
|
13002
|
-
};
|
|
13003
|
-
var SOURCE_AUTHORITIES = {
|
|
13004
|
-
receipt_integrity_verification: /* @__PURE__ */ new Set(["clio"]),
|
|
13005
|
-
run_receipt: /* @__PURE__ */ new Set(["clio", "validator", "runtime", "external_system", "unknown"]),
|
|
13006
|
-
gate_decision: /* @__PURE__ */ new Set(["clio", "reviewer", "operator", "unknown"]),
|
|
13007
|
-
evidence_bundle: /* @__PURE__ */ new Set(["clio"]),
|
|
13008
|
-
finish_contract: /* @__PURE__ */ new Set(["clio"]),
|
|
13009
|
-
compatibility: /* @__PURE__ */ new Set(["clio", "unknown"])
|
|
13010
|
-
};
|
|
13011
|
-
var ABSENCE_REASONS = /* @__PURE__ */ new Set([
|
|
13012
|
-
"not_recorded",
|
|
13013
|
-
"not_observed",
|
|
13014
|
-
"artifact_missing",
|
|
13015
|
-
"historical_format"
|
|
13016
|
-
]);
|
|
13017
|
-
var SOURCE_KINDS = /* @__PURE__ */ new Set([
|
|
13018
|
-
"receipt_integrity_verification",
|
|
13019
|
-
"run_receipt",
|
|
13020
|
-
"gate_decision",
|
|
13021
|
-
"evidence_bundle",
|
|
13022
|
-
"finish_contract",
|
|
13023
|
-
"compatibility"
|
|
13024
|
-
]);
|
|
13025
|
-
var AUTHORITY_KINDS = /* @__PURE__ */ new Set([
|
|
13026
|
-
"clio",
|
|
13027
|
-
"validator",
|
|
13028
|
-
"reviewer",
|
|
13029
|
-
"operator",
|
|
13030
|
-
"runtime",
|
|
13031
|
-
"external_system",
|
|
13032
|
-
"unknown"
|
|
13033
|
-
]);
|
|
13034
|
-
var ARTIFACT_KINDS = /* @__PURE__ */ new Set([
|
|
13035
|
-
"run_receipt",
|
|
13036
|
-
"validation_result",
|
|
13037
|
-
"gate_decision",
|
|
13038
|
-
"briefing",
|
|
13039
|
-
"project_context",
|
|
13040
|
-
"autonomy_policy",
|
|
13041
|
-
"finish_contract_evidence",
|
|
13042
|
-
"evidence_bundle",
|
|
13043
|
-
"session_entry"
|
|
13044
|
-
]);
|
|
13045
|
-
function isRecord10(value) {
|
|
13046
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13047
|
-
}
|
|
13048
|
-
function hasExactKeys(value, keys) {
|
|
13049
|
-
const expected = new Set(keys);
|
|
13050
|
-
return Object.keys(value).length === expected.size && Object.keys(value).every((key) => expected.has(key));
|
|
13051
|
-
}
|
|
13052
|
-
function isTrustStatusIdentifier(value) {
|
|
13053
|
-
if (typeof value !== "string" || value.trim().length === 0 || value.length > TRUST_STATUS_MAX_IDENTIFIER_LENGTH) {
|
|
13054
|
-
return false;
|
|
13055
|
-
}
|
|
13056
|
-
for (const character of value) {
|
|
13057
|
-
const codePoint = character.codePointAt(0);
|
|
13058
|
-
if (codePoint !== void 0 && (codePoint < 32 || codePoint === 127)) return false;
|
|
13059
|
-
}
|
|
13060
|
-
return true;
|
|
13061
|
-
}
|
|
13062
|
-
function compareArtifactReferences(left, right) {
|
|
13063
|
-
const leftKey = `${left.kind}\0${left.id}\0${left.digest?.value ?? ""}`;
|
|
13064
|
-
const rightKey = `${right.kind}\0${right.id}\0${right.digest?.value ?? ""}`;
|
|
13065
|
-
return leftKey < rightKey ? -1 : leftKey > rightKey ? 1 : 0;
|
|
13066
|
-
}
|
|
13067
|
-
function normalizeArtifactReference(value, path2) {
|
|
13068
|
-
if (!isRecord10(value)) throw new Error(`${path2} must be an object`);
|
|
13069
|
-
if (!hasExactKeys(value, value.digest === void 0 ? ["kind", "id"] : ["kind", "id", "digest"])) {
|
|
13070
|
-
throw new Error(`${path2} has unknown or missing fields`);
|
|
13071
|
-
}
|
|
13072
|
-
if (typeof value.kind !== "string" || !ARTIFACT_KINDS.has(value.kind)) {
|
|
13073
|
-
throw new Error(`${path2}.kind is invalid`);
|
|
13074
|
-
}
|
|
13075
|
-
if (!isTrustStatusIdentifier(value.id)) throw new Error(`${path2}.id is invalid`);
|
|
13076
|
-
const reference = { kind: value.kind, id: value.id };
|
|
13077
|
-
if (value.digest !== void 0) {
|
|
13078
|
-
if (!isRecord10(value.digest) || !hasExactKeys(value.digest, ["algorithm", "value"]) || value.digest.algorithm !== "sha256" || typeof value.digest.value !== "string" || !/^[a-f0-9]{64}$/u.test(value.digest.value)) {
|
|
13079
|
-
throw new Error(`${path2}.digest is invalid`);
|
|
13080
|
-
}
|
|
13081
|
-
reference.digest = { algorithm: "sha256", value: value.digest.value };
|
|
13082
|
-
}
|
|
13083
|
-
return reference;
|
|
13084
|
-
}
|
|
13085
|
-
function normalizeAttributedStatus(axis, value) {
|
|
13086
|
-
if (!hasExactKeys(value, ["state", "source", "authority", "artifacts"])) {
|
|
13087
|
-
throw new Error(`${axis} has unknown or missing fields`);
|
|
13088
|
-
}
|
|
13089
|
-
if (!isRecord10(value.source) || !hasExactKeys(value.source, ["kind", "id"])) {
|
|
13090
|
-
throw new Error(`${axis}.source is invalid`);
|
|
13091
|
-
}
|
|
13092
|
-
if (typeof value.source.kind !== "string" || !SOURCE_KINDS.has(value.source.kind) || !AXIS_SOURCES[axis].has(value.source.kind) || !isTrustStatusIdentifier(value.source.id)) {
|
|
13093
|
-
throw new Error(`${axis}.source is invalid`);
|
|
13094
|
-
}
|
|
13095
|
-
if (!isRecord10(value.authority) || !hasExactKeys(value.authority, ["kind", "id"])) {
|
|
13096
|
-
throw new Error(`${axis}.authority is invalid`);
|
|
13097
|
-
}
|
|
13098
|
-
if (typeof value.authority.kind !== "string" || !AUTHORITY_KINDS.has(value.authority.kind) || !SOURCE_AUTHORITIES[value.source.kind].has(
|
|
13099
|
-
value.authority.kind
|
|
13100
|
-
) || !isTrustStatusIdentifier(value.authority.id)) {
|
|
13101
|
-
throw new Error(`${axis}.authority is invalid`);
|
|
13102
|
-
}
|
|
13103
|
-
if (value.source.kind === "compatibility" && value.state !== "unknown" && value.state !== "not_applicable") {
|
|
13104
|
-
throw new Error(`${axis} compatibility source cannot establish ${value.state}`);
|
|
13105
|
-
}
|
|
13106
|
-
if (!Array.isArray(value.artifacts) || value.artifacts.length > TRUST_STATUS_MAX_ARTIFACT_REFERENCES) {
|
|
13107
|
-
throw new Error(`${axis}.artifacts exceeds the bounded reference list`);
|
|
13108
|
-
}
|
|
13109
|
-
const artifacts = value.artifacts.map(
|
|
13110
|
-
(entry, index) => normalizeArtifactReference(entry, `${axis}.artifacts[${index}]`)
|
|
13111
|
-
);
|
|
13112
|
-
artifacts.sort(compareArtifactReferences);
|
|
13113
|
-
for (let index = 1; index < artifacts.length; index += 1) {
|
|
13114
|
-
if (compareArtifactReferences(
|
|
13115
|
-
artifacts[index - 1],
|
|
13116
|
-
artifacts[index]
|
|
13117
|
-
) === 0) {
|
|
13118
|
-
throw new Error(`${axis}.artifacts contains a duplicate reference`);
|
|
13119
|
-
}
|
|
13120
|
-
}
|
|
13121
|
-
return {
|
|
13122
|
-
state: value.state,
|
|
13123
|
-
source: { kind: value.source.kind, id: value.source.id },
|
|
13124
|
-
authority: { kind: value.authority.kind, id: value.authority.id },
|
|
13125
|
-
artifacts
|
|
13126
|
-
};
|
|
13127
|
-
}
|
|
13128
|
-
function normalizeAxis(axis, value) {
|
|
13129
|
-
if (!isRecord10(value) || typeof value.state !== "string" || !AXIS_STATES[axis].has(value.state)) {
|
|
13130
|
-
throw new Error(`${axis}.state is invalid`);
|
|
13131
|
-
}
|
|
13132
|
-
if (value.state === "absent") {
|
|
13133
|
-
if (!hasExactKeys(value, ["state", "reason"]) || typeof value.reason !== "string" || !ABSENCE_REASONS.has(value.reason)) {
|
|
13134
|
-
throw new Error(`${axis} absent state is invalid`);
|
|
13135
|
-
}
|
|
13136
|
-
return { state: "absent", reason: value.reason };
|
|
13137
|
-
}
|
|
13138
|
-
return normalizeAttributedStatus(axis, value);
|
|
13139
|
-
}
|
|
13140
|
-
function normalizeTrustStatus(value) {
|
|
13141
|
-
if (!isRecord10(value) || !hasExactKeys(value, ["version", ...TRUST_STATUS_AXES])) {
|
|
13142
|
-
throw new Error("trust status has unknown or missing fields");
|
|
13143
|
-
}
|
|
13144
|
-
if (value.version !== TRUST_STATUS_VERSION) throw new Error("trust status version is invalid");
|
|
13145
|
-
return {
|
|
13146
|
-
version: TRUST_STATUS_VERSION,
|
|
13147
|
-
artifactIntegrity: normalizeAxis("artifactIntegrity", value.artifactIntegrity),
|
|
13148
|
-
validationGrounding: normalizeAxis("validationGrounding", value.validationGrounding),
|
|
13149
|
-
independentReview: normalizeAxis("independentReview", value.independentReview),
|
|
13150
|
-
contextProvenance: normalizeAxis("contextProvenance", value.contextProvenance),
|
|
13151
|
-
autonomyEnforcement: normalizeAxis("autonomyEnforcement", value.autonomyEnforcement),
|
|
13152
|
-
completionEvidence: normalizeAxis("completionEvidence", value.completionEvidence)
|
|
13153
|
-
};
|
|
13154
|
-
}
|
|
13155
|
-
function absentTrustStatus(reason) {
|
|
13156
|
-
return { state: "absent", reason };
|
|
13157
|
-
}
|
|
13158
|
-
function composeTrustStatus(...projections) {
|
|
13159
|
-
const axes = {
|
|
13160
|
-
artifactIntegrity: absentTrustStatus("not_recorded"),
|
|
13161
|
-
validationGrounding: absentTrustStatus("not_recorded"),
|
|
13162
|
-
independentReview: absentTrustStatus("not_recorded"),
|
|
13163
|
-
contextProvenance: absentTrustStatus("not_recorded"),
|
|
13164
|
-
autonomyEnforcement: absentTrustStatus("not_recorded"),
|
|
13165
|
-
completionEvidence: absentTrustStatus("not_recorded")
|
|
13166
|
-
};
|
|
13167
|
-
for (const projection of projections) {
|
|
13168
|
-
if (projection.artifactIntegrity !== void 0) axes.artifactIntegrity = projection.artifactIntegrity;
|
|
13169
|
-
if (projection.validationGrounding !== void 0) axes.validationGrounding = projection.validationGrounding;
|
|
13170
|
-
if (projection.independentReview !== void 0) axes.independentReview = projection.independentReview;
|
|
13171
|
-
if (projection.contextProvenance !== void 0) axes.contextProvenance = projection.contextProvenance;
|
|
13172
|
-
if (projection.autonomyEnforcement !== void 0) axes.autonomyEnforcement = projection.autonomyEnforcement;
|
|
13173
|
-
if (projection.completionEvidence !== void 0) axes.completionEvidence = projection.completionEvidence;
|
|
13174
|
-
}
|
|
13175
|
-
return normalizeTrustStatus({ version: TRUST_STATUS_VERSION, ...axes });
|
|
13176
|
-
}
|
|
13177
|
-
function sha256Reference(kind, id, digest) {
|
|
13178
|
-
const reference = { kind, id };
|
|
13179
|
-
if (digest !== void 0 && /^[a-f0-9]{64}$/u.test(digest)) {
|
|
13180
|
-
reference.digest = { algorithm: "sha256", value: digest };
|
|
13181
|
-
}
|
|
13182
|
-
return reference;
|
|
13183
|
-
}
|
|
13184
|
-
function receiptReference(receipt) {
|
|
13185
|
-
return sha256Reference("run_receipt", receipt.runId, receipt.integrity?.digest);
|
|
13186
|
-
}
|
|
13187
|
-
function attributed(state, source, authority, artifacts) {
|
|
13188
|
-
return { state, source, authority, artifacts: [...artifacts].sort(compareArtifactReferences) };
|
|
13189
|
-
}
|
|
13190
|
-
function receiptSource(receipt) {
|
|
13191
|
-
return { kind: "run_receipt", id: receipt.runId };
|
|
13192
|
-
}
|
|
13193
|
-
function compatibilitySource(receipt, field) {
|
|
13194
|
-
return { kind: "compatibility", id: `run_receipt:${receipt.runId}:${field}` };
|
|
13195
|
-
}
|
|
13196
|
-
var DISPATCH_AUTHORITY = { kind: "clio", id: "dispatch" };
|
|
13197
|
-
var COMPATIBILITY_AUTHORITY = { kind: "unknown", id: "historical-persisted-format" };
|
|
13198
|
-
function adaptReceiptIntegrityStatus(receipt, verification) {
|
|
13199
|
-
if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
|
|
13200
|
-
const artifacts = [receiptReference(receipt)];
|
|
13201
|
-
if (verification === void 0 || verification.ok && receipt.integrity === void 0) {
|
|
13202
|
-
return attributed(
|
|
13203
|
-
"unknown",
|
|
13204
|
-
{
|
|
13205
|
-
kind: "compatibility",
|
|
13206
|
-
id: `run_receipt:${receipt.runId}:${receipt.integrity === void 0 ? "integrity-missing" : "integrity-unchecked"}`
|
|
13207
|
-
},
|
|
13208
|
-
COMPATIBILITY_AUTHORITY,
|
|
13209
|
-
artifacts
|
|
13210
|
-
);
|
|
13211
|
-
}
|
|
13212
|
-
return attributed(
|
|
13213
|
-
verification.ok ? "verified" : "failed",
|
|
13214
|
-
{ kind: "receipt_integrity_verification", id: receipt.runId },
|
|
13215
|
-
{ kind: "clio", id: "receipt-integrity" },
|
|
13216
|
-
artifacts
|
|
13217
|
-
);
|
|
13218
|
-
}
|
|
13219
|
-
function validationArtifacts(receipt) {
|
|
13220
|
-
const artifacts = [receiptReference(receipt)];
|
|
13221
|
-
for (const fact of receipt.quality?.typedValidations ?? []) {
|
|
13222
|
-
artifacts.push(sha256Reference("validation_result", fact.sourceId, fact.validatorDigest));
|
|
13223
|
-
}
|
|
13224
|
-
const resultContract = receipt.quality?.resultContract;
|
|
13225
|
-
if (resultContract !== null && resultContract !== void 0) {
|
|
13226
|
-
artifacts.push(sha256Reference("validation_result", resultContract.sourceId, resultContract.validatorDigest));
|
|
13227
|
-
}
|
|
13228
|
-
return uniqueBoundedReferences(artifacts);
|
|
13229
|
-
}
|
|
13230
|
-
function qualityHasFailure(quality) {
|
|
13231
|
-
if (quality === void 0) return false;
|
|
13232
|
-
if (quality.typedValidations.some((fact) => !fact.passed)) return true;
|
|
13233
|
-
return quality.resultContract?.conformance === "fail" || quality.resultContract?.quality === "fail";
|
|
13234
|
-
}
|
|
13235
|
-
function qualityHasValidation(quality) {
|
|
13236
|
-
if (quality === void 0) return false;
|
|
13237
|
-
if (quality.typedValidations.some((fact) => fact.passed)) return true;
|
|
13238
|
-
return quality.resultContract?.quality === "pass";
|
|
13239
|
-
}
|
|
13240
|
-
function verificationStatus(verification, receipt, artifacts) {
|
|
13241
|
-
if (verification.state === "verified") {
|
|
13242
|
-
return attributed("validated", receiptSource(receipt), { kind: "validator", id: verification.basis }, artifacts);
|
|
13243
|
-
}
|
|
13244
|
-
if (verification.state === "unverified") return absentTrustStatus("not_observed");
|
|
13245
|
-
if (verification.state === "not_applicable") {
|
|
13246
|
-
return attributed("not_applicable", receiptSource(receipt), DISPATCH_AUTHORITY, artifacts);
|
|
13247
|
-
}
|
|
13248
|
-
return attributed(
|
|
13249
|
-
"unknown",
|
|
13250
|
-
receiptSource(receipt),
|
|
13251
|
-
verification.basis === "acp-external-unobserved" ? { kind: "external_system", id: "acp-delegation" } : COMPATIBILITY_AUTHORITY,
|
|
13252
|
-
artifacts
|
|
13253
|
-
);
|
|
13254
|
-
}
|
|
13255
|
-
function adaptRunReceiptValidationStatus(receipt) {
|
|
13256
|
-
if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
|
|
13257
|
-
const artifacts = validationArtifacts(receipt);
|
|
13258
|
-
if (receipt.hostVerification?.status === "rejected") {
|
|
13259
|
-
return attributed("failed", receiptSource(receipt), { kind: "validator", id: "host-verification" }, artifacts);
|
|
13260
|
-
}
|
|
13261
|
-
if (receipt.hostVerification?.status === "verified") {
|
|
13262
|
-
return attributed("validated", receiptSource(receipt), { kind: "validator", id: "host-verification" }, artifacts);
|
|
13263
|
-
}
|
|
13264
|
-
if (qualityHasFailure(receipt.quality)) {
|
|
13265
|
-
return attributed("failed", receiptSource(receipt), { kind: "validator", id: "receipt-quality" }, artifacts);
|
|
13266
|
-
}
|
|
13267
|
-
if ((receipt.validationGrounding?.ungrounded.length ?? 0) > 0 || receipt.validationGrounding !== void 0 && receipt.validationGrounding.claimed > receipt.validationGrounding.grounded) {
|
|
13268
|
-
return attributed("ungrounded", receiptSource(receipt), { kind: "validator", id: "command-grounding" }, artifacts);
|
|
13269
|
-
}
|
|
13270
|
-
if (qualityHasValidation(receipt.quality)) {
|
|
13271
|
-
return attributed("validated", receiptSource(receipt), { kind: "validator", id: "receipt-quality" }, artifacts);
|
|
13272
|
-
}
|
|
13273
|
-
if (receipt.verification !== void 0) {
|
|
13274
|
-
return verificationStatus(receipt.verification, receipt, artifacts);
|
|
13275
|
-
}
|
|
13276
|
-
return attributed("unknown", compatibilitySource(receipt, "verification"), COMPATIBILITY_AUTHORITY, artifacts);
|
|
13277
|
-
}
|
|
13278
|
-
function validBriefing(briefing) {
|
|
13279
|
-
return Number.isSafeInteger(briefing.bytes) && briefing.bytes >= 0 && /^[a-f0-9]{64}$/u.test(briefing.contentHash);
|
|
13280
|
-
}
|
|
13281
|
-
function validBoundedProjectContext(context) {
|
|
13282
|
-
return context.tier === "bounded" && Number.isSafeInteger(context.chars) && (context.chars ?? -1) >= 0 && typeof context.contentHash === "string" && /^[a-f0-9]{64}$/u.test(context.contentHash);
|
|
13283
|
-
}
|
|
13284
|
-
function contextArtifacts(receipt) {
|
|
13285
|
-
const artifacts = [receiptReference(receipt)];
|
|
13286
|
-
if (receipt.briefing !== void 0 && validBriefing(receipt.briefing)) {
|
|
13287
|
-
artifacts.push(sha256Reference("briefing", `${receipt.runId}:briefing`, receipt.briefing.contentHash));
|
|
13288
|
-
}
|
|
13289
|
-
if (receipt.projectContext?.tier === "bounded" && validBoundedProjectContext(receipt.projectContext)) {
|
|
13290
|
-
artifacts.push(
|
|
13291
|
-
sha256Reference("project_context", `${receipt.runId}:project-context`, receipt.projectContext.contentHash)
|
|
13292
|
-
);
|
|
13293
|
-
}
|
|
13294
|
-
return uniqueBoundedReferences(artifacts);
|
|
13295
|
-
}
|
|
13296
|
-
function adaptRunReceiptContextStatus(receipt) {
|
|
13297
|
-
if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
|
|
13298
|
-
const artifacts = contextArtifacts(receipt);
|
|
13299
|
-
const source = receiptSource(receipt);
|
|
13300
|
-
const briefingInvalid = receipt.briefing !== void 0 && !validBriefing(receipt.briefing);
|
|
13301
|
-
if (briefingInvalid) return attributed("invalid", source, DISPATCH_AUTHORITY, artifacts);
|
|
13302
|
-
const context = receipt.projectContext;
|
|
13303
|
-
if (context === void 0) {
|
|
13304
|
-
if (receipt.briefing !== void 0) return attributed("recorded", source, DISPATCH_AUTHORITY, artifacts);
|
|
13305
|
-
return attributed("unknown", compatibilitySource(receipt, "projectContext"), COMPATIBILITY_AUTHORITY, artifacts);
|
|
13306
|
-
}
|
|
13307
|
-
if (context.tier === "none") {
|
|
13308
|
-
if (context.chars !== void 0 || context.contentHash !== void 0 || context.sections !== void 0) {
|
|
13309
|
-
return attributed("invalid", source, DISPATCH_AUTHORITY, artifacts);
|
|
13310
|
-
}
|
|
13311
|
-
return receipt.briefing === void 0 ? attributed("not_applicable", source, DISPATCH_AUTHORITY, artifacts) : attributed("recorded", source, DISPATCH_AUTHORITY, artifacts);
|
|
13312
|
-
}
|
|
13313
|
-
return attributed(validBoundedProjectContext(context) ? "recorded" : "invalid", source, DISPATCH_AUTHORITY, artifacts);
|
|
13314
|
-
}
|
|
13315
|
-
function adaptRunReceiptAutonomyStatus(receipt) {
|
|
13316
|
-
if (receipt === null || receipt === void 0) return absentTrustStatus("artifact_missing");
|
|
13317
|
-
const enforcement = receipt.autonomyEnforcement;
|
|
13318
|
-
const artifacts = [receiptReference(receipt)];
|
|
13319
|
-
if (enforcement === void 0) {
|
|
13320
|
-
return attributed("unknown", compatibilitySource(receipt, "autonomyEnforcement"), COMPATIBILITY_AUTHORITY, artifacts);
|
|
13321
|
-
}
|
|
13322
|
-
artifacts.push({ kind: "autonomy_policy", id: `${receipt.runId}:${enforcement.autonomy}` });
|
|
13323
|
-
const authority = enforcement.grade === "mediated" ? { kind: "clio", id: "safety-autonomy" } : { kind: "runtime", id: enforcement.externalMode ?? "external-runtime" };
|
|
13324
|
-
const state = enforcement.dangerousBypass === true || enforcement.grade === "bypassed" ? "bypassed" : enforcement.grade === "approximated" ? "approximated" : "enforced";
|
|
13325
|
-
return attributed(state, receiptSource(receipt), authority, artifacts);
|
|
13326
|
-
}
|
|
13327
|
-
function receiptClaimsAreAuthenticated(receipt, integrity) {
|
|
13328
|
-
return receipt?.integrity !== void 0 && integrity?.ok === true;
|
|
13329
|
-
}
|
|
13330
|
-
function unauthenticatedReceiptProjection(receipt) {
|
|
13331
|
-
if (receipt === null || receipt === void 0) {
|
|
13332
|
-
return {
|
|
13333
|
-
validationGrounding: absentTrustStatus("artifact_missing"),
|
|
13334
|
-
contextProvenance: absentTrustStatus("artifact_missing"),
|
|
13335
|
-
autonomyEnforcement: absentTrustStatus("artifact_missing")
|
|
13336
|
-
};
|
|
13337
|
-
}
|
|
13338
|
-
if (receipt.integrity === void 0) {
|
|
13339
|
-
const artifacts = [receiptReference(receipt)];
|
|
13340
|
-
return {
|
|
13341
|
-
validationGrounding: attributed(
|
|
13342
|
-
"unknown",
|
|
13343
|
-
compatibilitySource(receipt, "canonical-projection"),
|
|
13344
|
-
COMPATIBILITY_AUTHORITY,
|
|
13345
|
-
artifacts
|
|
13346
|
-
),
|
|
13347
|
-
contextProvenance: attributed(
|
|
13348
|
-
"unknown",
|
|
13349
|
-
compatibilitySource(receipt, "canonical-projection"),
|
|
13350
|
-
COMPATIBILITY_AUTHORITY,
|
|
13351
|
-
artifacts
|
|
13352
|
-
),
|
|
13353
|
-
autonomyEnforcement: attributed(
|
|
13354
|
-
"unknown",
|
|
13355
|
-
compatibilitySource(receipt, "canonical-projection"),
|
|
13356
|
-
COMPATIBILITY_AUTHORITY,
|
|
13357
|
-
artifacts
|
|
13358
|
-
)
|
|
13359
|
-
};
|
|
13360
|
-
}
|
|
13361
|
-
return {
|
|
13362
|
-
validationGrounding: absentTrustStatus("not_observed"),
|
|
13363
|
-
contextProvenance: absentTrustStatus("not_observed"),
|
|
13364
|
-
autonomyEnforcement: absentTrustStatus("not_observed")
|
|
13365
|
-
};
|
|
13366
|
-
}
|
|
13367
|
-
function adaptRunReceiptTrustStatus(receipt, options = {}) {
|
|
13368
|
-
const authenticated2 = receiptClaimsAreAuthenticated(receipt, options.integrity);
|
|
13369
|
-
const receiptProjection = authenticated2 ? {
|
|
13370
|
-
validationGrounding: adaptRunReceiptValidationStatus(receipt),
|
|
13371
|
-
contextProvenance: adaptRunReceiptContextStatus(receipt),
|
|
13372
|
-
autonomyEnforcement: adaptRunReceiptAutonomyStatus(receipt)
|
|
13373
|
-
} : unauthenticatedReceiptProjection(receipt);
|
|
13374
|
-
return composeTrustStatus({
|
|
13375
|
-
artifactIntegrity: adaptReceiptIntegrityStatus(receipt, options.integrity),
|
|
13376
|
-
...receiptProjection,
|
|
13377
|
-
independentReview: absentTrustStatus(receipt === null || receipt === void 0 ? "artifact_missing" : "not_recorded"),
|
|
13378
|
-
completionEvidence: absentTrustStatus(
|
|
13379
|
-
receipt === null || receipt === void 0 ? "artifact_missing" : "not_recorded"
|
|
13380
|
-
)
|
|
13381
|
-
});
|
|
13382
|
-
}
|
|
13383
|
-
function inspectRunReceiptTrustStatus(receipt, envelope) {
|
|
13384
|
-
let integrity;
|
|
13385
|
-
if (receipt === null || receipt === void 0) {
|
|
13386
|
-
integrity = { ok: false, reason: "receipt unavailable" };
|
|
13387
|
-
} else if (envelope === null || envelope === void 0) {
|
|
13388
|
-
integrity = { ok: false, reason: "run ledger envelope unavailable" };
|
|
13389
|
-
} else {
|
|
13390
|
-
try {
|
|
13391
|
-
integrity = verifyReceiptIntegrity(receipt, envelope);
|
|
13392
|
-
} catch (error) {
|
|
13393
|
-
integrity = {
|
|
13394
|
-
ok: false,
|
|
13395
|
-
reason: `receipt invalid: ${error instanceof Error ? error.message : String(error)}`
|
|
13396
|
-
};
|
|
13397
|
-
}
|
|
13398
|
-
}
|
|
13399
|
-
return {
|
|
13400
|
-
integrity,
|
|
13401
|
-
status: adaptRunReceiptTrustStatus(receipt, { integrity })
|
|
13402
|
-
};
|
|
13403
|
-
}
|
|
13404
|
-
function gateReference(artifact) {
|
|
13405
|
-
return sha256Reference("gate_decision", artifact.id, artifact.integrity.digest);
|
|
13406
|
-
}
|
|
13407
|
-
function gateAuthority(artifact) {
|
|
13408
|
-
if (artifact.outcome === "operator-confirmed") return { kind: "operator", id: "gate-confirmation" };
|
|
13409
|
-
if (artifact.outcome === "full-auto-applied") return { kind: "clio", id: "full-auto-gate-policy" };
|
|
13410
|
-
return { kind: "reviewer", id: artifact.decider?.runId ?? "unavailable-decider" };
|
|
13411
|
-
}
|
|
13412
|
-
function adaptGateDecisionReviewStatus(artifact, subjectRunId, verification) {
|
|
13413
|
-
if (artifact === null || artifact === void 0) return absentTrustStatus("artifact_missing");
|
|
13414
|
-
const source = { kind: "gate_decision", id: artifact.id };
|
|
13415
|
-
const artifacts = [gateReference(artifact)];
|
|
13416
|
-
const authority = gateAuthority(artifact);
|
|
13417
|
-
if (!artifact.subjects.some((subject) => subject.runId === subjectRunId)) return absentTrustStatus("not_recorded");
|
|
13418
|
-
if (verification === void 0 || !verification.ok) {
|
|
13419
|
-
return attributed(
|
|
13420
|
-
"unknown",
|
|
13421
|
-
source,
|
|
13422
|
-
verification === void 0 ? COMPATIBILITY_AUTHORITY : { kind: "unknown", id: "unauthenticated-gate-artifact" },
|
|
13423
|
-
artifacts
|
|
13424
|
-
);
|
|
13425
|
-
}
|
|
13426
|
-
if (artifact.decider === void 0 || artifact.correlation === void 0) {
|
|
13427
|
-
if (artifact.outcome === "operator-confirmed" || artifact.outcome === "full-auto-applied") {
|
|
13428
|
-
return attributed("not_applicable", source, authority, artifacts);
|
|
13429
|
-
}
|
|
13430
|
-
return attributed("inconclusive", source, authority, artifacts);
|
|
13431
|
-
}
|
|
13432
|
-
if (!artifact.correlation.independent) return attributed("not_independent", source, authority, artifacts);
|
|
13433
|
-
if (artifact.outcome === "pass") return attributed("passed", source, authority, artifacts);
|
|
13434
|
-
if (artifact.outcome === "fail") return attributed("failed", source, authority, artifacts);
|
|
13435
|
-
if (artifact.outcome === "winner") {
|
|
13436
|
-
return attributed(
|
|
13437
|
-
artifact.winner?.subject.runId === subjectRunId ? "passed" : "failed",
|
|
13438
|
-
source,
|
|
13439
|
-
authority,
|
|
13440
|
-
artifacts
|
|
13441
|
-
);
|
|
13442
|
-
}
|
|
13443
|
-
return attributed("inconclusive", source, authority, artifacts);
|
|
13444
|
-
}
|
|
13445
|
-
function adaptGroundedEvidenceValidationStatus(input) {
|
|
13446
|
-
const observed = (input.artifacts ?? []).filter((artifact) => !SELF_REPORTED_ARTIFACT_KINDS.has(artifact.kind));
|
|
13447
|
-
if (observed.length === 0) return absentTrustStatus("not_observed");
|
|
13448
|
-
return attributed(
|
|
13449
|
-
"validated",
|
|
13450
|
-
{ kind: "evidence_bundle", id: `${input.evidenceId}:${input.runId}` },
|
|
13451
|
-
{ kind: "clio", id: "evidence-grounding" },
|
|
13452
|
-
uniqueBoundedReferences([{ kind: "evidence_bundle", id: input.evidenceId }, ...observed])
|
|
13453
|
-
);
|
|
13454
|
-
}
|
|
13455
|
-
function adaptFinishContractCompletionStatus(assessment, options = {}) {
|
|
13456
|
-
const artifacts = uniqueBoundedReferences(
|
|
13457
|
-
options.artifacts ?? assessment.evidence.map((evidence, index) => ({
|
|
13458
|
-
kind: evidence.turnId === void 0 ? "finish_contract_evidence" : "session_entry",
|
|
13459
|
-
id: evidence.turnId ?? `${evidence.kind}:${index + 1}`
|
|
13460
|
-
}))
|
|
13461
|
-
);
|
|
13462
|
-
const source = { kind: "finish_contract", id: options.sourceId ?? assessment.reason };
|
|
13463
|
-
const authority = { kind: "clio", id: "finish-contract" };
|
|
13464
|
-
if (assessment.reason === "no_mutation") return attributed("not_applicable", source, authority, artifacts);
|
|
13465
|
-
if (assessment.reason === "validation_evidence") return attributed("evidenced", source, authority, artifacts);
|
|
13466
|
-
if (assessment.reason === "explicit_limitation") return attributed("limited", source, authority, artifacts);
|
|
13467
|
-
return attributed("incomplete", source, authority, artifacts);
|
|
13468
|
-
}
|
|
13469
|
-
function uniqueBoundedReferences(references) {
|
|
13470
|
-
const sorted = [...references].sort(compareArtifactReferences);
|
|
13471
|
-
const unique = sorted.filter(
|
|
13472
|
-
(reference, index) => index === 0 || compareArtifactReferences(sorted[index - 1], reference) !== 0
|
|
13473
|
-
);
|
|
13474
|
-
return unique.slice(0, TRUST_STATUS_MAX_ARTIFACT_REFERENCES);
|
|
13475
|
-
}
|
|
13476
|
-
|
|
13477
13126
|
// src/domains/evidence/types.ts
|
|
13478
13127
|
init_esm_shims();
|
|
13479
13128
|
var EVIDENCE_VERSION = 1;
|
|
@@ -13676,7 +13325,7 @@ async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
|
13676
13325
|
}
|
|
13677
13326
|
const source = `${evidenceId}/trust-status.json`;
|
|
13678
13327
|
const parsed = parseJson(raw, source);
|
|
13679
|
-
if (!
|
|
13328
|
+
if (!isRecord10(parsed)) throw new Error(`${source}: expected object`);
|
|
13680
13329
|
if (parsed.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
13681
13330
|
if (readString(parsed, source, "evidenceId") !== evidenceId) {
|
|
13682
13331
|
throw new Error(`${source}.evidenceId: expected ${evidenceId}`);
|
|
@@ -13689,7 +13338,7 @@ async function loadEvidenceTrustStatus(dataDir, evidenceId) {
|
|
|
13689
13338
|
projection: "canonical",
|
|
13690
13339
|
runs: parsed.runs.map((entry, index) => {
|
|
13691
13340
|
const entrySource = `${source}.runs[${index}]`;
|
|
13692
|
-
if (!
|
|
13341
|
+
if (!isRecord10(entry)) throw new Error(`${entrySource}: expected object`);
|
|
13693
13342
|
return {
|
|
13694
13343
|
runId: readString(entry, entrySource, "runId"),
|
|
13695
13344
|
status: normalizeTrustStatus(entry.status)
|
|
@@ -13707,10 +13356,10 @@ async function loadEvidenceRunProvenance(dataDir, evidenceId) {
|
|
|
13707
13356
|
throw error;
|
|
13708
13357
|
}
|
|
13709
13358
|
const parsed = parseJson(raw, `${evidenceId}/receipt.json`);
|
|
13710
|
-
if (!
|
|
13359
|
+
if (!isRecord10(parsed) || !Array.isArray(parsed.receipts)) return [];
|
|
13711
13360
|
const out = [];
|
|
13712
13361
|
for (const entry of parsed.receipts) {
|
|
13713
|
-
if (!
|
|
13362
|
+
if (!isRecord10(entry) || typeof entry.runId !== "string") continue;
|
|
13714
13363
|
const view = runProvenanceFromUnknown(entry);
|
|
13715
13364
|
if (hasRunProvenance(view)) out.push({ runId: entry.runId, view });
|
|
13716
13365
|
}
|
|
@@ -13735,7 +13384,7 @@ async function listEvidenceOverviews(dataDir) {
|
|
|
13735
13384
|
return overviews;
|
|
13736
13385
|
}
|
|
13737
13386
|
function parseOverview(value, source) {
|
|
13738
|
-
if (!
|
|
13387
|
+
if (!isRecord10(value)) throw new Error(`${source}: expected object`);
|
|
13739
13388
|
if (value.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
13740
13389
|
const evidenceId = readString(value, source, "evidenceId");
|
|
13741
13390
|
const sourceValue = readSource(value.source, `${source}.source`);
|
|
@@ -13776,13 +13425,13 @@ function parseOverview(value, source) {
|
|
|
13776
13425
|
};
|
|
13777
13426
|
}
|
|
13778
13427
|
function parseFindingsFile(value, source) {
|
|
13779
|
-
if (!
|
|
13428
|
+
if (!isRecord10(value)) throw new Error(`${source}: expected object`);
|
|
13780
13429
|
if (value.version !== 1) throw new Error(`${source}: expected version 1`);
|
|
13781
13430
|
if (!Array.isArray(value.findings)) throw new Error(`${source}.findings: expected array`);
|
|
13782
13431
|
return value.findings.map((entry, index) => parseFinding(entry, `${source}.findings[${index}]`));
|
|
13783
13432
|
}
|
|
13784
13433
|
function parseFinding(value, source) {
|
|
13785
|
-
if (!
|
|
13434
|
+
if (!isRecord10(value)) throw new Error(`${source}: expected object`);
|
|
13786
13435
|
const severity = readString(value, source, "severity");
|
|
13787
13436
|
if (severity !== "info" && severity !== "warn") throw new Error(`${source}.severity: expected info or warn`);
|
|
13788
13437
|
const tag = readString(value, source, "tag");
|
|
@@ -13795,14 +13444,14 @@ function parseFinding(value, source) {
|
|
|
13795
13444
|
};
|
|
13796
13445
|
}
|
|
13797
13446
|
function readSource(value, source) {
|
|
13798
|
-
if (!
|
|
13447
|
+
if (!isRecord10(value)) throw new Error(`${source}: expected object`);
|
|
13799
13448
|
if (value.kind === "run") return { kind: "run", runId: readString(value, source, "runId") };
|
|
13800
13449
|
if (value.kind === "session") return { kind: "session", sessionId: readString(value, source, "sessionId") };
|
|
13801
13450
|
if (value.kind === "eval") return { kind: "eval", evalId: readString(value, source, "evalId") };
|
|
13802
13451
|
throw new Error(`${source}.kind: expected run, session, or eval`);
|
|
13803
13452
|
}
|
|
13804
13453
|
function readTotals(value, source) {
|
|
13805
|
-
if (!
|
|
13454
|
+
if (!isRecord10(value)) throw new Error(`${source}: expected object`);
|
|
13806
13455
|
return {
|
|
13807
13456
|
runs: readNumber(value, source, "runs"),
|
|
13808
13457
|
receipts: readNumber(value, source, "receipts"),
|
|
@@ -13860,7 +13509,7 @@ function parseJson(raw, source) {
|
|
|
13860
13509
|
throw new Error(`${source}: invalid JSON: ${message}`);
|
|
13861
13510
|
}
|
|
13862
13511
|
}
|
|
13863
|
-
function
|
|
13512
|
+
function isRecord10(value) {
|
|
13864
13513
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13865
13514
|
}
|
|
13866
13515
|
function findingsFile(evidenceId, findings) {
|
|
@@ -13946,7 +13595,10 @@ async function buildEvidence(options) {
|
|
|
13946
13595
|
redactedToolEvents,
|
|
13947
13596
|
protectedArtifacts
|
|
13948
13597
|
);
|
|
13949
|
-
const transcript = redactSecretsText(
|
|
13598
|
+
const transcript = redactSecretsText(
|
|
13599
|
+
renderTranscript(overview, redactedRunSources, sessionLinks, trustStatusRaw),
|
|
13600
|
+
tally
|
|
13601
|
+
);
|
|
13950
13602
|
const finalOverview = { ...overview, redactionCount: tally.count };
|
|
13951
13603
|
await writeEvidenceFiles(
|
|
13952
13604
|
directory,
|
|
@@ -14019,8 +13671,9 @@ function buildFindings(runSources, trustStatus, sessionLinks, auditLinks, protec
|
|
|
14019
13671
|
const status = trustByRun.get(source.envelope.id);
|
|
14020
13672
|
if (status === void 0) throw new Error(`canonical trust status missing for run ${source.envelope.id}`);
|
|
14021
13673
|
if (source.receiptError !== null) {
|
|
14022
|
-
const
|
|
14023
|
-
|
|
13674
|
+
const retired = retiredIntegrityVersionOf(status.artifactIntegrity) !== null;
|
|
13675
|
+
const tag = retired ? "receipt-retired" : source.receiptIntegrityFailed ? "receipt-integrity" : "unknown";
|
|
13676
|
+
findings.push(finding(findings.length, retired ? "info" : "warn", tag, source.envelope.id, source.receiptError));
|
|
14024
13677
|
}
|
|
14025
13678
|
if (isSuccessfulRun(source) && (status.validationGrounding.state === "absent" || status.validationGrounding.state === "unknown")) {
|
|
14026
13679
|
findings.push(
|
|
@@ -14081,6 +13734,7 @@ function buildFindings(runSources, trustStatus, sessionLinks, auditLinks, protec
|
|
|
14081
13734
|
)
|
|
14082
13735
|
);
|
|
14083
13736
|
}
|
|
13737
|
+
findings.push(...axisFindings(findings.length, source, status));
|
|
14084
13738
|
if (source.envelope.status === "stale" || source.envelope.status === "dead") {
|
|
14085
13739
|
findings.push(
|
|
14086
13740
|
finding(findings.length, "warn", "timeout", source.envelope.id, `run status ${source.envelope.status}`)
|
|
@@ -14231,7 +13885,7 @@ function validationToolCallCandidate(entry, linked, runSources) {
|
|
|
14231
13885
|
}
|
|
14232
13886
|
function validationToolCallSummary(toolName, args) {
|
|
14233
13887
|
const parsed = parseMaybeJson(args);
|
|
14234
|
-
const argRecord =
|
|
13888
|
+
const argRecord = isRecord11(parsed) ? parsed : null;
|
|
14235
13889
|
if (toolName === "bash") {
|
|
14236
13890
|
const command = readOptionalString2(argRecord?.command);
|
|
14237
13891
|
if (command === null) return null;
|
|
@@ -14253,8 +13907,8 @@ function validationToolCallSummary(toolName, args) {
|
|
|
14253
13907
|
}
|
|
14254
13908
|
function isSuccessfulSessionToolResult(result) {
|
|
14255
13909
|
if (result.isError) return false;
|
|
14256
|
-
const obj =
|
|
14257
|
-
const details =
|
|
13910
|
+
const obj = isRecord11(result.result) ? result.result : null;
|
|
13911
|
+
const details = isRecord11(obj?.details) ? obj.details : null;
|
|
14258
13912
|
return details?.kind !== "error";
|
|
14259
13913
|
}
|
|
14260
13914
|
function finding(index, severity, tag, runId, message) {
|
|
@@ -14271,7 +13925,7 @@ async function writeEvidenceFiles(directory, overview, runSources, findings, ses
|
|
|
14271
13925
|
await writeJson(join17(directory, "overview.json"), overview);
|
|
14272
13926
|
await writeFile(
|
|
14273
13927
|
join17(directory, "transcript.md"),
|
|
14274
|
-
transcript ?? renderTranscript(overview, runSources, sessionLinks),
|
|
13928
|
+
transcript ?? renderTranscript(overview, runSources, sessionLinks, trustStatus),
|
|
14275
13929
|
"utf8"
|
|
14276
13930
|
);
|
|
14277
13931
|
await writeJsonl(join17(directory, "trace.raw.jsonl"), rawTraceRows(runSources));
|
|
@@ -14300,7 +13954,8 @@ function cleanedTraceRows(runSources, findings, toolEventRows) {
|
|
|
14300
13954
|
const rows = [];
|
|
14301
13955
|
for (const source of runSources) {
|
|
14302
13956
|
const envelope = source.envelope;
|
|
14303
|
-
const
|
|
13957
|
+
const receipt = authenticatedReceipt(source);
|
|
13958
|
+
const provenance = receipt === null ? {} : extractRunProvenance(receipt);
|
|
14304
13959
|
rows.push({
|
|
14305
13960
|
kind: "run",
|
|
14306
13961
|
runId: envelope.id,
|
|
@@ -14426,7 +14081,7 @@ function attributionWindows(ledger, runSources, sessionIds) {
|
|
|
14426
14081
|
}
|
|
14427
14082
|
const linkedSessions = new Set(sessionIds);
|
|
14428
14083
|
for (const row of ledger.rows) {
|
|
14429
|
-
if (!
|
|
14084
|
+
if (!isRecord11(row)) continue;
|
|
14430
14085
|
const id = readOptionalString2(row.id);
|
|
14431
14086
|
const startedAt = readOptionalString2(row.startedAt);
|
|
14432
14087
|
const sessionId = readOptionalString2(row.sessionId);
|
|
@@ -14767,7 +14422,8 @@ function protectedArtifactsFile(sessionLinks) {
|
|
|
14767
14422
|
function compareProtectedArtifactEvents(left, right) {
|
|
14768
14423
|
return compareCodepoints(left.timestamp, right.timestamp) || compareCodepoints(left.sessionId, right.sessionId) || compareCodepoints(left.turnId, right.turnId) || compareCodepoints(left.artifact.path, right.artifact.path);
|
|
14769
14424
|
}
|
|
14770
|
-
function renderTranscript(overview, runSources, sessionLinks) {
|
|
14425
|
+
function renderTranscript(overview, runSources, sessionLinks, trustStatus) {
|
|
14426
|
+
const trustByRun = new Map(trustStatus.runs.map((entry) => [entry.runId, entry.status]));
|
|
14771
14427
|
const lines = [
|
|
14772
14428
|
`# Evidence ${overview.evidenceId}`,
|
|
14773
14429
|
"",
|
|
@@ -14784,7 +14440,8 @@ function renderTranscript(overview, runSources, sessionLinks) {
|
|
|
14784
14440
|
);
|
|
14785
14441
|
lines.push(` task: ${truncateText(envelope.task, MAX_TASK_CHARS)}`);
|
|
14786
14442
|
if (source.receipt !== null) {
|
|
14787
|
-
|
|
14443
|
+
const status = trustByRun.get(envelope.id);
|
|
14444
|
+
for (const line of provenanceTranscriptLines(extractRunProvenance(source.receipt), status)) {
|
|
14788
14445
|
lines.push(` ${line}`);
|
|
14789
14446
|
}
|
|
14790
14447
|
}
|
|
@@ -14926,6 +14583,37 @@ function renderSessionTranscriptEntry(linked) {
|
|
|
14926
14583
|
const _exhaustive = entry;
|
|
14927
14584
|
return [`${prefix} ${String(_exhaustive)}`];
|
|
14928
14585
|
}
|
|
14586
|
+
function axisFindings(offset, source, status) {
|
|
14587
|
+
const out = [];
|
|
14588
|
+
const runId = source.envelope.id;
|
|
14589
|
+
const next = (severity, tag, message) => {
|
|
14590
|
+
out.push(finding(offset + out.length, severity, tag, runId, message));
|
|
14591
|
+
};
|
|
14592
|
+
const review = status.independentReview.state;
|
|
14593
|
+
if (review === "failed") {
|
|
14594
|
+
next("warn", "independent-review", "independent review failed for this run");
|
|
14595
|
+
} else if (review === "not_independent") {
|
|
14596
|
+
next("warn", "independent-review", "review was not independent of the run it judged");
|
|
14597
|
+
} else if (review === "inconclusive") {
|
|
14598
|
+
next("info", "independent-review", "independent review was inconclusive");
|
|
14599
|
+
} else if (isSuccessfulRun(source) && (review === "absent" || review === "unknown")) {
|
|
14600
|
+
next("info", "independent-review", "run was not independently reviewed; its result rests on its own receipt");
|
|
14601
|
+
}
|
|
14602
|
+
if (status.contextProvenance.state === "invalid") {
|
|
14603
|
+
next("warn", "context-provenance", "context provenance record is contradictory; see trust-status.json");
|
|
14604
|
+
}
|
|
14605
|
+
const completion = status.completionEvidence.state;
|
|
14606
|
+
if (completion === "incomplete") {
|
|
14607
|
+
next(
|
|
14608
|
+
"warn",
|
|
14609
|
+
"completion-evidence",
|
|
14610
|
+
"run mutated the workspace and finished without validation evidence at the completion boundary"
|
|
14611
|
+
);
|
|
14612
|
+
} else if (completion === "limited") {
|
|
14613
|
+
next("info", "completion-evidence", "run finished with an explicit limitation instead of validation evidence");
|
|
14614
|
+
}
|
|
14615
|
+
return out;
|
|
14616
|
+
}
|
|
14929
14617
|
function renderFindings(findings) {
|
|
14930
14618
|
if (findings.length === 0) return "# Findings\n\nNo findings.\n";
|
|
14931
14619
|
const lines = ["# Findings", ""];
|
|
@@ -14953,7 +14641,7 @@ async function readRunLedger(stateDir) {
|
|
|
14953
14641
|
}
|
|
14954
14642
|
function selectRunEnvelopes(ledger, source) {
|
|
14955
14643
|
return ledger.rows.flatMap((entry, index) => {
|
|
14956
|
-
if (!
|
|
14644
|
+
if (!isRecord11(entry)) return [];
|
|
14957
14645
|
const selected = source.kind === "run" ? entry.id === source.runId : entry.sessionId === source.sessionId;
|
|
14958
14646
|
return selected ? [parseRunEnvelope(entry, `${ledger.path}[${index}]`)] : [];
|
|
14959
14647
|
});
|
|
@@ -14983,6 +14671,7 @@ async function readReceipt(stateDir, envelope) {
|
|
|
14983
14671
|
}
|
|
14984
14672
|
const integrity = inspectRunReceiptTrustStatus(receipt, envelope).integrity;
|
|
14985
14673
|
if (!integrity.ok) {
|
|
14674
|
+
if (integrity.retired !== void 0) return { receipt, error: integrity.reason, integrityFailed: false };
|
|
14986
14675
|
return { receipt, error: `receipt integrity: ${integrity.reason}`, integrityFailed: true };
|
|
14987
14676
|
}
|
|
14988
14677
|
return { receipt, error: null, integrityFailed: false };
|
|
@@ -14993,7 +14682,7 @@ function readExecutionRole(value, source) {
|
|
|
14993
14682
|
return role;
|
|
14994
14683
|
}
|
|
14995
14684
|
function parseRunEnvelope(value, source) {
|
|
14996
|
-
if (!
|
|
14685
|
+
if (!isRecord11(value)) throw new Error(`${source}: expected object`);
|
|
14997
14686
|
const reasoningTokenCount = readOptionalNumber2(value, source, "reasoningTokenCount");
|
|
14998
14687
|
return {
|
|
14999
14688
|
...value,
|
|
@@ -15020,9 +14709,9 @@ function parseRunEnvelope(value, source) {
|
|
|
15020
14709
|
};
|
|
15021
14710
|
}
|
|
15022
14711
|
function parseRunReceipt(value, source) {
|
|
15023
|
-
if (!
|
|
14712
|
+
if (!isRecord11(value)) throw new Error(`${source}: expected object`);
|
|
15024
14713
|
const integrity = value.integrity;
|
|
15025
|
-
if (!
|
|
14714
|
+
if (!isRecord11(integrity)) throw new Error(`${source}.integrity: expected object`);
|
|
15026
14715
|
const reasoningTokenCount = readOptionalNumber2(value, source, "reasoningTokenCount");
|
|
15027
14716
|
const failureMessage = readOptionalString2(value.failureMessage);
|
|
15028
14717
|
return {
|
|
@@ -15062,7 +14751,7 @@ function readToolStats(record, source, field) {
|
|
|
15062
14751
|
if (!Array.isArray(value)) throw new Error(`${source}.${field}: expected array`);
|
|
15063
14752
|
return value.map((entry, index) => {
|
|
15064
14753
|
const itemSource = `${source}.${field}[${index}]`;
|
|
15065
|
-
if (!
|
|
14754
|
+
if (!isRecord11(entry)) throw new Error(`${itemSource}: expected object`);
|
|
15066
14755
|
return {
|
|
15067
14756
|
tool: readString2(entry, itemSource, "tool"),
|
|
15068
14757
|
count: readNumber2(entry, itemSource, "count"),
|
|
@@ -15127,11 +14816,11 @@ function parseJson2(raw, source) {
|
|
|
15127
14816
|
throw new Error(`${source}: invalid JSON: ${message}`);
|
|
15128
14817
|
}
|
|
15129
14818
|
}
|
|
15130
|
-
function
|
|
14819
|
+
function isRecord11(value) {
|
|
15131
14820
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15132
14821
|
}
|
|
15133
14822
|
function payloadObject(payload) {
|
|
15134
|
-
return
|
|
14823
|
+
return isRecord11(payload) ? payload : null;
|
|
15135
14824
|
}
|
|
15136
14825
|
function parseMaybeJson(value) {
|
|
15137
14826
|
if (typeof value !== "string") return value;
|
|
@@ -15148,7 +14837,7 @@ function firstContentBlock(payload, type) {
|
|
|
15148
14837
|
const content = obj?.content;
|
|
15149
14838
|
if (!Array.isArray(content)) return null;
|
|
15150
14839
|
for (const block of content) {
|
|
15151
|
-
if (!
|
|
14840
|
+
if (!isRecord11(block)) continue;
|
|
15152
14841
|
if (block.type === type) return block;
|
|
15153
14842
|
}
|
|
15154
14843
|
return null;
|
|
@@ -15161,7 +14850,7 @@ function extractTextFromPayload(payload) {
|
|
|
15161
14850
|
if (Array.isArray(obj.content)) {
|
|
15162
14851
|
const parts = [];
|
|
15163
14852
|
for (const block of obj.content) {
|
|
15164
|
-
if (!
|
|
14853
|
+
if (!isRecord11(block)) continue;
|
|
15165
14854
|
if (block.type === "text" && typeof block.text === "string") parts.push(block.text);
|
|
15166
14855
|
}
|
|
15167
14856
|
return parts.join("\n");
|
|
@@ -15617,7 +15306,7 @@ async function readRunLedger2(stateDir) {
|
|
|
15617
15306
|
try {
|
|
15618
15307
|
const raw = await readFile3(join18(stateDir, "runs.json"), "utf8");
|
|
15619
15308
|
const parsed = JSON.parse(raw);
|
|
15620
|
-
return Array.isArray(parsed) ? parsed.filter(
|
|
15309
|
+
return Array.isArray(parsed) ? parsed.filter(isRecord12) : [];
|
|
15621
15310
|
} catch {
|
|
15622
15311
|
return [];
|
|
15623
15312
|
}
|
|
@@ -15629,7 +15318,7 @@ async function readReceiptForRun(stateDir, envelope) {
|
|
|
15629
15318
|
const path2 = envelope.receiptPath ?? join18(stateDir, "receipts", `${envelope.id}.json`);
|
|
15630
15319
|
try {
|
|
15631
15320
|
const parsed = JSON.parse(await readFile3(path2, "utf8"));
|
|
15632
|
-
return
|
|
15321
|
+
return isRecord12(parsed) ? parsed : null;
|
|
15633
15322
|
} catch {
|
|
15634
15323
|
return null;
|
|
15635
15324
|
}
|
|
@@ -15644,7 +15333,7 @@ async function countSessionEntries(stateDir, sessionIds) {
|
|
|
15644
15333
|
count += raw.split("\n").filter((line) => line.trim().length > 0).filter((line) => {
|
|
15645
15334
|
try {
|
|
15646
15335
|
const parsed = JSON.parse(line);
|
|
15647
|
-
return
|
|
15336
|
+
return isRecord12(parsed) && parsed.type !== "session";
|
|
15648
15337
|
} catch {
|
|
15649
15338
|
return false;
|
|
15650
15339
|
}
|
|
@@ -15693,7 +15382,7 @@ async function linkedEvalAuditRows(stateDir, runIds, artifact) {
|
|
|
15693
15382
|
} catch {
|
|
15694
15383
|
continue;
|
|
15695
15384
|
}
|
|
15696
|
-
if (!
|
|
15385
|
+
if (!isRecord12(parsed)) continue;
|
|
15697
15386
|
const directRunId = typeof parsed.runId === "string" ? parsed.runId : null;
|
|
15698
15387
|
if (directRunId !== null && runIds.has(directRunId)) {
|
|
15699
15388
|
rows.push(evalAuditRow(parsed, directRunId, "run-id", "exact", ["audit runId matched nested eval run"]));
|
|
@@ -15764,7 +15453,7 @@ function sanitizeEvidenceId2(value) {
|
|
|
15764
15453
|
const sanitized = value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
15765
15454
|
return sanitized.length === 0 ? "unknown" : sanitized;
|
|
15766
15455
|
}
|
|
15767
|
-
function
|
|
15456
|
+
function isRecord12(value) {
|
|
15768
15457
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15769
15458
|
}
|
|
15770
15459
|
|
|
@@ -15936,6 +15625,7 @@ export {
|
|
|
15936
15625
|
openAgentLedger,
|
|
15937
15626
|
renderAgentLedgerBoard,
|
|
15938
15627
|
closeAgentLedger,
|
|
15628
|
+
renderDispatchReviewerTask,
|
|
15939
15629
|
createRunReceiptQuality,
|
|
15940
15630
|
UNVERIFIABLE_RECEIPT_VERIFICATION,
|
|
15941
15631
|
decideReviewGate,
|
|
@@ -15959,8 +15649,6 @@ export {
|
|
|
15959
15649
|
extractRunProvenance,
|
|
15960
15650
|
provenanceTranscriptLines,
|
|
15961
15651
|
provenanceCompactSuffix,
|
|
15962
|
-
adaptRunReceiptTrustStatus,
|
|
15963
|
-
inspectRunReceiptTrustStatus,
|
|
15964
15652
|
FAILURE_CAUSE_TAGS,
|
|
15965
15653
|
evidenceDirectory,
|
|
15966
15654
|
EvidenceNotFoundError,
|
|
@@ -15971,4 +15659,4 @@ export {
|
|
|
15971
15659
|
summarizeEvalResults,
|
|
15972
15660
|
buildEvalEvidence
|
|
15973
15661
|
};
|
|
15974
|
-
//# sourceMappingURL=chunk-
|
|
15662
|
+
//# sourceMappingURL=chunk-TLQJPP24.js.map
|