@raishin/vanguard-frontier-agentic 3.14.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/.github/plugin/marketplace.json +1 -1
  5. package/agents/cross-functional/revenue-critical-journey-integrity-agent/harnesses/codex.toml +1 -1
  6. package/agents/dotnet/dotnet-aspire-cloud-native-review-agent/harnesses/codex.toml +1 -1
  7. package/agents/dotnet/dotnet-aspnetcore-api-review-agent/harnesses/codex.toml +1 -1
  8. package/agents/dotnet/dotnet-aspnetcore-identity-authz-review-agent/harnesses/codex.toml +1 -1
  9. package/agents/dotnet/dotnet-csharp-runtime-review-agent/harnesses/codex.toml +1 -1
  10. package/agents/dotnet/dotnet-efcore-data-access-review-agent/harnesses/codex.toml +1 -1
  11. package/agents/dotnet/dotnet-maestro-agent/harnesses/codex.toml +1 -1
  12. package/agents/dotnet/dotnet-observability-otel-review-agent/harnesses/codex.toml +1 -1
  13. package/agents/dotnet/dotnet-performance-aot-review-agent/harnesses/codex.toml +1 -1
  14. package/agents/dotnet/dotnet-supply-chain-review-agent/harnesses/codex.toml +1 -1
  15. package/agents/dotnet/dotnet-testing-quality-review-agent/harnesses/codex.toml +1 -1
  16. package/agents/frontend/nextjs-specialist-agent/harnesses/codex.toml +1 -1
  17. package/agents/frontend/svelte-sveltekit-specialist-agent/harnesses/codex.toml +1 -1
  18. package/agents/hr/hr-analytics-people-data-agent/harnesses/codex.toml +1 -1
  19. package/agents/hr/hr-benefits-payroll-agent/harnesses/codex.toml +1 -1
  20. package/agents/hr/hr-compensation-equity-agent/harnesses/codex.toml +1 -1
  21. package/agents/hr/hr-culture-dei-agent/harnesses/codex.toml +1 -1
  22. package/agents/hr/hr-employee-relations-agent/harnesses/codex.toml +1 -1
  23. package/agents/hr/hr-hris-process-controls-agent/harnesses/codex.toml +1 -1
  24. package/agents/hr/hr-learning-policy-agent/harnesses/codex.toml +1 -1
  25. package/agents/hr/hr-leave-accommodation-agent/harnesses/codex.toml +1 -1
  26. package/agents/hr/hr-maestro-agent/harnesses/codex.toml +1 -1
  27. package/agents/hr/hr-performance-management-agent/harnesses/codex.toml +1 -1
  28. package/agents/hr/hr-recruiting-selection-agent/harnesses/codex.toml +1 -1
  29. package/agents/hr/hr-risk-triage-review-agent/harnesses/codex.toml +1 -1
  30. package/agents/hr/hr-termination-readiness-agent/harnesses/codex.toml +1 -1
  31. package/agents/hr/hr-workforce-planning-rif-agent/harnesses/codex.toml +1 -1
  32. package/agents/hr/hr-workplace-investigations-agent/harnesses/codex.toml +1 -1
  33. package/agents/java/java-application-server-exit-agent/harnesses/codex.toml +1 -1
  34. package/agents/java/java-concurrency-and-virtual-thread-agent/harnesses/codex.toml +1 -1
  35. package/agents/java/java-container-and-kubernetes-readiness-agent/harnesses/codex.toml +1 -1
  36. package/agents/java/java-database-migration-safety-agent/harnesses/codex.toml +1 -1
  37. package/agents/java/java-deserialization-and-parser-security-agent/harnesses/codex.toml +1 -1
  38. package/agents/java/java-framework-production-readiness-agent/harnesses/codex.toml +1 -1
  39. package/agents/java/java-jdk-lifecycle-and-upgrade-agent/harnesses/codex.toml +1 -1
  40. package/agents/java/java-jpa-hibernate-performance-agent/harnesses/codex.toml +1 -1
  41. package/agents/java/java-jvm-performance-and-gc-agent/harnesses/codex.toml +1 -1
  42. package/agents/java/java-kafka-reliability-agent/harnesses/codex.toml +1 -1
  43. package/agents/java/java-maestro-agent/harnesses/codex.toml +1 -1
  44. package/agents/java/java-resilience-pattern-agent/harnesses/codex.toml +1 -1
  45. package/agents/java/java-spring-security-agent/harnesses/codex.toml +1 -1
  46. package/agents/java/java-test-architecture-agent/harnesses/codex.toml +1 -1
  47. package/agents/java/java-transaction-and-consistency-agent/harnesses/codex.toml +1 -1
  48. package/agents/legal/legal-contract-review-agent/harnesses/codex.toml +1 -1
  49. package/agents/legal/legal-counsel-review-agent/harnesses/codex.toml +1 -1
  50. package/agents/legal/legal-employment-law-risk-agent/harnesses/codex.toml +1 -1
  51. package/agents/legal/legal-ethics-investigations-agent/harnesses/codex.toml +1 -1
  52. package/agents/legal/legal-ip-open-source-agent/harnesses/codex.toml +1 -1
  53. package/agents/legal/legal-knowledge-management-agent/harnesses/codex.toml +1 -1
  54. package/agents/legal/legal-litigation-discovery-hold-agent/harnesses/codex.toml +1 -1
  55. package/agents/legal/legal-maestro-agent/harnesses/codex.toml +1 -1
  56. package/agents/legal/legal-policy-governance-agent/harnesses/codex.toml +1 -1
  57. package/agents/legal/legal-privacy-data-protection-agent/harnesses/codex.toml +1 -1
  58. package/agents/legal/legal-public-disclosure-agent/harnesses/codex.toml +1 -1
  59. package/agents/legal/legal-regulatory-compliance-agent/harnesses/codex.toml +1 -1
  60. package/agents/legal/legal-vendor-procurement-risk-agent/harnesses/codex.toml +1 -1
  61. package/agents/netsuite/netsuite-administrator-agent/harnesses/codex.toml +1 -1
  62. package/agents/netsuite/netsuite-ai-connector-mcp-agent/harnesses/codex.toml +1 -1
  63. package/agents/netsuite/netsuite-ai-foundations-agent/harnesses/codex.toml +1 -1
  64. package/agents/netsuite/netsuite-application-developer-agent/harnesses/codex.toml +1 -1
  65. package/agents/netsuite/netsuite-audit-controls-sox-agent/harnesses/codex.toml +1 -1
  66. package/agents/netsuite/netsuite-bi-reporting-agent/harnesses/codex.toml +1 -1
  67. package/agents/netsuite/netsuite-data-governance-privacy-agent/harnesses/codex.toml +1 -1
  68. package/agents/netsuite/netsuite-enterprise-architecture-agent/harnesses/codex.toml +1 -1
  69. package/agents/netsuite/netsuite-erp-consultant-agent/harnesses/codex.toml +1 -1
  70. package/agents/netsuite/netsuite-evidence-release-drift-agent/harnesses/codex.toml +1 -1
  71. package/agents/netsuite/netsuite-financial-foundations-agent/harnesses/codex.toml +1 -1
  72. package/agents/netsuite/netsuite-identity-access-role-permission-agent/harnesses/codex.toml +1 -1
  73. package/agents/netsuite/netsuite-integration-migration-agent/harnesses/codex.toml +1 -1
  74. package/agents/netsuite/netsuite-live-org-mutation-guard-agent/harnesses/codex.toml +1 -1
  75. package/agents/netsuite/netsuite-maestro-agent/harnesses/codex.toml +1 -1
  76. package/agents/netsuite/netsuite-oneworld-multisubsidiary-agent/harnesses/codex.toml +1 -1
  77. package/agents/netsuite/netsuite-sandbox-nonproduction-governance-agent/harnesses/codex.toml +1 -1
  78. package/agents/netsuite/netsuite-saved-searches-workbook-agent/harnesses/codex.toml +1 -1
  79. package/agents/netsuite/netsuite-sdf-devops-release-agent/harnesses/codex.toml +1 -1
  80. package/agents/netsuite/netsuite-sso-oauth-tba-agent/harnesses/codex.toml +1 -1
  81. package/agents/netsuite/netsuite-suitecloud-developer-agent/harnesses/codex.toml +1 -1
  82. package/agents/netsuite/netsuite-suiteflow-automation-agent/harnesses/codex.toml +1 -1
  83. package/agents/netsuite/netsuite-suitefoundation-agent/harnesses/codex.toml +1 -1
  84. package/agents/netsuite/netsuite-suitescript-secure-code-review-agent/harnesses/codex.toml +1 -1
  85. package/agents/netsuite/netsuite-web-services-integration-agent/harnesses/codex.toml +1 -1
  86. package/agents/qa/ci-test-pipeline-review-agent/harnesses/codex.toml +1 -1
  87. package/agents/qa/helm-chart-quality-review-agent/harnesses/codex.toml +1 -1
  88. package/agents/qa/kubernetes-manifest-quality-review-agent/harnesses/codex.toml +1 -1
  89. package/agents/qa/llm-ai-pipeline-test-review-agent/harnesses/codex.toml +1 -1
  90. package/agents/qa/playwright-e2e-suite-review-agent/harnesses/codex.toml +1 -1
  91. package/agents/qa/plc-control-logic-safety-review-agent/harnesses/codex.toml +1 -1
  92. package/agents/qa/rpa-workflow-resilience-review-agent/harnesses/codex.toml +1 -1
  93. package/agents/qa/test-coverage-quality-review-agent/harnesses/codex.toml +1 -1
  94. package/agents/qa/test-flakiness-triage-agent/harnesses/codex.toml +1 -1
  95. package/agents/salesforce/salesforce-adaptive-access-agent/harnesses/codex.toml +1 -1
  96. package/agents/salesforce/salesforce-agentforce-ai-agent/harnesses/codex.toml +1 -1
  97. package/agents/salesforce/salesforce-analytics-tableau-agent/harnesses/codex.toml +1 -1
  98. package/agents/salesforce/salesforce-app-builder-automation-agent/harnesses/codex.toml +1 -1
  99. package/agents/salesforce/salesforce-business-analyst-agent/harnesses/codex.toml +1 -1
  100. package/agents/salesforce/salesforce-certificate-lifecycle-agent/harnesses/codex.toml +1 -1
  101. package/agents/salesforce/salesforce-change-impact-analyst-agent/harnesses/codex.toml +1 -1
  102. package/agents/salesforce/salesforce-code-analyzer-orchestrator-agent/harnesses/codex.toml +1 -1
  103. package/agents/salesforce/salesforce-compliance-privacy-agent/harnesses/codex.toml +1 -1
  104. package/agents/salesforce/salesforce-continuous-verification-agent/harnesses/codex.toml +1 -1
  105. package/agents/salesforce/salesforce-data-architecture-agent/harnesses/codex.toml +1 -1
  106. package/agents/salesforce/salesforce-development-agent/harnesses/codex.toml +1 -1
  107. package/agents/salesforce/salesforce-devops-release-agent/harnesses/codex.toml +1 -1
  108. package/agents/salesforce/salesforce-enterprise-architect-agent/harnesses/codex.toml +1 -1
  109. package/agents/salesforce/salesforce-experience-cloud-agent/harnesses/codex.toml +1 -1
  110. package/agents/salesforce/salesforce-hyperforce-security-agent/harnesses/codex.toml +1 -1
  111. package/agents/salesforce/salesforce-industry-cloud-agent/harnesses/codex.toml +1 -1
  112. package/agents/salesforce/salesforce-integration-mulesoft-agent/harnesses/codex.toml +1 -1
  113. package/agents/salesforce/salesforce-live-guard-agent/harnesses/codex.toml +1 -1
  114. package/agents/salesforce/salesforce-maestro-agent/harnesses/codex.toml +1 -1
  115. package/agents/salesforce/salesforce-marketing-cloud-agent/harnesses/codex.toml +1 -1
  116. package/agents/salesforce/salesforce-network-policy-architect-agent/harnesses/codex.toml +1 -1
  117. package/agents/salesforce/salesforce-platform-admin-review-agent/harnesses/codex.toml +1 -1
  118. package/agents/salesforce/salesforce-sales-cloud-revenue-agent/harnesses/codex.toml +1 -1
  119. package/agents/salesforce/salesforce-sandbox-governance-agent/harnesses/codex.toml +1 -1
  120. package/agents/salesforce/salesforce-sandbox-isolation-agent/harnesses/codex.toml +1 -1
  121. package/agents/salesforce/salesforce-security-identity-access-agent/harnesses/codex.toml +1 -1
  122. package/agents/salesforce/salesforce-service-field-service-agent/harnesses/codex.toml +1 -1
  123. package/agents/salesforce/salesforce-session-governance-agent/harnesses/codex.toml +1 -1
  124. package/agents/salesforce/salesforce-slack-collaboration-agent/harnesses/codex.toml +1 -1
  125. package/catalog/AGENTS.md +2 -1
  126. package/catalog/asset-integrity.json +723 -276
  127. package/catalog/index.json +3 -2
  128. package/catalog/model-assignments.json +121 -121
  129. package/catalog/model-policy.json +9 -9
  130. package/catalog/model-registry.json +28 -13
  131. package/catalog/mods.json +131 -0
  132. package/mods/README.md +220 -0
  133. package/mods/audit-trail/README.md +70 -0
  134. package/mods/audit-trail/bin/hook.mjs +65 -0
  135. package/mods/audit-trail/claude-code/UNSUPPORTED.md +11 -0
  136. package/mods/audit-trail/claude-code/settings.hooks.json +14 -0
  137. package/mods/audit-trail/codex/hooks.json +14 -0
  138. package/mods/audit-trail/kiro/UNSUPPORTED.md +7 -0
  139. package/mods/audit-trail/kiro/audit-trail-post-tool-use-hook.json +14 -0
  140. package/mods/audit-trail/lib/common.mjs +213 -0
  141. package/mods/audit-trail/lib/core.mjs +50 -0
  142. package/mods/audit-trail/lib/runtime.mjs +140 -0
  143. package/mods/audit-trail/mod.toml +37 -0
  144. package/mods/blast-radius-guard/.claude-plugin/plugin.json +5 -0
  145. package/mods/blast-radius-guard/README.md +53 -0
  146. package/mods/blast-radius-guard/bin/hook.mjs +18 -0
  147. package/mods/blast-radius-guard/claude-code/settings.hooks.json +14 -0
  148. package/mods/blast-radius-guard/codex/UNSUPPORTED.md +7 -0
  149. package/mods/blast-radius-guard/codex/hooks.json +14 -0
  150. package/mods/blast-radius-guard/hooks/hooks.json +5 -0
  151. package/mods/blast-radius-guard/hooks/register.test.ts +97 -0
  152. package/mods/blast-radius-guard/hooks/register.ts +13 -0
  153. package/mods/blast-radius-guard/kiro/UNSUPPORTED.md +7 -0
  154. package/mods/blast-radius-guard/kiro/blast-radius-guard-pre-tool-use-hook.json +14 -0
  155. package/mods/blast-radius-guard/lib/common.mjs +213 -0
  156. package/mods/blast-radius-guard/lib/core.mjs +66 -0
  157. package/mods/blast-radius-guard/lib/patterns.mjs +102 -0
  158. package/mods/blast-radius-guard/lib/runtime.mjs +140 -0
  159. package/mods/blast-radius-guard/mod.toml +34 -0
  160. package/mods/blast-radius-guard/patterns.json +101 -0
  161. package/mods/context-burn/.claude-plugin/plugin.json +5 -0
  162. package/mods/context-burn/README.md +66 -0
  163. package/mods/context-burn/bin/hook.mjs +38 -0
  164. package/mods/context-burn/claude-code/UNSUPPORTED.md +7 -0
  165. package/mods/context-burn/claude-code/settings.hooks.json +24 -0
  166. package/mods/context-burn/codex/UNSUPPORTED.md +7 -0
  167. package/mods/context-burn/codex/hooks.json +24 -0
  168. package/mods/context-burn/hooks/hooks.json +5 -0
  169. package/mods/context-burn/hooks/register.test.ts +151 -0
  170. package/mods/context-burn/hooks/register.ts +35 -0
  171. package/mods/context-burn/kiro/UNSUPPORTED.md +7 -0
  172. package/mods/context-burn/kiro/context-burn-post-tool-use-hook.json +14 -0
  173. package/mods/context-burn/kiro/context-burn-session-start-hook.json +14 -0
  174. package/mods/context-burn/lib/common.mjs +213 -0
  175. package/mods/context-burn/lib/core.mjs +79 -0
  176. package/mods/context-burn/lib/runtime.mjs +140 -0
  177. package/mods/context-burn/mod.toml +37 -0
  178. package/mods/live-guard-gate/.claude-plugin/plugin.json +5 -0
  179. package/mods/live-guard-gate/README.md +43 -0
  180. package/mods/live-guard-gate/bin/hook.mjs +12 -0
  181. package/mods/live-guard-gate/claude-code/settings.hooks.json +14 -0
  182. package/mods/live-guard-gate/codex/UNSUPPORTED.md +7 -0
  183. package/mods/live-guard-gate/codex/hooks.json +14 -0
  184. package/mods/live-guard-gate/hooks/hooks.json +5 -0
  185. package/mods/live-guard-gate/hooks/register.test.ts +59 -0
  186. package/mods/live-guard-gate/hooks/register.ts +11 -0
  187. package/mods/live-guard-gate/kiro/UNSUPPORTED.md +7 -0
  188. package/mods/live-guard-gate/kiro/live-guard-gate-pre-tool-use-hook.json +14 -0
  189. package/mods/live-guard-gate/lib/common.mjs +213 -0
  190. package/mods/live-guard-gate/lib/core.mjs +24 -0
  191. package/mods/live-guard-gate/lib/live-agents.mjs +65 -0
  192. package/mods/live-guard-gate/lib/patterns.mjs +523 -0
  193. package/mods/live-guard-gate/lib/runtime.mjs +140 -0
  194. package/mods/live-guard-gate/mod.toml +34 -0
  195. package/mods/live-guard-gate/patterns.json +522 -0
  196. package/mods/secret-redactor/.claude-plugin/plugin.json +5 -0
  197. package/mods/secret-redactor/README.md +86 -0
  198. package/mods/secret-redactor/bin/hook.mjs +35 -0
  199. package/mods/secret-redactor/claude-code/UNSUPPORTED.md +7 -0
  200. package/mods/secret-redactor/claude-code/settings.hooks.json +24 -0
  201. package/mods/secret-redactor/codex/UNSUPPORTED.md +11 -0
  202. package/mods/secret-redactor/codex/hooks.json +14 -0
  203. package/mods/secret-redactor/hooks/hooks.json +5 -0
  204. package/mods/secret-redactor/hooks/register.test.ts +150 -0
  205. package/mods/secret-redactor/hooks/register.ts +19 -0
  206. package/mods/secret-redactor/kiro/UNSUPPORTED.md +11 -0
  207. package/mods/secret-redactor/kiro/secret-redactor-pre-tool-use-hook.json +14 -0
  208. package/mods/secret-redactor/lib/common.mjs +213 -0
  209. package/mods/secret-redactor/lib/core.mjs +61 -0
  210. package/mods/secret-redactor/lib/patterns.mjs +75 -0
  211. package/mods/secret-redactor/lib/runtime.mjs +140 -0
  212. package/mods/secret-redactor/mod.toml +43 -0
  213. package/mods/secret-redactor/patterns.json +74 -0
  214. package/package.json +9 -5
  215. package/plugins/vanguard-frontier-agentic/.codex-plugin/plugin.json +1 -1
  216. package/scripts/generate-mods.mjs +784 -0
  217. package/scripts/mods/common.mjs +213 -0
  218. package/scripts/mods/runtime.mjs +140 -0
  219. package/tests/fixtures/README.md +1 -1
  220. package/tests/fuzz-properties.test.mjs +254 -0
  221. package/tests/mods.test.mjs +768 -0
  222. package/tests/validate-asset-integrity.py +1 -0
  223. package/tests/validate-mods.py +821 -0
@@ -0,0 +1,213 @@
1
+ // Shared helpers for the mods under mods/. scripts/generate-mods.mjs copies this file
2
+ // byte-for-byte to mods/<id>/lib/common.mjs, so edit it here and run `npm run mods:write`.
3
+ //
4
+ // Pure on purpose: no imports, no environment, no I/O. Claude Code's native mod runtime
5
+ // imports it and has no Node, and every harness must reach the same verdict on the same
6
+ // input. Regexes compile without the `u` flag so Node and Python `re.ASCII`
7
+ // (tests/validate-mods.py) read them the same way.
8
+
9
+ export const LIMITS = Object.freeze({
10
+ // A redaction that still changes after this many passes is withheld as a whole.
11
+ maxPasses: 8,
12
+ // A guard candidate longer than this is not evaluated and counts as a hit.
13
+ maxCandidateChars: 65536,
14
+ // Guard candidates are not evaluated past this combined length; the call counts as a hit.
15
+ maxTotalChars: 262144,
16
+ // Only the tail of a leaf's context (key or previous sibling) is prefixed to it.
17
+ maxContextChars: 256,
18
+ })
19
+
20
+ const MARKER_PREFIX = '[REDACTED:'
21
+ export const OVERFLOW_MARKER = '[REDACTED:overflow]'
22
+ const OVERFLOW_HIT = Object.freeze({ id: 'overflow', name: 'redaction did not converge' })
23
+ export const TOO_LARGE_HIT = Object.freeze({ id: 'too-large', name: 'input too large to evaluate' })
24
+
25
+ const ID_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/
26
+ const PATTERN_KEYS = new Set(['id', 'name', 'description', 'regex', 'flags', 'context', 'severity', 'agents'])
27
+ const isStringArray = (v) => Array.isArray(v) && v.every((s) => typeof s === 'string' && s !== '')
28
+
29
+ // Parser diagnostics can quote credential-bearing data; never expose it in hook logs.
30
+ export function parseJson(text, source) {
31
+ try {
32
+ return JSON.parse(text)
33
+ } catch {
34
+ throw new Error(`${source}: invalid JSON`)
35
+ }
36
+ }
37
+
38
+ // Validates a patterns.json-shaped list and compiles it. Throws on anything malformed so a
39
+ // bad extension file fails closed in the caller instead of silently matching nothing.
40
+ export function compilePatterns(list, source = 'patterns') {
41
+ if (!Array.isArray(list)) throw new Error(`${source}: expected an array of patterns`)
42
+ const seen = new Set()
43
+ return list.map((p, i) => {
44
+ const where = `${source}[${i}]`
45
+ if (p === null || typeof p !== 'object' || Array.isArray(p)) throw new Error(`${where}: expected an object`)
46
+ for (const k of Object.keys(p)) if (!PATTERN_KEYS.has(k)) throw new Error(`${where}: unknown key ${k}`)
47
+ if (typeof p.id !== 'string' || !ID_RE.test(p.id)) throw new Error(`${where}: id must be kebab-case`)
48
+ if (seen.has(p.id)) throw new Error(`${where}: duplicate id ${p.id}`)
49
+ seen.add(p.id)
50
+ if (typeof p.name !== 'string' || p.name === '') throw new Error(`${where}: name must be a non-empty string`)
51
+ if (typeof p.regex !== 'string' || p.regex === '') throw new Error(`${where}: regex must be a non-empty string`)
52
+ if (p.flags !== '' && p.flags !== 'i') throw new Error(`${where}: flags must be "" or "i"`)
53
+ if (!isStringArray(p.context) || p.context.length === 0) throw new Error(`${where}: context must be a non-empty string array`)
54
+ for (const k of ['description', 'severity']) {
55
+ if (p[k] !== undefined && typeof p[k] !== 'string') throw new Error(`${where}: ${k} must be a string`)
56
+ }
57
+ if (p.agents !== undefined && !isStringArray(p.agents)) throw new Error(`${where}: agents must be a string array`)
58
+ let rx, rxg
59
+ try {
60
+ rx = new RegExp(p.regex, p.flags)
61
+ rxg = new RegExp(p.regex, 'g' + p.flags)
62
+ } catch {
63
+ throw new Error(`${where}: regex does not compile`)
64
+ }
65
+ return Object.freeze({
66
+ id: p.id,
67
+ name: p.name,
68
+ severity: p.severity,
69
+ context: Object.freeze([...p.context]),
70
+ agents: p.agents ? Object.freeze([...p.agents]) : undefined,
71
+ rx,
72
+ rxg,
73
+ marker: `${MARKER_PREFIX}${p.id}]`,
74
+ })
75
+ })
76
+ }
77
+
78
+ // Every string value (not key) in depth-first order. The order follows the input, so the
79
+ // same payload always yields the same list.
80
+ export function stringLeaves(value, out = []) {
81
+ if (typeof value === 'string') out.push(value)
82
+ else if (Array.isArray(value)) for (const v of value) stringLeaves(v, out)
83
+ else if (value !== null && typeof value === 'object') for (const v of Object.values(value)) stringLeaves(v, out)
84
+ return out
85
+ }
86
+
87
+ // Guard candidates: every string leaf, plus every all-string array joined with spaces so
88
+ // an argv-style command (["rm", "-rf", "/"]) reads like the shell line it runs.
89
+ export function candidates(value) {
90
+ const out = stringLeaves(value)
91
+ const joinArrays = (v) => {
92
+ if (Array.isArray(v)) {
93
+ if (v.length > 1 && v.every((s) => typeof s === 'string')) out.push(v.join(' '))
94
+ v.forEach(joinArrays)
95
+ } else if (v !== null && typeof v === 'object') {
96
+ Object.values(v).forEach(joinArrays)
97
+ }
98
+ }
99
+ joinArrays(value)
100
+ return out
101
+ }
102
+
103
+ // The patterns tagged with `context` that match any text, in catalog order. Oversized input
104
+ // is not evaluated (regex cost is unbounded there) and reports TOO_LARGE_HIT instead.
105
+ export function matchPatterns(patterns, texts, context) {
106
+ let total = 0
107
+ for (const t of texts) {
108
+ total += t.length
109
+ if (t.length > LIMITS.maxCandidateChars || total > LIMITS.maxTotalChars) return [TOO_LARGE_HIT]
110
+ }
111
+ return patterns.filter((p) => p.context.includes(context) && texts.some((t) => p.rx.test(t)))
112
+ }
113
+
114
+ // One pattern pass after another until the text stops changing. Each pass can expose a new
115
+ // match (password-in-url can swallow an earlier marker), so a single pass is not enough.
116
+ function fixedPoint(text, patterns, hits) {
117
+ let x = text
118
+ for (let pass = 0; pass <= LIMITS.maxPasses; pass++) {
119
+ let y = x
120
+ for (const p of patterns) {
121
+ y = y.replace(p.rxg, (m) => {
122
+ if (m === '') return m
123
+ hits.add(p)
124
+ return p.marker
125
+ })
126
+ }
127
+ if (y === x) return x
128
+ x = y
129
+ }
130
+ hits.add(OVERFLOW_HIT)
131
+ return OVERFLOW_MARKER
132
+ }
133
+
134
+ // Redacts `s` with `ctx` in front so a secret split across a key and its value, or across
135
+ // argv elements ("Bearer", "<token>"), still matches; then strips the context back off.
136
+ function redactLeaf(s, ctx, patterns, hits) {
137
+ if (ctx === '') return fixedPoint(s, patterns, hits)
138
+ const pre = ctx.slice(-LIMITS.maxContextChars) + ' '
139
+ const y = fixedPoint(pre + s, patterns, hits)
140
+ if (y === OVERFLOW_MARKER) return y
141
+ const r = fixedPoint(pre, patterns, new Set())
142
+ if (y.startsWith(r)) return fixedPoint(y.slice(r.length), patterns, hits)
143
+ // A match spans the boundary: keep from the marker that covers it. Slicing changes
144
+ // anchors and boundaries, so also check the standalone leaf after contextual matching.
145
+ let d = 0
146
+ while (d < r.length && y[d] === r[d]) d++
147
+ const i = y.lastIndexOf(MARKER_PREFIX, d)
148
+ return fixedPoint(i >= 0 ? y.slice(i) : y, patterns, hits)
149
+ }
150
+
151
+ function walk(v, ctx, patterns, hits) {
152
+ if (typeof v === 'string') {
153
+ const local = new Set()
154
+ const out = redactLeaf(v, ctx, patterns, local)
155
+ if (out !== v) for (const h of local) hits.add(h)
156
+ return out
157
+ }
158
+ if (Array.isArray(v)) {
159
+ let prev = null
160
+ return v.map((el) => {
161
+ const out = walk(el, typeof prev === 'string' ? prev : ctx, patterns, hits)
162
+ prev = el
163
+ return out
164
+ })
165
+ }
166
+ if (v !== null && typeof v === 'object') {
167
+ const named = typeof v.name === 'string' ? v.name : typeof v.key === 'string' ? v.key : null
168
+ // fromEntries, not assignment: `out[k] = v` would drop an own "__proto__" key.
169
+ return Object.fromEntries(
170
+ Object.entries(v).map(([k, x]) => [
171
+ walk(k, '', patterns, hits),
172
+ walk(x, k === 'value' && named !== null ? named : k, patterns, hits),
173
+ ]),
174
+ )
175
+ }
176
+ return v
177
+ }
178
+
179
+ // Returns a copy of `value` with every match replaced by `[REDACTED:<id>]`, plus the
180
+ // patterns that fired (catalog order, unique). Keys are redacted too; two keys that redact
181
+ // to the same marker collapse into one, which loses data but never leaks it.
182
+ export function redactValue(value, patterns) {
183
+ const hits = new Set()
184
+ const out = walk(value, '', patterns, hits)
185
+ const order = [...patterns, OVERFLOW_HIT]
186
+ return { value: out, hits: order.filter((p) => hits.has(p)) }
187
+ }
188
+
189
+ // Same shape as `value`, every string replaced by `text`. The fallback when redaction
190
+ // itself failed: withhold everything rather than pass anything through.
191
+ export function maskValue(value, text) {
192
+ if (typeof value === 'string') return text
193
+ if (Array.isArray(value)) return value.map((v) => maskValue(v, text))
194
+ if (value !== null && typeof value === 'object') {
195
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, maskValue(v, text)]))
196
+ }
197
+ return value
198
+ }
199
+
200
+ // JSON with object keys sorted at every level, so equal values hash equally.
201
+ export function canonicalJson(value) {
202
+ if (Array.isArray(value)) return '[' + value.map((v) => (v === undefined ? 'null' : canonicalJson(v))).join(',') + ']'
203
+ if (value !== null && typeof value === 'object') {
204
+ const keys = Object.keys(value).filter((k) => value[k] !== undefined).sort()
205
+ return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonicalJson(value[k])).join(',') + '}'
206
+ }
207
+ return JSON.stringify(value) ?? 'null'
208
+ }
209
+
210
+ export async function sha256Hex(text) {
211
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
212
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('')
213
+ }
@@ -0,0 +1,140 @@
1
+ // Command-hook runtime for the mods under mods/. scripts/generate-mods.mjs copies this file
2
+ // byte-for-byte to mods/<id>/lib/runtime.mjs, so edit it here and run `npm run mods:write`.
3
+ //
4
+ // A mod's bin/hook.mjs hands its handlers to runHook, which reads the harness payload from
5
+ // stdin and renders the handler's decision in that harness's protocol. It writes no files
6
+ // and reads no environment; Claude Code's native runtime never imports it.
7
+ import { readFileSync } from 'node:fs'
8
+ import { isAbsolute, resolve, sep } from 'node:path'
9
+
10
+ const HARNESSES = new Set(['claude-code', 'kiro', 'codex'])
11
+ const EVENTS = new Set(['PreToolUse', 'PostToolUse', 'SessionStart'])
12
+ const DECISIONS = new Set(['allow', 'deny', 'ask', 'replace', 'context'])
13
+
14
+ const nodeIo = () => ({
15
+ argv: process.argv.slice(2),
16
+ readStdin: () => readFileSync(0, 'utf8'),
17
+ out: (s) => process.stdout.write(s),
18
+ err: (s) => process.stderr.write(s),
19
+ })
20
+
21
+ const message = (err) => (err instanceof Error ? err.message : String(err))
22
+
23
+ // JSON.parse errors quote the text they failed on, and stdin can carry a tool's input or
24
+ // output: report the failure without echoing any of it.
25
+ function parseStdin(text) {
26
+ try {
27
+ return JSON.parse(text)
28
+ } catch {
29
+ throw new Error('stdin is not valid JSON')
30
+ }
31
+ }
32
+
33
+ export function parseArgs(argv) {
34
+ const usage = 'usage: hook.mjs --harness <claude-code|kiro|codex> --event <PreToolUse|PostToolUse|SessionStart>'
35
+ if (argv.length !== 4) throw new Error(usage)
36
+ const args = {}
37
+ for (let i = 0; i < 4; i += 2) {
38
+ const key = { '--harness': 'harness', '--event': 'event' }[argv[i]]
39
+ if (!key || key in args) throw new Error(usage)
40
+ args[key] = argv[i + 1]
41
+ }
42
+ if (!HARNESSES.has(args.harness)) throw new Error(`unknown harness ${args.harness}; ${usage}`)
43
+ if (!EVENTS.has(args.event)) throw new Error(`unknown event ${args.event}; ${usage}`)
44
+ return args
45
+ }
46
+
47
+ // Where an observer writes `path`. A relative path resolves against the project root when
48
+ // the hook runs from its install location <root>/.<harness dir>/vanguard-mods/<id>/bin/,
49
+ // otherwise against the working directory. Never CLAUDE_PROJECT_DIR: mods read only their
50
+ // own VANGUARD_<ID>_* variables.
51
+ export function projectPath(path, harness, binDir) {
52
+ if (isAbsolute(path)) return path
53
+ const parts = resolve(binDir).split(sep)
54
+ const n = parts.length
55
+ const dir = { 'claude-code': '.claude', kiro: '.kiro', codex: '.codex' }[harness]
56
+ const installed = n >= 5 && parts[n - 1] === 'bin' && parts[n - 3] === 'vanguard-mods' && parts[n - 4] === dir
57
+ return resolve(installed ? parts.slice(0, n - 4).join(sep) || sep : process.cwd(), path)
58
+ }
59
+
60
+ // Rejects decisions the harness cannot express, so a handler bug surfaces as an error
61
+ // instead of a silently dropped verdict.
62
+ function normalize(d, { harness, event }) {
63
+ if (d === undefined) return { decision: 'allow', log: [] }
64
+ if (d === null || typeof d !== 'object' || !DECISIONS.has(d.decision)) {
65
+ throw new Error(`handler returned an invalid decision: ${JSON.stringify(d)}`)
66
+ }
67
+ const log = d.log ?? []
68
+ if (!Array.isArray(log) || !log.every((l) => typeof l === 'string')) throw new Error('decision log must be a string array')
69
+ const needs = { deny: 'reason', ask: 'reason', context: 'text' }[d.decision]
70
+ if (needs && (typeof d[needs] !== 'string' || d[needs] === '')) throw new Error(`${d.decision} needs a ${needs}`)
71
+ if ((d.decision === 'deny' || d.decision === 'ask') && event !== 'PreToolUse') {
72
+ throw new Error(`${d.decision} is only valid for PreToolUse, not ${event}`)
73
+ }
74
+ if (d.decision === 'replace' && (harness !== 'claude-code' || event !== 'PostToolUse')) {
75
+ throw new Error(`replace is only valid for claude-code PostToolUse, not ${harness} ${event}`)
76
+ }
77
+ return { ...d, log }
78
+ }
79
+
80
+ function render(d, { harness, event }, io) {
81
+ const json = (hookSpecificOutput) => io.out(JSON.stringify({ hookSpecificOutput: { hookEventName: event, ...hookSpecificOutput } }) + '\n')
82
+ for (const line of d.log) io.err(line + '\n')
83
+ switch (d.decision) {
84
+ case 'allow':
85
+ return 0
86
+ case 'deny':
87
+ case 'ask':
88
+ if (harness === 'claude-code') {
89
+ json({ permissionDecision: d.decision, permissionDecisionReason: d.reason })
90
+ return 0
91
+ }
92
+ // Kiro and Codex have no confirmation step; exit 2 blocks the call in both.
93
+ io.err(d.decision === 'ask' ? `${d.reason} (confirmation unsupported on ${harness}; denied)\n` : `${d.reason}\n`)
94
+ return 2
95
+ case 'replace':
96
+ json({ updatedToolOutput: d.output })
97
+ return 0
98
+ case 'context':
99
+ if (harness === 'kiro') io.err(d.text + '\n')
100
+ else json({ additionalContext: d.text })
101
+ return 0
102
+ }
103
+ }
104
+
105
+ // Runs one hook invocation and returns the exit code; bin/hook.mjs sets process.exitCode
106
+ // with it rather than calling process.exit, so buffered stdout is never cut short.
107
+ //
108
+ // - Bad arguments, or an event this mod has no handler for: exit 2, which blocks a
109
+ // PreToolUse call in every harness (a broken install must not allow silently).
110
+ // - Invalid stdin or a throwing handler: `onError(err, payload, ctx)` supplies the decision
111
+ // (guards deny, the redactor withholds). Without onError: stderr and exit 1, which is
112
+ // loud but does not block.
113
+ // - An onError that throws or returns an invalid decision: exit 2.
114
+ export async function runHook({ name, handlers, onError }, io = nodeIo()) {
115
+ let ctx
116
+ try {
117
+ ctx = parseArgs(io.argv)
118
+ if (!Object.hasOwn(handlers, ctx.event)) throw new Error(`no handler for ${ctx.event}`)
119
+ } catch (err) {
120
+ io.err(`${name}: ${message(err)}\n`)
121
+ return 2
122
+ }
123
+ let payload
124
+ let decision
125
+ try {
126
+ payload = parseStdin(io.readStdin())
127
+ if (payload === null || typeof payload !== 'object' || Array.isArray(payload)) throw new Error('stdin is not a JSON object')
128
+ decision = normalize(await handlers[ctx.event](payload, ctx), ctx)
129
+ } catch (err) {
130
+ io.err(`${name}: ${message(err)}\n`)
131
+ if (typeof onError !== 'function') return 1
132
+ try {
133
+ decision = normalize(await onError(err, payload, ctx), ctx)
134
+ } catch (err2) {
135
+ io.err(`${name}: error handler failed: ${message(err2)}\n`)
136
+ return 2
137
+ }
138
+ }
139
+ return render(decision, ctx, io)
140
+ }
@@ -66,4 +66,4 @@ The grader provides three structural guarantees:
66
66
 
67
67
  - <!-- count:global:maestros -->35<!-- /count --> maestros covered, one routing fixture directory each
68
68
  - <!-- count:global:scenarios -->840<!-- /count --> scenarios validated
69
- - enforced by `validate:maestro-routing`, one of the <!-- count:global:gates -->29<!-- /count --> `npm run validate` gates
69
+ - enforced by `validate:maestro-routing`, one of the <!-- count:global:gates -->30<!-- /count --> `npm run validate` gates
@@ -12,8 +12,19 @@
12
12
  */
13
13
 
14
14
  import assert from "node:assert/strict";
15
+ import { execFileSync } from "node:child_process";
16
+ import { createHash } from "node:crypto";
17
+ import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
18
+ import { tmpdir } from "node:os";
15
19
  import path from "node:path";
20
+ import { fileURLToPath } from "node:url";
16
21
  import fc from "fast-check";
22
+ import { redactValue, stringLeaves } from "../mods/secret-redactor/lib/common.mjs";
23
+ import { loadPatterns } from "../mods/secret-redactor/lib/core.mjs";
24
+ import { checkToolUse, compileGuardPatterns } from "../mods/blast-radius-guard/lib/core.mjs";
25
+ import { buildRecord, lastSequence } from "../mods/audit-trail/lib/core.mjs";
26
+ import { canonicalJson } from "../mods/audit-trail/lib/common.mjs";
27
+ import { loadMods, parseToml, renderAll } from "../scripts/generate-mods.mjs";
17
28
  import {
18
29
  AGENT_ID_PATTERN,
19
30
  HARNESS_PATH_TRAVERSAL,
@@ -188,4 +199,247 @@ for (const [alias, canonical] of Object.entries(ALIASES)) {
188
199
  }
189
200
  console.log("PASS normalizePlatform: known aliases resolve to canonical form");
190
201
 
202
+ // ── 5. Cross-harness mods: production exports, fixed-seed properties ──────────
203
+
204
+ const MOD_FUZZ = { seed: 20261014, numRuns: 200 };
205
+ const ROOT = fileURLToPath(new URL("../", import.meta.url));
206
+ const redactorPatterns = loadPatterns();
207
+ const guardPatterns = compileGuardPatterns();
208
+ const shortText = fc.string({ maxLength: 40 });
209
+ const primitive = fc.oneof(shortText, fc.boolean(), fc.integer(), fc.constant(null));
210
+ const metadata = fc.dictionary(safeSegment, primitive, { maxKeys: 4 });
211
+ const token = (regex) => fc.stringMatching(regex);
212
+ const secret = fc.oneof(
213
+ token(/^[A-Za-z0-9]{36,48}$/).map((body) => ({ id: "github-pat", text: "gh" + "p_" + body })),
214
+ token(/^[A-Za-z0-9_]{22,48}$/).map((body) => ({ id: "github-fine-grained-pat", text: "github_" + "pat_" + body })),
215
+ token(/^[A-Z0-9]{16}$/).map((body) => ({ id: "aws-access-key", text: "AK" + "IA" + body })),
216
+ token(/^[A-Za-z0-9/+]{40,48}$/).map((body) => ({ id: "aws-secret-key", text: "aws_secret_access_key=" + body })),
217
+ token(/^[A-Za-z0-9._~+/-]{16,48}$/).map((body) => ({ id: "generic-bearer", text: "Bearer " + body })),
218
+ fc.tuple(safeSegment, safeSegment).map(([user, password]) => ({ id: "password-in-url", text: `https://${user}:${password}@example.invalid` })),
219
+ );
220
+
221
+ // Shape is independent of the redaction algorithm: safe keys stay put, all container
222
+ // lengths/types survive, and non-string leaves are never altered.
223
+ function assertShape(before, after) {
224
+ if (typeof before === "string") {
225
+ assert.equal(typeof after, "string");
226
+ } else if (Array.isArray(before)) {
227
+ assert.equal(Array.isArray(after), true);
228
+ assert.equal(after.length, before.length);
229
+ before.forEach((value, i) => assertShape(value, after[i]));
230
+ } else if (before !== null && typeof before === "object") {
231
+ assert.deepEqual(Object.keys(after), Object.keys(before));
232
+ Object.entries(before).forEach(([key, value]) => assertShape(value, after[key]));
233
+ } else {
234
+ assert.equal(after, before);
235
+ }
236
+ }
237
+
238
+ fc.assert(
239
+ fc.property(secret, shortText, shortText, metadata, fc.array(primitive, { maxLength: 5 }), (credential, before, after, data, values) => {
240
+ const input = {
241
+ metadata: data,
242
+ values,
243
+ nested: [{ text: `${before}\n${credential.text}\n${after}` }, null, 17, false],
244
+ // Contextual and split credentials exercise the real sibling/key handling too.
245
+ argv: ["Bearer", "x".repeat(24)],
246
+ named: { name: "aws_secret_access_key", value: "z".repeat(40) },
247
+ };
248
+ const snapshot = JSON.stringify(input);
249
+ const redacted = redactValue(input, redactorPatterns);
250
+ assert.ok(redacted.hits.some((hit) => hit.id === credential.id));
251
+ assertShape(input, redacted.value);
252
+ assert.equal(JSON.stringify(input), snapshot, "redaction must not mutate its input");
253
+ for (const leaf of stringLeaves(redacted.value)) {
254
+ for (const pattern of redactorPatterns) {
255
+ assert.equal(pattern.rx.test(leaf), false, `residual ${pattern.id}`);
256
+ }
257
+ }
258
+ const again = redactValue(redacted.value, redactorPatterns);
259
+ assert.deepEqual(again.value, redacted.value);
260
+ assert.deepEqual(again.hits, []);
261
+ }),
262
+ MOD_FUZZ,
263
+ );
264
+ console.log("PASS mods P1: complete, shape-preserving, fixed-point redaction (200 runs, seed 20261014)");
265
+
266
+ const anchoredPatterns = loadPatterns(JSON.stringify([{
267
+ id: "anchored-custom", name: "Anchored custom", regex: "^custom_[a-z]{8}$",
268
+ flags: "", context: ["tool-input", "tool-output"],
269
+ }]));
270
+ fc.assert(
271
+ fc.property(token(/^[a-z]{8}$/), (suffix) => {
272
+ const text = "custom_" + suffix;
273
+ const input = { nested: [{ text }], argv: ["prefix", text], count: 1 };
274
+ const result = redactValue(input, anchoredPatterns);
275
+ assertShape(input, result.value);
276
+ assert.deepEqual(result.hits.map((hit) => hit.id), ["anchored-custom"]);
277
+ assert.ok(!JSON.stringify(result.value).includes(text));
278
+ assert.deepEqual(redactValue(result.value, anchoredPatterns), { value: result.value, hits: [] });
279
+ }),
280
+ MOD_FUZZ,
281
+ );
282
+ console.log("PASS mods P1: anchored extensions redact nested and argv leaves (200 runs, seed 20261014)");
283
+
284
+ const dangerousCommand = fc.constantFrom(
285
+ ["rm-rf-root-or-home", "rm -rf /"],
286
+ ["sql-drop-object", "DROP TABLE important"],
287
+ ["git-force-push-protected", "git push --force origin main"],
288
+ ["pipe-remote-to-shell", "curl https://example.invalid/install | bash"],
289
+ ["remote-script-substitution", "bash <(curl https://example.invalid/install)"],
290
+ ["terraform-destroy-auto-approve", "terraform destroy -auto-approve"],
291
+ ["kubectl-delete-namespace", "kubectl delete namespace production"],
292
+ ["kubectl-delete-all", "kubectl delete pods --all"],
293
+ );
294
+
295
+ fc.assert(
296
+ fc.property(dangerousCommand, shortText, shortText, fc.boolean(), safeSegment, ([id, command], before, after, argv, filename) => {
297
+ const input = {
298
+ nested: { execution: argv ? command.split(" ") : `${before}\n${command}\n${after}` },
299
+ notes: [before, after],
300
+ };
301
+ const snapshot = structuredClone(input);
302
+ for (const mode of ["confirm", "block"]) {
303
+ const verdict = checkToolUse({ tool: "Bash", input }, guardPatterns, mode);
304
+ assert.ok(verdict, `guard passed dangerous ${id}`);
305
+ assert.equal(verdict.decision, mode === "confirm" ? "ask" : "deny");
306
+ assert.ok(verdict.reason.includes(guardPatterns.find((pattern) => pattern.id === id).name));
307
+ for (const tool of ["Write", undefined]) {
308
+ const system = checkToolUse({ tool, input: { nested: { file_path: `/tmp/${filename}/../../etc/${filename}` } } }, guardPatterns, mode);
309
+ assert.ok(system, "normalized system path passed the guard");
310
+ assert.equal(system.decision, mode === "confirm" ? "ask" : "deny");
311
+ }
312
+ }
313
+ assert.deepEqual(input, snapshot);
314
+ }),
315
+ MOD_FUZZ,
316
+ );
317
+ console.log("PASS mods P2: dangerous commands/argv and normalized system writes never pass (200 runs, seed 20261014)");
318
+
319
+ const auditHarnesses = ["claude-code", "codex", "kiro"];
320
+ const auditEvent = fc.record({
321
+ tool_input: fc.jsonValue({ maxDepth: 3 }),
322
+ tool_response: fc.jsonValue({ maxDepth: 3 }),
323
+ });
324
+
325
+ async function assertAuditSequence(events, sessionId, harness) {
326
+ const directory = mkdtempSync(path.join(tmpdir(), "vfa-audit-property-"));
327
+ try {
328
+ const payloads = events.map((event) => ({ session_id: sessionId, tool_name: "Read", ...event }));
329
+ for (const payload of payloads) {
330
+ const stdout = execFileSync(process.execPath, [path.join(ROOT, "mods/audit-trail/bin/hook.mjs"), "--harness", harness, "--event", "PostToolUse"], {
331
+ input: JSON.stringify(payload),
332
+ encoding: "utf8",
333
+ timeout: 5000,
334
+ env: { ...process.env, VANGUARD_AUDIT_TRAIL_LOG_DIR: directory, VANGUARD_AUDIT_TRAIL_SESSION_ID: sessionId, VANGUARD_AUDIT_TRAIL_AGENT_ID: "property-test-agent" },
335
+ });
336
+ assert.equal(stdout, "");
337
+ }
338
+ const days = readdirSync(directory);
339
+ assert.equal(days.length, 1);
340
+ assert.deepEqual(readdirSync(path.join(directory, days[0])), [`${sessionId}.jsonl`], "append must release its lock");
341
+ const text = readFileSync(path.join(directory, days[0], `${sessionId}.jsonl`), "utf8");
342
+ assert.ok(text.endsWith("\n"));
343
+ const records = text.trimEnd().split("\n").map((line) => JSON.parse(line));
344
+ assert.equal(records.length, events.length);
345
+ assert.deepEqual(records.map((record) => record.sequence_number), events.map((_, i) => i + 1));
346
+ assert.equal(lastSequence(text), events.length);
347
+ for (const [i, record] of records.entries()) {
348
+ assert.equal(new Date(record.timestamp).toISOString(), record.timestamp);
349
+ assert.deepEqual(record, await buildRecord({ timestamp: record.timestamp, sessionId, agentId: "property-test-agent", payload: payloads[i], harness, sequence: i + 1 }));
350
+ const hash = (value) => createHash("sha256").update(canonicalJson(value)).digest("hex");
351
+ assert.equal(record.args_hash, hash(harness === "kiro" ? payloads[i] : payloads[i].tool_input));
352
+ assert.equal(record.result_hash, hash(harness === "kiro" ? null : payloads[i].tool_response));
353
+ }
354
+ } finally {
355
+ rmSync(directory, { recursive: true, force: true });
356
+ }
357
+ }
358
+
359
+ // Choose N explicitly so fast-check's default array size bias cannot narrow the workload.
360
+ const auditSequence = fc.integer({ min: 1, max: 50 })
361
+ .chain((length) => fc.array(auditEvent, { minLength: length, maxLength: length }));
362
+ await fc.assert(
363
+ fc.asyncProperty(auditSequence, safeSegment, fc.constantFrom(...auditHarnesses), assertAuditSequence),
364
+ MOD_FUZZ,
365
+ );
366
+ console.log("PASS mods P3: actual audit hook appends N records with sequence 1..N and nested JSON hashes (200 runs, N=1..50, seed 20261014)");
367
+
368
+ const boundaryEvents = Array.from({ length: 50 }, (_, i) => ({
369
+ tool_input: { nested: [{ index: i, values: [null, true, false, i + 0.5, "line\nvalue"] }] },
370
+ tool_response: [null, { nested: { index: i, values: ["result", false] } }],
371
+ }));
372
+ // Prototypes are not part of JSON's wire contract; null-prototype input remains valid.
373
+ const nullPrototypeInput = Object.assign(Object.create(null), {
374
+ nested: Object.assign(Object.create(null), { values: [null, true, 1.5, { text: "value" }] }),
375
+ });
376
+ assert.equal(Object.getPrototypeOf(nullPrototypeInput), null);
377
+ assert.deepEqual(JSON.parse(JSON.stringify(nullPrototypeInput)), { nested: { values: [null, true, 1.5, { text: "value" }] } });
378
+ for (const harness of auditHarnesses) {
379
+ for (const count of [1, 50]) {
380
+ await assertAuditSequence(boundaryEvents.slice(0, count), `boundary-${count}`, harness);
381
+ }
382
+ await assertAuditSequence([{ tool_input: nullPrototypeInput, tool_response: { ok: true, values: [null, [1, 2]] } }], "null-prototype", harness);
383
+ }
384
+ console.log("PASS mods P3: explicit N=1/50 and JSON-compatible null-prototype input across claude-code, codex and kiro");
385
+
386
+ const tomlString = fc.array(fc.oneof(fc.integer({ min: 0, max: 0xd7ff }), fc.integer({ min: 0xe000, max: 0x10ffff })), { maxLength: 20 })
387
+ .map((points) => String.fromCodePoint(...points));
388
+ const tomlValue = fc.oneof(tomlString, fc.integer(), fc.boolean(), fc.array(tomlString, { maxLength: 4 }));
389
+ const tomlTable = fc.dictionary(safeSegment.map((key) => `key-${key}`), tomlValue, { maxKeys: 4 })
390
+ .map((value) => Object.fromEntries(Object.entries(value)));
391
+
392
+ // An output-only test oracle, not a second parser. It emits valid TOML basic strings
393
+ // (JSON's \b and \f escapes are not TOML) and scalars before their child tables.
394
+ function tomlQuote(value) {
395
+ return '"' + [...value].map((character) => {
396
+ const escapes = { '"': '\\"', "\\": "\\\\", "\n": "\\n", "\r": "\\r", "\t": "\\t" };
397
+ if (Object.hasOwn(escapes, character)) return escapes[character];
398
+ const code = character.codePointAt(0);
399
+ return code < 0x20 || code === 0x7f ? `\\u${code.toString(16).padStart(4, "0")}` : character;
400
+ }).join("") + '"';
401
+ }
402
+
403
+ function serializeToml(value, table = []) {
404
+ const entries = Object.entries(value);
405
+ const isTable = (entry) => entry !== null && typeof entry === "object" && !Array.isArray(entry);
406
+ const scalar = (entry) => typeof entry === "string" ? tomlQuote(entry) : Array.isArray(entry) ? `[${entry.map(tomlQuote).join(", ")}]` : String(entry);
407
+ const lines = table.length ? [`[${table.join(".")}]`] : [];
408
+ for (const [key, entry] of entries) if (!isTable(entry)) lines.push(`${key} = ${scalar(entry)} # scalar`);
409
+ for (const [key, entry] of entries) if (isTable(entry)) lines.push(serializeToml(entry, [...table, key]));
410
+ return lines.join("\n") + "\n";
411
+ }
412
+
413
+ const loadedMods = loadMods(ROOT);
414
+ assert.deepEqual(loadedMods.errors, []);
415
+ fc.assert(
416
+ fc.property(tomlTable, tomlTable, tomlTable, fc.boolean(), (root, first, second, crlf) => {
417
+ const value = { ...root, first, nested: { second } };
418
+ let text = "# generated subset oracle\n" + serializeToml(value);
419
+ if (crlf) text = text.replaceAll("\n", "\r\n");
420
+ assert.deepEqual(parseToml(text, "property.toml"), value);
421
+ const parsedMods = loadedMods.mods.map((mod) => ({ ...mod, manifest: parseToml(serializeToml(mod.manifest), `${mod.id}.toml`) }));
422
+ const rendered = renderAll(parsedMods, loadedMods.ctx);
423
+ assert.deepEqual(JSON.parse(rendered.get("catalog/mods.json")), loadedMods.mods.toSorted((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0).map(({ id, manifest }) => ({
424
+ id, name: manifest.mod.name, version: manifest.mod.version, description: manifest.mod.description,
425
+ reach_level: manifest.mod.reach_level, events: manifest.mod.events,
426
+ harnesses: Object.keys(manifest.harnesses).filter((harness) => manifest.harnesses[harness].supported).sort(),
427
+ path: `mods/${id}`,
428
+ footprint: manifest.footprint,
429
+ })));
430
+ }),
431
+ MOD_FUZZ,
432
+ );
433
+ console.log("PASS mods P4: TOML subset and production catalog round-trip through serializer oracle (200 runs, seed 20261014)");
434
+
435
+ const generated = [...renderAll(loadedMods.mods, loadedMods.ctx)];
436
+ fc.assert(
437
+ fc.property(fc.shuffledSubarray(loadedMods.mods, { minLength: loadedMods.mods.length, maxLength: loadedMods.mods.length }), (permutation) => {
438
+ assert.deepEqual([...renderAll(permutation, loadedMods.ctx)], generated);
439
+ assert.deepEqual([...renderAll(permutation, loadedMods.ctx)], generated, "repeat rendering must be byte-identical too");
440
+ }),
441
+ MOD_FUZZ,
442
+ );
443
+ console.log("PASS mods P5: renderAll is deterministic and permutation-invariant (200 runs, seed 20261014)");
444
+
191
445
  console.log("\nAll fuzz properties passed.");