blun-king-cli 9.1.643 → 9.1.644

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/LIESMICH.txt +18 -0
  2. package/README.md +20 -6
  3. package/bin/blun.js +3 -3
  4. package/bin/king.js +3 -3
  5. package/bin/launcher-mode.js +125 -126
  6. package/bin/launcher-runtime.js +603 -616
  7. package/bin/plugin-bootstrap.js +339 -405
  8. package/bin/rename-private-staging.cjs +2 -2
  9. package/bin/retired-bundled-plugins.cjs +84 -0
  10. package/bin/startup-security-host.cjs +105 -0
  11. package/bin/startup-security.cjs +9 -105
  12. package/bin/startup-warning-policy.cjs +22 -0
  13. package/bin/update-lease-installer.cjs +125 -0
  14. package/bin/update-lease-sockets.cjs +228 -0
  15. package/bin/update-lease.js +22 -327
  16. package/bin/verify-bundled-agent-sources.cjs +2 -4
  17. package/blun.mjs +18 -179
  18. package/bundled-agent-sources.json +1 -552
  19. package/package.json +1 -5
  20. package/tool-liveness642/receipt.json +1 -1
  21. package/worker-host.mjs +3 -119
  22. package/agent-spine-plugin/.claude-plugin/marketplace.json +0 -20
  23. package/agent-spine-plugin/.claude-plugin/plugin.json +0 -14
  24. package/agent-spine-plugin/.codex-plugin/plugin.json +0 -47
  25. package/agent-spine-plugin/.mcp.json +0 -8
  26. package/agent-spine-plugin/CHANGELOG.md +0 -1614
  27. package/agent-spine-plugin/LICENSE +0 -186
  28. package/agent-spine-plugin/README.md +0 -432
  29. package/agent-spine-plugin/assets/agentspine-banner.svg +0 -32
  30. package/agent-spine-plugin/bin/agentspine-mcp.js +0 -4
  31. package/agent-spine-plugin/bin/agentspine.js +0 -7
  32. package/agent-spine-plugin/blun.plugin.json +0 -68
  33. package/agent-spine-plugin/docs/acceptance.md +0 -61
  34. package/agent-spine-plugin/docs/artifact-evaluation.md +0 -93
  35. package/agent-spine-plugin/docs/host-integration.md +0 -193
  36. package/agent-spine-plugin/docs/preflight-recall.md +0 -71
  37. package/agent-spine-plugin/docs/preservation-contract.md +0 -53
  38. package/agent-spine-plugin/docs/quality-gates.md +0 -50
  39. package/agent-spine-plugin/docs/session-timeline.md +0 -112
  40. package/agent-spine-plugin/docs/source-roots.md +0 -113
  41. package/agent-spine-plugin/docs/world-model.md +0 -119
  42. package/agent-spine-plugin/hooks/codex.json +0 -47
  43. package/agent-spine-plugin/hooks/hooks.json +0 -106
  44. package/agent-spine-plugin/hooks/version.json +0 -5
  45. package/agent-spine-plugin/package.json +0 -77
  46. package/agent-spine-plugin/scripts/check-codex-install.js +0 -226
  47. package/agent-spine-plugin/scripts/check-hosts.js +0 -208
  48. package/agent-spine-plugin/scripts/check-install-hook.js +0 -227
  49. package/agent-spine-plugin/scripts/check-install-selfstarter.js +0 -154
  50. package/agent-spine-plugin/scripts/check-install.js +0 -478
  51. package/agent-spine-plugin/scripts/check-line-budget.js +0 -58
  52. package/agent-spine-plugin/scripts/check-syntax.js +0 -29
  53. package/agent-spine-plugin/scripts/github-actions.js +0 -11
  54. package/agent-spine-plugin/scripts/hermetic-process.js +0 -191
  55. package/agent-spine-plugin/scripts/release-check.js +0 -150
  56. package/agent-spine-plugin/scripts/run-acceptance.js +0 -19
  57. package/agent-spine-plugin/scripts/run-checks.js +0 -50
  58. package/agent-spine-plugin/scripts/run-tests-hermetic.js +0 -112
  59. package/agent-spine-plugin/skills/agent-spine/SKILL.md +0 -99
  60. package/agent-spine-plugin/spine-example/1-identity.md +0 -12
  61. package/agent-spine-plugin/spine-example/2-voice.md +0 -6
  62. package/agent-spine-plugin/spine-example/3-conduct.md +0 -8
  63. package/agent-spine-plugin/spine-example/4-history.md +0 -4
  64. package/agent-spine-plugin/src/cli-agent.js +0 -315
  65. package/agent-spine-plugin/src/cli-attention.js +0 -95
  66. package/agent-spine-plugin/src/cli-autonomy.js +0 -36
  67. package/agent-spine-plugin/src/cli-common.js +0 -71
  68. package/agent-spine-plugin/src/cli-continuity.js +0 -116
  69. package/agent-spine-plugin/src/cli-core.js +0 -128
  70. package/agent-spine-plugin/src/cli-diagnostics.js +0 -291
  71. package/agent-spine-plugin/src/cli-host.js +0 -21
  72. package/agent-spine-plugin/src/cli-learning.js +0 -320
  73. package/agent-spine-plugin/src/cli-premortem.js +0 -16
  74. package/agent-spine-plugin/src/cli-sharing.js +0 -230
  75. package/agent-spine-plugin/src/cli.js +0 -181
  76. package/agent-spine-plugin/src/codex-reader-launcher.js +0 -182
  77. package/agent-spine-plugin/src/hook.js +0 -500
  78. package/agent-spine-plugin/src/index.js +0 -108
  79. package/agent-spine-plugin/src/lib/acceptance.js +0 -435
  80. package/agent-spine-plugin/src/lib/action-lesson-recall.js +0 -118
  81. package/agent-spine-plugin/src/lib/attention-context.js +0 -167
  82. package/agent-spine-plugin/src/lib/attention-events.js +0 -113
  83. package/agent-spine-plugin/src/lib/attention-privacy.js +0 -72
  84. package/agent-spine-plugin/src/lib/attention-schema.js +0 -164
  85. package/agent-spine-plugin/src/lib/attention-storage.js +0 -93
  86. package/agent-spine-plugin/src/lib/attention.js +0 -164
  87. package/agent-spine-plugin/src/lib/audit-premortem.js +0 -223
  88. package/agent-spine-plugin/src/lib/audit.js +0 -401
  89. package/agent-spine-plugin/src/lib/authentication.js +0 -515
  90. package/agent-spine-plugin/src/lib/autonomy-policy.js +0 -110
  91. package/agent-spine-plugin/src/lib/autonomy-store.js +0 -202
  92. package/agent-spine-plugin/src/lib/autonomy.js +0 -8
  93. package/agent-spine-plugin/src/lib/briefing.js +0 -493
  94. package/agent-spine-plugin/src/lib/catalog-document-read.js +0 -51
  95. package/agent-spine-plugin/src/lib/catalog.js +0 -167
  96. package/agent-spine-plugin/src/lib/channel-continuity.js +0 -19
  97. package/agent-spine-plugin/src/lib/channel-runtime.js +0 -665
  98. package/agent-spine-plugin/src/lib/codex-installation.js +0 -231
  99. package/agent-spine-plugin/src/lib/codex-skill-installation.js +0 -211
  100. package/agent-spine-plugin/src/lib/context.js +0 -156
  101. package/agent-spine-plugin/src/lib/continuity.js +0 -338
  102. package/agent-spine-plugin/src/lib/coordination.js +0 -577
  103. package/agent-spine-plugin/src/lib/delivery-agent-usage.js +0 -231
  104. package/agent-spine-plugin/src/lib/delivery-assignment.js +0 -220
  105. package/agent-spine-plugin/src/lib/delivery-command-actions.js +0 -462
  106. package/agent-spine-plugin/src/lib/delivery-knowledge.js +0 -78
  107. package/agent-spine-plugin/src/lib/delivery-premortem-binding.js +0 -107
  108. package/agent-spine-plugin/src/lib/delivery-premortem-closure.js +0 -171
  109. package/agent-spine-plugin/src/lib/delivery-premortem-codec.js +0 -45
  110. package/agent-spine-plugin/src/lib/delivery-premortem-correction.js +0 -101
  111. package/agent-spine-plugin/src/lib/delivery-premortem-file.js +0 -21
  112. package/agent-spine-plugin/src/lib/delivery-premortem-index.js +0 -493
  113. package/agent-spine-plugin/src/lib/delivery-premortem-inspection.js +0 -37
  114. package/agent-spine-plugin/src/lib/delivery-premortem-recovery.js +0 -120
  115. package/agent-spine-plugin/src/lib/delivery-premortem-rejection.js +0 -65
  116. package/agent-spine-plugin/src/lib/delivery-premortem-results.js +0 -28
  117. package/agent-spine-plugin/src/lib/delivery-premortem-session-guard.js +0 -46
  118. package/agent-spine-plugin/src/lib/delivery-premortem-write-ledger.js +0 -285
  119. package/agent-spine-plugin/src/lib/delivery-premortem.js +0 -499
  120. package/agent-spine-plugin/src/lib/delivery-shell-heredoc.js +0 -115
  121. package/agent-spine-plugin/src/lib/delivery-shell-substitutions.js +0 -111
  122. package/agent-spine-plugin/src/lib/delivery-shell-wrapper.js +0 -64
  123. package/agent-spine-plugin/src/lib/delivery-target.js +0 -73
  124. package/agent-spine-plugin/src/lib/delivery-verification.js +0 -445
  125. package/agent-spine-plugin/src/lib/documents.js +0 -239
  126. package/agent-spine-plugin/src/lib/feed-transport.js +0 -499
  127. package/agent-spine-plugin/src/lib/filesystem-retry.js +0 -34
  128. package/agent-spine-plugin/src/lib/gateway-common.js +0 -68
  129. package/agent-spine-plugin/src/lib/gateway-control.js +0 -370
  130. package/agent-spine-plugin/src/lib/gateway-delivery.js +0 -103
  131. package/agent-spine-plugin/src/lib/gateway-execution.js +0 -350
  132. package/agent-spine-plugin/src/lib/gateway-group-response.js +0 -128
  133. package/agent-spine-plugin/src/lib/gateway-host-fencing.js +0 -92
  134. package/agent-spine-plugin/src/lib/gateway-host-lifecycle.js +0 -193
  135. package/agent-spine-plugin/src/lib/gateway-inspection.js +0 -85
  136. package/agent-spine-plugin/src/lib/gateway-knowledge.js +0 -129
  137. package/agent-spine-plugin/src/lib/gateway-policy-provenance.js +0 -197
  138. package/agent-spine-plugin/src/lib/gateway-premortem-disposition.js +0 -82
  139. package/agent-spine-plugin/src/lib/gateway-premortem.js +0 -363
  140. package/agent-spine-plugin/src/lib/gateway-prepared-host.js +0 -28
  141. package/agent-spine-plugin/src/lib/gateway-runs.js +0 -345
  142. package/agent-spine-plugin/src/lib/gateway-runtime-identity.js +0 -31
  143. package/agent-spine-plugin/src/lib/gateway-runtime-records.js +0 -21
  144. package/agent-spine-plugin/src/lib/gateway-runtime.js +0 -18
  145. package/agent-spine-plugin/src/lib/gateway-state-transaction.js +0 -356
  146. package/agent-spine-plugin/src/lib/gateway-state.js +0 -344
  147. package/agent-spine-plugin/src/lib/graph.js +0 -337
  148. package/agent-spine-plugin/src/lib/hook-artifact-guards.js +0 -356
  149. package/agent-spine-plugin/src/lib/hook-audit.js +0 -43
  150. package/agent-spine-plugin/src/lib/hook-briefing-use.js +0 -78
  151. package/agent-spine-plugin/src/lib/hook-context.js +0 -441
  152. package/agent-spine-plugin/src/lib/hook-final-message.js +0 -26
  153. package/agent-spine-plugin/src/lib/hook-input.js +0 -27
  154. package/agent-spine-plugin/src/lib/hook-output.js +0 -284
  155. package/agent-spine-plugin/src/lib/hook-premortem.js +0 -257
  156. package/agent-spine-plugin/src/lib/hook-process-advisory.js +0 -36
  157. package/agent-spine-plugin/src/lib/hook-protection.js +0 -95
  158. package/agent-spine-plugin/src/lib/hook-stop-verification.js +0 -84
  159. package/agent-spine-plugin/src/lib/hook-timeline.js +0 -102
  160. package/agent-spine-plugin/src/lib/host-instruction-budget.js +0 -11
  161. package/agent-spine-plugin/src/lib/https-transport.js +0 -392
  162. package/agent-spine-plugin/src/lib/identifier-analysis.js +0 -446
  163. package/agent-spine-plugin/src/lib/indexed-memory-offline.js +0 -40
  164. package/agent-spine-plugin/src/lib/indexed-memory.js +0 -298
  165. package/agent-spine-plugin/src/lib/knowledge-evidence.js +0 -431
  166. package/agent-spine-plugin/src/lib/learning-applications.js +0 -441
  167. package/agent-spine-plugin/src/lib/learning-artifact-evaluator.js +0 -114
  168. package/agent-spine-plugin/src/lib/learning-candidates.js +0 -274
  169. package/agent-spine-plugin/src/lib/learning-context.js +0 -137
  170. package/agent-spine-plugin/src/lib/learning-delivery-contracts.js +0 -310
  171. package/agent-spine-plugin/src/lib/learning-evaluation-contracts.js +0 -350
  172. package/agent-spine-plugin/src/lib/learning-evaluation-registration.js +0 -372
  173. package/agent-spine-plugin/src/lib/learning-evaluation-revocation.js +0 -292
  174. package/agent-spine-plugin/src/lib/learning-evidence-contracts.js +0 -321
  175. package/agent-spine-plugin/src/lib/learning-findings.js +0 -458
  176. package/agent-spine-plugin/src/lib/learning-measurement-contracts.js +0 -285
  177. package/agent-spine-plugin/src/lib/learning-measurements.js +0 -265
  178. package/agent-spine-plugin/src/lib/learning-outcome-contracts.js +0 -165
  179. package/agent-spine-plugin/src/lib/learning-outcomes.js +0 -343
  180. package/agent-spine-plugin/src/lib/learning-reconciliation.js +0 -290
  181. package/agent-spine-plugin/src/lib/learning-retry-contracts.js +0 -188
  182. package/agent-spine-plugin/src/lib/learning-schema.js +0 -229
  183. package/agent-spine-plugin/src/lib/learning-scope-targets.js +0 -424
  184. package/agent-spine-plugin/src/lib/learning-state-upgrade.js +0 -477
  185. package/agent-spine-plugin/src/lib/learning-status-configuration.js +0 -476
  186. package/agent-spine-plugin/src/lib/learning-storage.js +0 -203
  187. package/agent-spine-plugin/src/lib/learning-trial-recovery.js +0 -218
  188. package/agent-spine-plugin/src/lib/learning-validation-contracts.js +0 -375
  189. package/agent-spine-plugin/src/lib/learning-validation-renewal.js +0 -298
  190. package/agent-spine-plugin/src/lib/learning-validation-runtime.js +0 -234
  191. package/agent-spine-plugin/src/lib/learning.js +0 -36
  192. package/agent-spine-plugin/src/lib/lesson-recall-session.js +0 -172
  193. package/agent-spine-plugin/src/lib/mcp-autonomy-tools.js +0 -37
  194. package/agent-spine-plugin/src/lib/mcp-delivery-completion.js +0 -124
  195. package/agent-spine-plugin/src/lib/mcp-delivery-tools.js +0 -45
  196. package/agent-spine-plugin/src/lib/mcp-premortem.js +0 -68
  197. package/agent-spine-plugin/src/lib/mcp-runtime.js +0 -355
  198. package/agent-spine-plugin/src/lib/mcp-source-context.js +0 -61
  199. package/agent-spine-plugin/src/lib/mcp-timeline-tools.js +0 -240
  200. package/agent-spine-plugin/src/lib/mcp-world-tools.js +0 -52
  201. package/agent-spine-plugin/src/lib/object-transport.js +0 -206
  202. package/agent-spine-plugin/src/lib/owned-file-lock.js +0 -182
  203. package/agent-spine-plugin/src/lib/paths.js +0 -109
  204. package/agent-spine-plugin/src/lib/peer-transport.js +0 -283
  205. package/agent-spine-plugin/src/lib/persona-runtime.js +0 -581
  206. package/agent-spine-plugin/src/lib/pre-answer-timeline-recall.js +0 -104
  207. package/agent-spine-plugin/src/lib/preflight-delivery-id.js +0 -27
  208. package/agent-spine-plugin/src/lib/preflight.js +0 -688
  209. package/agent-spine-plugin/src/lib/project-portfolio.js +0 -176
  210. package/agent-spine-plugin/src/lib/runtime.js +0 -13
  211. package/agent-spine-plugin/src/lib/selfstarter-core.js +0 -382
  212. package/agent-spine-plugin/src/lib/selfstarter-jobs.js +0 -149
  213. package/agent-spine-plugin/src/lib/selfstarter-lease.js +0 -204
  214. package/agent-spine-plugin/src/lib/selfstarter-policy.js +0 -90
  215. package/agent-spine-plugin/src/lib/selfstarter-workspace.js +0 -111
  216. package/agent-spine-plugin/src/lib/selfstarter.js +0 -11
  217. package/agent-spine-plugin/src/lib/session-timeline-auth.js +0 -316
  218. package/agent-spine-plugin/src/lib/session-timeline-codex.js +0 -69
  219. package/agent-spine-plugin/src/lib/session-timeline-contract.js +0 -56
  220. package/agent-spine-plugin/src/lib/session-timeline-enrollment-source.js +0 -38
  221. package/agent-spine-plugin/src/lib/session-timeline-enrollment-storage.js +0 -128
  222. package/agent-spine-plugin/src/lib/session-timeline-enrollment-transport.js +0 -15
  223. package/agent-spine-plugin/src/lib/session-timeline-enrollment.js +0 -478
  224. package/agent-spine-plugin/src/lib/session-timeline-event-extract.js +0 -186
  225. package/agent-spine-plugin/src/lib/session-timeline-host-origin.js +0 -73
  226. package/agent-spine-plugin/src/lib/session-timeline-host-receipt.js +0 -117
  227. package/agent-spine-plugin/src/lib/session-timeline-invocation.js +0 -201
  228. package/agent-spine-plugin/src/lib/session-timeline-king.js +0 -93
  229. package/agent-spine-plugin/src/lib/session-timeline-prior.js +0 -57
  230. package/agent-spine-plugin/src/lib/session-timeline-provider.js +0 -36
  231. package/agent-spine-plugin/src/lib/session-timeline-query.js +0 -56
  232. package/agent-spine-plugin/src/lib/session-timeline-results.js +0 -56
  233. package/agent-spine-plugin/src/lib/session-timeline-root.js +0 -11
  234. package/agent-spine-plugin/src/lib/session-timeline-search.js +0 -82
  235. package/agent-spine-plugin/src/lib/session-timeline-sid-acl.js +0 -213
  236. package/agent-spine-plugin/src/lib/session-timeline-source-open.js +0 -30
  237. package/agent-spine-plugin/src/lib/session-timeline-source.js +0 -80
  238. package/agent-spine-plugin/src/lib/session-timeline-state.js +0 -45
  239. package/agent-spine-plugin/src/lib/session-timeline-transport.js +0 -42
  240. package/agent-spine-plugin/src/lib/session-timeline-windows-acl.js +0 -145
  241. package/agent-spine-plugin/src/lib/session-timeline.js +0 -462
  242. package/agent-spine-plugin/src/lib/sharing.js +0 -969
  243. package/agent-spine-plugin/src/lib/source-roots.js +0 -475
  244. package/agent-spine-plugin/src/lib/source-tree-scan.js +0 -178
  245. package/agent-spine-plugin/src/lib/sqlite-transport.js +0 -501
  246. package/agent-spine-plugin/src/lib/task-knowledge-context.js +0 -99
  247. package/agent-spine-plugin/src/lib/telegram-adapter.js +0 -119
  248. package/agent-spine-plugin/src/lib/timeline-continuation-update.js +0 -100
  249. package/agent-spine-plugin/src/lib/timeline-tool-guard.js +0 -225
  250. package/agent-spine-plugin/src/lib/timeline-user-feedback.js +0 -216
  251. package/agent-spine-plugin/src/lib/timeline-world-capture.js +0 -233
  252. package/agent-spine-plugin/src/lib/voice-runtime.js +0 -39
  253. package/agent-spine-plugin/src/lib/world-knowledge.js +0 -306
  254. package/agent-spine-plugin/src/lib/world-model.js +0 -333
  255. package/agent-spine-plugin/src/mcp.js +0 -456
  256. package/agent-spine-plugin/src/version.js +0 -1
  257. package/agent-spine-plugin/src/worker.js +0 -257
  258. package/bin/agentspine-king-goal-inbox.mjs +0 -127
  259. package/bin/agentspine-king-goal-intake.mjs +0 -106
  260. package/bin/agentspine-king-host-runner.mjs +0 -109
  261. package/bin/agentspine-king-snapshot-policy.cjs +0 -80
  262. package/bin/agentspine-king-status-policy.mjs +0 -226
  263. package/bin/agentspine-king-worker-host.mjs +0 -160
  264. package/bin/managed-plugin-selection.cjs +0 -141
  265. package/bin/verify-agent-behavior.cjs +0 -122
  266. package/bin/verify-agent-components.cjs +0 -104
@@ -1,458 +0,0 @@
1
- import {
2
- KINDS, EVIDENCE_TYPES, PRIVACY, STATUSES, AUTO_KINDS, OUTCOME_AUTO_KINDS,
3
- CONTINUITY_AUTO_KINDS, SCOPE_FIELDS, ID_RE, DIGEST_RE, SECRET_RE, AUTHORITY_ASSERTION_RE,
4
- LINEAGE_EVALUATIONS, ROOT_BOUND_EVALUATIONS, REGISTRY_BOUND_EVALUATIONS, TRIAL_RETRY_EVALUATIONS, CANDIDATE_ADMISSION_EVALUATIONS, CANDIDATE_EVIDENCE_LINEAGE_EVALUATIONS,
5
- DELIVERABLE_APPLICATIONS
6
- } from "./learning-schema.js";
7
- import {
8
- validConfig, scopeContains, exactScope, digest, storedEvidenceRevocationStructure, evidenceRevocationMatchesState,
9
- storedOutcomeStructure, storedMeasurementStructure, storedMeasurementRevocationStructure, measurementRevocationMatchesState, revokedMeasurementForCandidate, measurementRunDigest,
10
- evaluatorRootRunDigest, activeEvaluationBinding, storedEvaluationRevocationStructure, evaluationRevocationMatchesState
11
- } from "./learning-scope-targets.js";
12
- import {
13
- revokedEvaluationForCandidate, storedRevalidationWindowStructure, revalidationWindowMatchesState, storedValidationLeaseStructure, validationLeaseMatchesState
14
- } from "./learning-validation-contracts.js";
15
- import {
16
- storedValidationRevocationStructure, validationRevocationMatchesState, revokedValidationForCandidate
17
- } from "./learning-validation-runtime.js";
18
- import {
19
- storedMeasurementLineageStructure, storedEvidenceSourceAttestationRevocationStructure, evidenceSourceAttestationRevocationMatchesState, revokedEvidenceSourceAttestationForCandidate
20
- } from "./learning-measurement-contracts.js";
21
- import {
22
- storedCandidateEvidenceLineageStructure, candidateEvidenceLineageMatchesEvaluation, candidateAdmissionMatches
23
- } from "./learning-evidence-contracts.js";
24
- import {
25
- storedEvaluationStructure, storedApplicationStructure, storedTrialFailureStructure, trialFailureMatchesState, storedTrialFailureRevocationStructure, trialFailureRevocationMatchesState
26
- } from "./learning-evaluation-contracts.js";
27
- import {
28
- trialRetryMatchesState, storedTrialRetryExhaustionStructure, trialRetryExhaustionMatchesState
29
- } from "./learning-retry-contracts.js";
30
- import {
31
- storedDeliveryStructure, storedApplicationRevocationStructure, applicationRevocationMatchesState, revokedApplicationForCandidate, storedDeliveryRevocationStructure, deliveryRevocationMatchesState,
32
- revokedDeliveryForCandidate, storedOutcomeRevocationStructure, outcomeRevocationMatchesState, revokedOutcomeForCandidate
33
- } from "./learning-delivery-contracts.js";
34
- import {
35
- isGroupMember, evidenceConfidence
36
- } from "./learning-storage.js";
37
- import {
38
- distinctEvidence
39
- } from "./learning-candidates.js";
40
-
41
- export function learningFindings(learning, graph) {
42
- const findings = [];
43
- if (!validConfig(learning.config)) findings.push("invalid-config");
44
- const groups = new Set(graph.entities.filter((entity) => entity.kind === "group").map((entity) => entity.id));
45
- for (const candidate of learning.candidates) {
46
- if (!KINDS.has(candidate.kind) || !STATUSES.has(candidate.status) || !PRIVACY.has(candidate.privacy)) findings.push(`invalid-candidate:${candidate.id}`);
47
- const nested = [...(candidate.evidence || []), candidate.review, candidate.rollback, candidate.promotion].filter(Boolean);
48
- if (candidate.authority !== "context-only" || nested.some((item) => item.authority !== "context-only")) findings.push(`authority:${candidate.id}`);
49
- if (SECRET_RE.test(candidate.claim || "") || AUTHORITY_ASSERTION_RE.test(candidate.claim || "")) findings.push(`unsafe-claim:${candidate.id}`);
50
- if (candidate.evidence?.some((item) => SECRET_RE.test(item.summary || ""))) findings.push(`unsafe-evidence:${candidate.id}`);
51
- const evidenceValid = candidate.evidence.length > 0 && candidate.evidence.every((item) => (
52
- ID_RE.test(item.id || "") && EVIDENCE_TYPES.has(item.type)
53
- && typeof item.summary === "string" && item.summary.length > 0
54
- && Number.isFinite(item.confidence) && item.confidence >= 0 && item.confidence <= 1
55
- && Number.isFinite(new Date(item.observedAt).getTime())
56
- && (item.type !== "document" || (item.sourceDocument && /^[a-f0-9]{64}$/.test(item.sourceSha256 || "")))
57
- ));
58
- if (!evidenceValid || !Number.isFinite(candidate.confidence)
59
- || Math.abs(candidate.confidence - evidenceConfidence(candidate.evidence)) > 1e-12) {
60
- findings.push(`invalid-evidence:${candidate.id}`);
61
- }
62
- if (candidate.privacy === "group" && (!groups.has(candidate.groupId) || !isGroupMember(graph, candidate.groupId, candidate.subjectId))) findings.push(`invalid-group:${candidate.id}`);
63
- if (!candidate.scope || Object.keys(candidate.scope).some((field) => !SCOPE_FIELDS.includes(field))
64
- || Object.values(candidate.scope || {}).some((value) => value !== null && !ID_RE.test(value))) findings.push(`invalid-scope:${candidate.id}`);
65
- if (candidate.status === "accepted") {
66
- if ((learning.evidenceRevocations || []).some((receipt) => receipt.learningId === candidate.id)) {
67
- findings.push(`revoked-evidence:${candidate.id}`);
68
- }
69
- if (revokedMeasurementForCandidate(learning, candidate)) findings.push(`revoked-measurement:${candidate.id}`);
70
- if (revokedApplicationForCandidate(learning, candidate)) findings.push(`revoked-application:${candidate.id}`);
71
- if (revokedDeliveryForCandidate(learning, candidate)) findings.push(`revoked-delivery:${candidate.id}`);
72
- if (revokedOutcomeForCandidate(learning, candidate)) findings.push(`revoked-outcome:${candidate.id}`);
73
- const canaryEvaluation = candidate.promotion?.canary?.evaluationId
74
- ? (learning.evaluations || []).find((contract) => contract.id === candidate.promotion.canary.evaluationId)
75
- : null;
76
- const manualProof = candidate.automatic === false
77
- && candidate.review?.decision === "accept" && candidate.review?.confirmedByUser === true;
78
- const automaticProof = candidate.automatic === true
79
- && ((AUTO_KINDS.has(candidate.kind)
80
- && candidate.promotion?.mode === "automatic-low-risk"
81
- && candidate.confidence >= candidate.promotion?.minConfidence
82
- && distinctEvidence(candidate) >= candidate.promotion?.minEvidence
83
- && candidate.promotion?.evidenceCount >= candidate.promotion?.minEvidence)
84
- || (CONTINUITY_AUTO_KINDS.has(candidate.kind)
85
- && candidate.promotion?.mode === "automatic-continuity-low-risk"
86
- && candidate.promotion?.localOptIn === true
87
- && candidate.confidence >= candidate.promotion?.minConfidence
88
- && candidate.promotion?.directness >= candidate.promotion?.minDirectness
89
- && distinctEvidence(candidate) >= candidate.promotion?.minEvidence
90
- && candidate.promotion?.evidenceCount >= candidate.promotion?.minEvidence)
91
- || (OUTCOME_AUTO_KINDS.has(candidate.kind)
92
- && candidate.promotion?.mode === "outcome-canary"
93
- && candidate.requiresLocalReview === false
94
- && ["active", "validated"].includes(candidate.promotion?.canary?.status)
95
- && candidate.confidence >= candidate.promotion?.minConfidence
96
- && distinctEvidence(candidate) >= candidate.promotion?.minEvidence
97
- && candidate.promotion?.canary?.beforeReceipts?.length >= (canaryEvaluation?.thresholds.beforeReceipts
98
- ?? learning.config.minOutcomeReceipts)
99
- && (!candidate.promotion?.canary?.evaluationId
100
- || (canaryEvaluation && canaryEvaluation.digest === candidate.promotion.canary.evaluationDigest))));
101
- if (!candidate.acceptedAt || (!manualProof && !automaticProof)) findings.push(`invalid-acceptance:${candidate.id}`);
102
- if (candidate.promotion?.mode === "outcome-canary" && ["active", "validated"].includes(candidate.promotion?.canary?.status)
103
- && new Date(candidate.promotion.canary.expiresAt).getTime() <= Date.now()) findings.push(`stale-canary:${candidate.id}`);
104
- if (candidate.promotion?.mode === "outcome-canary" && ["active", "validated"].includes(candidate.promotion?.canary?.status)
105
- && REGISTRY_BOUND_EVALUATIONS.has(canaryEvaluation?.schema)
106
- && !activeEvaluationBinding(learning, canaryEvaluation)) findings.push(`inactive-evaluator-canary:${candidate.id}`);
107
- if (revokedEvaluationForCandidate(learning, candidate)) findings.push(`revoked-evaluation:${candidate.id}`);
108
- if (revokedEvidenceSourceAttestationForCandidate(learning, candidate)) {
109
- findings.push(`revoked-evidence-source-attestation:${candidate.id}`);
110
- }
111
- if (revokedValidationForCandidate(learning, candidate)) findings.push(`revoked-validation:${candidate.id}`);
112
- if (candidate.promotion?.mode === "outcome-canary" && candidate.promotion?.canary?.status === "validated"
113
- && REGISTRY_BOUND_EVALUATIONS.has(canaryEvaluation?.schema)
114
- && !(learning.validationLeases || []).some((lease) => lease.id === candidate.promotion.canary.validationLeaseId
115
- && lease.digest === candidate.promotion.canary.validationLeaseDigest
116
- && storedValidationLeaseStructure(lease) && validationLeaseMatchesState(learning, lease))) {
117
- findings.push(`missing-validation-lease:${candidate.id}`);
118
- }
119
- const revalidation = candidate.promotion?.canary?.revalidation;
120
- const predecessorValidation = revalidation ? (learning.validationLeases || []).find((lease) =>
121
- lease.id === revalidation.predecessorValidationId
122
- && lease.digest === revalidation.predecessorValidationDigest && lease.learningId === candidate.id) : null;
123
- const revalidationBaselineReferences = predecessorValidation?.schema === "agentspine.learning-validation/v1"
124
- ? predecessorValidation.beforeOutcomes : predecessorValidation?.baselineOutcomes;
125
- const revalidationRoots = (revalidationBaselineReferences || []).map((reference) =>
126
- (learning.outcomes || []).find((outcome) => outcome.id === reference.id && outcome.digest === reference.digest))
127
- .filter(Boolean).sort((a, b) => a.measurement.evaluatorId.localeCompare(b.measurement.evaluatorId))
128
- .map((outcome) => outcome.measurement.evaluatorRootDigest);
129
- if (revalidation && (candidate.promotion?.canary?.status !== "validated"
130
- || !storedRevalidationWindowStructure(revalidation) || !predecessorValidation
131
- || !revalidationWindowMatchesState(learning, candidate)
132
- || (["agentspine.learning-revalidation-window/v2", "agentspine.learning-revalidation-window/v3",
133
- "agentspine.learning-revalidation-window/v4"]
134
- .includes(revalidation.schema)
135
- && (revalidation.selection.requiredDeliveries !== revalidationRoots.length
136
- || revalidation.selection.evaluatorRoots.some((entry, index) =>
137
- entry.evaluatorRootDigest !== revalidationRoots[index]))))) {
138
- findings.push(`invalid-revalidation:${candidate.id}`);
139
- }
140
- }
141
- }
142
- const outcomeIds = new Set();
143
- for (const receipt of learning.outcomes || []) {
144
- const candidate = learning.candidates.find((item) => item.id === receipt.learningId);
145
- const valid = storedOutcomeStructure(receipt) && candidate && scopeContains(candidate.scope, receipt.scope);
146
- if (!valid || outcomeIds.has(receipt.id)) findings.push(`invalid-outcome:${receipt.id || "unknown"}`);
147
- outcomeIds.add(receipt.id);
148
- }
149
- const evaluationIds = new Set();
150
- for (const contract of learning.evaluations || []) {
151
- const candidate = learning.candidates.find((item) => item.id === contract.learningId);
152
- const valid = storedEvaluationStructure(contract) && candidate && scopeContains(candidate.scope, contract.scope)
153
- && (!CANDIDATE_ADMISSION_EVALUATIONS.has(contract.schema)
154
- || candidateAdmissionMatches(contract, candidate));
155
- if (!valid || evaluationIds.has(contract.id)) findings.push(`invalid-evaluation:${contract.id || "unknown"}`);
156
- if (REGISTRY_BOUND_EVALUATIONS.has(contract.schema)) {
157
- const binding = (learning.evaluationBindings || []).find((entry) => entry.evaluationId === contract.id);
158
- if (!binding || binding.evaluationDigest !== contract.digest) findings.push(`invalid-evaluator-binding:${contract.id}`);
159
- }
160
- evaluationIds.add(contract.id);
161
- }
162
- const candidateEvidenceDigests = new Set();
163
- const candidateEvidenceIndependence = new Set();
164
- for (const lineage of learning.candidateEvidenceLineage || []) {
165
- const evidenceKey = `${lineage.scopeDigest}\0${lineage.evidenceDigest}`;
166
- const independenceKey = `${lineage.scopeDigest}\0${lineage.independenceDigest}`;
167
- const valid = storedCandidateEvidenceLineageStructure(lineage);
168
- if (!valid || candidateEvidenceDigests.has(evidenceKey)
169
- || candidateEvidenceIndependence.has(independenceKey)) {
170
- findings.push(`invalid-candidate-evidence-lineage:${lineage.evaluationId || "unknown"}`);
171
- }
172
- candidateEvidenceDigests.add(evidenceKey);
173
- candidateEvidenceIndependence.add(independenceKey);
174
- }
175
- for (const contract of (learning.evaluations || [])
176
- .filter((entry) => CANDIDATE_EVIDENCE_LINEAGE_EVALUATIONS.has(entry.schema))) {
177
- if (!candidateEvidenceLineageMatchesEvaluation(learning, contract)) {
178
- findings.push(`invalid-candidate-evidence-lineage-binding:${contract.id || "unknown"}`);
179
- }
180
- }
181
- const validationLeaseIds = new Set();
182
- const validatedLearningIds = new Set();
183
- for (const lease of learning.validationLeases || []) {
184
- const valid = storedValidationLeaseStructure(lease) && validationLeaseMatchesState(learning, lease);
185
- if (!valid || validationLeaseIds.has(lease.id) || validatedLearningIds.has(lease.learningId)) {
186
- findings.push(`invalid-validation-lease:${lease.id || "unknown"}`);
187
- }
188
- validationLeaseIds.add(lease.id);
189
- validatedLearningIds.add(lease.learningId);
190
- }
191
- const trialFailureIds = new Set();
192
- const failedApplications = new Set();
193
- for (const receipt of learning.trialFailures || []) {
194
- const valid = storedTrialFailureStructure(receipt) && trialFailureMatchesState(learning, receipt);
195
- if (!valid || trialFailureIds.has(receipt.id) || failedApplications.has(receipt.applicationId)) {
196
- findings.push(`invalid-trial-failure:${receipt.id || "unknown"}`);
197
- }
198
- trialFailureIds.add(receipt.id);
199
- failedApplications.add(receipt.applicationId);
200
- }
201
- const trialFailureRevocationIds = new Set();
202
- const revokedTrialFailureIds = new Set();
203
- for (const receipt of learning.trialFailureRevocations || []) {
204
- const valid = storedTrialFailureRevocationStructure(receipt)
205
- && trialFailureRevocationMatchesState(learning, receipt);
206
- if (!valid || trialFailureRevocationIds.has(receipt.id)
207
- || revokedTrialFailureIds.has(receipt.trialFailureId)) {
208
- findings.push(`invalid-trial-failure-revocation:${receipt.id || "unknown"}`);
209
- }
210
- trialFailureRevocationIds.add(receipt.id);
211
- revokedTrialFailureIds.add(receipt.trialFailureId);
212
- }
213
- const retryRevocationIds = new Set();
214
- for (const contract of (learning.evaluations || []).filter((entry) => TRIAL_RETRY_EVALUATIONS.has(entry.schema))) {
215
- if (!trialRetryMatchesState(learning, contract)
216
- || retryRevocationIds.has(contract.retry?.trialFailureRevocationId)) {
217
- findings.push(`invalid-trial-retry:${contract.id || "unknown"}`);
218
- }
219
- retryRevocationIds.add(contract.retry?.trialFailureRevocationId);
220
- }
221
- const trialRetryExhaustionIds = new Set();
222
- const exhaustedCorrectiveEvaluations = new Set();
223
- const exhaustedTrialFailures = new Set();
224
- for (const receipt of learning.trialRetryExhaustions || []) {
225
- const valid = storedTrialRetryExhaustionStructure(receipt)
226
- && trialRetryExhaustionMatchesState(learning, receipt);
227
- if (!valid || trialRetryExhaustionIds.has(receipt.id)
228
- || exhaustedCorrectiveEvaluations.has(receipt.correctiveEvaluationId)
229
- || exhaustedTrialFailures.has(receipt.trialFailureId)) {
230
- findings.push(`invalid-trial-retry-exhaustion:${receipt.id || "unknown"}`);
231
- }
232
- trialRetryExhaustionIds.add(receipt.id);
233
- exhaustedCorrectiveEvaluations.add(receipt.correctiveEvaluationId);
234
- exhaustedTrialFailures.add(receipt.trialFailureId);
235
- }
236
- const evaluationRevocationIds = new Set();
237
- const revokedEvaluationIds = new Set();
238
- for (const receipt of learning.evaluationRevocations || []) {
239
- const valid = storedEvaluationRevocationStructure(receipt) && evaluationRevocationMatchesState(learning, receipt);
240
- if (!valid || evaluationRevocationIds.has(receipt.id) || revokedEvaluationIds.has(receipt.evaluationId)) {
241
- findings.push(`invalid-evaluation-revocation:${receipt.id || "unknown"}`);
242
- }
243
- evaluationRevocationIds.add(receipt.id);
244
- revokedEvaluationIds.add(receipt.evaluationId);
245
- }
246
- const evidenceSourceAttestationRevocationIds = new Set();
247
- const revokedEvidenceSourceAttestations = new Set();
248
- for (const receipt of learning.evidenceSourceAttestationRevocations || []) {
249
- const key = `${receipt.evaluationId}\0${receipt.evidenceDigest}`;
250
- const valid = storedEvidenceSourceAttestationRevocationStructure(receipt)
251
- && evidenceSourceAttestationRevocationMatchesState(learning, receipt);
252
- if (!valid || evidenceSourceAttestationRevocationIds.has(receipt.id)
253
- || revokedEvidenceSourceAttestations.has(key)) {
254
- findings.push(`invalid-evidence-source-attestation-revocation:${receipt.id || "unknown"}`);
255
- }
256
- evidenceSourceAttestationRevocationIds.add(receipt.id);
257
- revokedEvidenceSourceAttestations.add(key);
258
- }
259
- const validationRevocationIds = new Set();
260
- const revokedValidationLeaseIds = new Set();
261
- for (const receipt of learning.validationRevocations || []) {
262
- const valid = storedValidationRevocationStructure(receipt) && validationRevocationMatchesState(learning, receipt);
263
- if (!valid || validationRevocationIds.has(receipt.id)
264
- || revokedValidationLeaseIds.has(receipt.validationLeaseId)) {
265
- findings.push(`invalid-validation-revocation:${receipt.id || "unknown"}`);
266
- }
267
- validationRevocationIds.add(receipt.id);
268
- revokedValidationLeaseIds.add(receipt.validationLeaseId);
269
- }
270
- const evidenceRevocationIds = new Set();
271
- const revokedEvidenceKeys = new Set();
272
- for (const receipt of learning.evidenceRevocations || []) {
273
- const key = `${receipt.learningId}\0${receipt.evidenceId}`;
274
- const valid = storedEvidenceRevocationStructure(receipt) && evidenceRevocationMatchesState(learning, receipt);
275
- if (!valid || evidenceRevocationIds.has(receipt.id) || revokedEvidenceKeys.has(key)) {
276
- findings.push(`invalid-evidence-revocation:${receipt.id || "unknown"}`);
277
- }
278
- evidenceRevocationIds.add(receipt.id);
279
- revokedEvidenceKeys.add(key);
280
- }
281
- const measurementRevocationIds = new Set();
282
- const revokedMeasurementIds = new Set();
283
- for (const receipt of learning.measurementRevocations || []) {
284
- const valid = storedMeasurementRevocationStructure(receipt) && measurementRevocationMatchesState(learning, receipt);
285
- if (!valid || measurementRevocationIds.has(receipt.id) || revokedMeasurementIds.has(receipt.measurementId)) {
286
- findings.push(`invalid-measurement-revocation:${receipt.id || "unknown"}`);
287
- }
288
- measurementRevocationIds.add(receipt.id);
289
- revokedMeasurementIds.add(receipt.measurementId);
290
- }
291
- const applicationRevocationIds = new Set();
292
- const revokedApplicationIds = new Set();
293
- for (const receipt of learning.applicationRevocations || []) {
294
- const valid = storedApplicationRevocationStructure(receipt) && applicationRevocationMatchesState(learning, receipt);
295
- if (!valid || applicationRevocationIds.has(receipt.id) || revokedApplicationIds.has(receipt.applicationId)) {
296
- findings.push(`invalid-application-revocation:${receipt.id || "unknown"}`);
297
- }
298
- applicationRevocationIds.add(receipt.id);
299
- revokedApplicationIds.add(receipt.applicationId);
300
- }
301
- const deliveryRevocationIds = new Set();
302
- const revokedDeliveryIds = new Set();
303
- for (const receipt of learning.deliveryRevocations || []) {
304
- const valid = storedDeliveryRevocationStructure(receipt) && deliveryRevocationMatchesState(learning, receipt);
305
- if (!valid || deliveryRevocationIds.has(receipt.id) || revokedDeliveryIds.has(receipt.deliveryId)) {
306
- findings.push(`invalid-delivery-revocation:${receipt.id || "unknown"}`);
307
- }
308
- deliveryRevocationIds.add(receipt.id);
309
- revokedDeliveryIds.add(receipt.deliveryId);
310
- }
311
- const outcomeRevocationIds = new Set();
312
- const revokedOutcomeIds = new Set();
313
- for (const receipt of learning.outcomeRevocations || []) {
314
- const valid = storedOutcomeRevocationStructure(receipt) && outcomeRevocationMatchesState(learning, receipt);
315
- if (!valid || outcomeRevocationIds.has(receipt.id) || revokedOutcomeIds.has(receipt.outcomeId)) {
316
- findings.push(`invalid-outcome-revocation:${receipt.id || "unknown"}`);
317
- }
318
- outcomeRevocationIds.add(receipt.id);
319
- revokedOutcomeIds.add(receipt.outcomeId);
320
- }
321
- const measurementIds = new Set();
322
- const measurementSources = new Set();
323
- const measurementRuns = new Set();
324
- const evaluatorRootRuns = new Set();
325
- const measurementLineageIds = new Set();
326
- for (const lineage of learning.measurementLineage || []) {
327
- const valid = storedMeasurementLineageStructure(lineage);
328
- if (!valid || measurementLineageIds.has(lineage.measurementReceiptId)) {
329
- findings.push(`invalid-measurement-lineage:${lineage.measurementReceiptId || "unknown"}`);
330
- }
331
- if (measurementSources.has(lineage.sourceDigest) || measurementRuns.has(lineage.runDigest)
332
- || (lineage.schema === "agentspine.learning-measurement-lineage/v2" && evaluatorRootRuns.has(lineage.rootRunDigest))) {
333
- findings.push(`replayed-measurement-lineage:${lineage.measurementReceiptId || "unknown"}`);
334
- }
335
- measurementLineageIds.add(lineage.measurementReceiptId);
336
- measurementSources.add(lineage.sourceDigest);
337
- measurementRuns.add(lineage.runDigest);
338
- if (lineage.schema === "agentspine.learning-measurement-lineage/v2") evaluatorRootRuns.add(lineage.rootRunDigest);
339
- }
340
- for (const receipt of learning.measurements || []) {
341
- const candidate = learning.candidates.find((item) => item.id === receipt.learningId);
342
- const contract = (learning.evaluations || []).find((item) => item.id === receipt.evaluationId);
343
- const lineage = (learning.measurementLineage || []).find((item) => item.measurementReceiptId === receipt.id);
344
- const valid = storedMeasurementStructure(receipt) && candidate && contract
345
- && LINEAGE_EVALUATIONS.has(contract.schema)
346
- && contract.learningId === receipt.learningId
347
- && exactScope(contract.scope, receipt.scope) && scopeContains(candidate.scope, receipt.scope)
348
- && lineage?.sourceDigest === receipt.measurement?.sourceDigest
349
- && lineage?.runDigest === measurementRunDigest(receipt.measurement?.evaluatorId, receipt.measurement?.runId)
350
- && (receipt.schema !== "agentspine.learning-measurement/v2"
351
- || (ROOT_BOUND_EVALUATIONS.has(contract.schema)
352
- && contract.evaluatorRoots.some((root) => root.evaluatorId === receipt.measurement?.evaluatorId
353
- && root.principalDigest === receipt.measurement?.evaluatorRootDigest)
354
- && lineage?.schema === "agentspine.learning-measurement-lineage/v2"
355
- && lineage?.evaluatorRootDigest === receipt.measurement?.evaluatorRootDigest
356
- && lineage?.rootRunDigest === evaluatorRootRunDigest(receipt.measurement?.evaluatorRootDigest, receipt.measurement?.runId)))
357
- && lineage?.registeredAt === receipt.measuredAt;
358
- if (!valid || measurementIds.has(receipt.id)) findings.push(`invalid-measurement:${receipt.id || "unknown"}`);
359
- measurementIds.add(receipt.id);
360
- }
361
- const applicationIds = new Set();
362
- for (const receipt of learning.applications || []) {
363
- const candidate = learning.candidates.find((item) => item.id === receipt.learningId);
364
- const valid = storedApplicationStructure(receipt) && candidate && scopeContains(candidate.scope, receipt.scope);
365
- if (!valid || applicationIds.has(receipt.id)) findings.push(`invalid-application:${receipt.id || "unknown"}`);
366
- if (DELIVERABLE_APPLICATIONS.has(receipt.schema)
367
- && new Date(receipt.deliveryExpiresAt).getTime() < Date.now()
368
- && !(learning.deliveries || []).some((delivery) => delivery.applicationId === receipt.id)
369
- && !failedApplications.has(receipt.id)) {
370
- findings.push(`stale-undelivered-application:${receipt.id}`);
371
- }
372
- applicationIds.add(receipt.id);
373
- }
374
- const deliveryIds = new Set();
375
- for (const receipt of learning.deliveries || []) {
376
- const candidate = learning.candidates.find((item) => item.id === receipt.learningId);
377
- const application = learning.applications.find((item) => item.id === receipt.applicationId);
378
- const valid = storedDeliveryStructure(receipt) && candidate && application
379
- && application.learningId === receipt.learningId && application.sessionId === receipt.sessionId
380
- && exactScope(application.scope, receipt.scope) && scopeContains(candidate.scope, receipt.scope);
381
- if (!valid || deliveryIds.has(receipt.id)) findings.push(`invalid-delivery:${receipt.id || "unknown"}`);
382
- deliveryIds.add(receipt.id);
383
- }
384
- for (const receipt of learning.outcomes || []) {
385
- if (["agentspine.learning-outcome/v2", "agentspine.learning-outcome/v3", "agentspine.learning-outcome/v4", "agentspine.learning-outcome/v5", "agentspine.learning-outcome/v6", "agentspine.learning-outcome/v7", "agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema) && receipt.phase === "after"
386
- && !applicationIds.has(receipt.applicationId)) findings.push(`unbound-outcome:${receipt.id}`);
387
- if (["agentspine.learning-outcome/v3", "agentspine.learning-outcome/v4", "agentspine.learning-outcome/v5", "agentspine.learning-outcome/v6", "agentspine.learning-outcome/v7", "agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema) && !evaluationIds.has(receipt.evaluationId)) {
388
- findings.push(`unplanned-outcome:${receipt.id}`);
389
- }
390
- if (["agentspine.learning-outcome/v4", "agentspine.learning-outcome/v5", "agentspine.learning-outcome/v6", "agentspine.learning-outcome/v7", "agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema) && receipt.phase === "after"
391
- && !deliveryIds.has(receipt.deliveryId)) findings.push(`undelivered-outcome:${receipt.id}`);
392
- if (["agentspine.learning-outcome/v5", "agentspine.learning-outcome/v6", "agentspine.learning-outcome/v7", "agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema)) {
393
- const contract = (learning.evaluations || []).find((item) => item.id === receipt.evaluationId);
394
- if (!contract
395
- || (receipt.schema === "agentspine.learning-outcome/v5" && contract.schema !== "agentspine.learning-evaluation/v2")
396
- || (receipt.schema === "agentspine.learning-outcome/v6" && contract.schema !== "agentspine.learning-evaluation/v3")
397
- || (receipt.schema === "agentspine.learning-outcome/v7" && contract.schema !== "agentspine.learning-evaluation/v4")
398
- || (receipt.schema === "agentspine.learning-outcome/v8" && contract.schema !== "agentspine.learning-evaluation/v5")
399
- || (receipt.schema === "agentspine.learning-outcome/v9" && !ROOT_BOUND_EVALUATIONS.has(contract.schema))
400
- || receipt.coverage?.datasetDigest !== contract.benchmark.datasetDigest
401
- || receipt.coverage?.caseCount < contract.benchmark.minCases) findings.push(`invalid-coverage:${receipt.id}`);
402
- }
403
- if (receipt.schema === "agentspine.learning-outcome/v6" && !DIGEST_RE.test(receipt.measurement?.sourceDigest || "")) {
404
- findings.push(`invalid-provenance:${receipt.id}`);
405
- }
406
- if (["agentspine.learning-outcome/v7", "agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema)) {
407
- const source = (learning.measurements || []).find((item) => item.id === receipt.measurementReceiptId);
408
- if (!source || source.digest !== receipt.measurementReceiptDigest) findings.push(`unbound-measurement:${receipt.id}`);
409
- }
410
- }
411
- const pairedOutcomeKeys = new Set();
412
- const pairedAfterApplications = new Set();
413
- for (const receipt of learning.outcomes || []) {
414
- if (!["agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema)) continue;
415
- const evaluatorKey = receipt.schema === "agentspine.learning-outcome/v9"
416
- ? receipt.measurement.evaluatorRootDigest : receipt.measurement.evaluatorId;
417
- const key = `${receipt.evaluationId}\0${receipt.phase}\0${evaluatorKey}`;
418
- if (pairedOutcomeKeys.has(key)) findings.push(`duplicate-paired-evaluator:${receipt.id}`);
419
- pairedOutcomeKeys.add(key);
420
- if (receipt.phase === "after") {
421
- const applicationKey = `${receipt.evaluationId}\0${receipt.applicationId}`;
422
- if (pairedAfterApplications.has(applicationKey)) findings.push(`duplicate-paired-turn:${receipt.id}`);
423
- pairedAfterApplications.add(applicationKey);
424
- }
425
- }
426
- for (const receipt of learning.outcomes || []) {
427
- if (!["agentspine.learning-outcome/v8", "agentspine.learning-outcome/v9"].includes(receipt.schema) || receipt.phase !== "after") continue;
428
- const pairedBefore = learning.outcomes.some((before) => before.schema === receipt.schema
429
- && before.phase === "before" && before.learningId === receipt.learningId
430
- && before.evaluationId === receipt.evaluationId
431
- && before.measurement.evaluatorId === receipt.measurement.evaluatorId
432
- && (receipt.schema !== "agentspine.learning-outcome/v9"
433
- || before.measurement.evaluatorRootDigest === receipt.measurement.evaluatorRootDigest)
434
- && before.measurement.kind === receipt.measurement.kind
435
- && before.coverage.caseCount === receipt.coverage.caseCount
436
- && exactScope(before.scope, receipt.scope));
437
- if (!pairedBefore) findings.push(`unpaired-evaluator-outcome:${receipt.id}`);
438
- }
439
- const provenanceKeys = new Set();
440
- for (const receipt of learning.outcomes || []) {
441
- if (receipt.schema !== "agentspine.learning-outcome/v6") continue;
442
- const key = `${receipt.evaluationId}\0${receipt.measurement.sourceDigest}`;
443
- if (provenanceKeys.has(key)) findings.push(`replayed-provenance:${receipt.id}`);
444
- provenanceKeys.add(key);
445
- }
446
- for (const entry of learning.history) {
447
- const value = entry.value || {};
448
- const nested = [...(value.evidence || []), value.review, value.rollback, value.promotion].filter(Boolean);
449
- if (entry.authority !== "context-only" || value.authority !== "context-only" || nested.some((item) => item.authority !== "context-only")) {
450
- findings.push(`history-authority:${entry.recordId || "unknown"}`);
451
- }
452
- if (SECRET_RE.test(value.claim || "") || AUTHORITY_ASSERTION_RE.test(value.claim || "")
453
- || value.evidence?.some((item) => SECRET_RE.test(item.summary || ""))) {
454
- findings.push(`unsafe-history:${entry.recordId || "unknown"}`);
455
- }
456
- }
457
- return findings;
458
- }