@ornexus/neocortex 4.60.73 → 4.60.75

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 (269) hide show
  1. package/dist/release-source.json +1 -1
  2. package/dist/sbom.cdx.json +1216 -1210
  3. package/install.ps1 +1 -1
  4. package/install.sh +1 -1
  5. package/package.json +2 -2
  6. package/packages/client/dist/adapters/adapter-registry.js +1 -108
  7. package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
  8. package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
  9. package/packages/client/dist/adapters/codex-adapter.js +2 -80
  10. package/packages/client/dist/adapters/cursor-adapter.js +4 -115
  11. package/packages/client/dist/adapters/gemini-adapter.js +2 -71
  12. package/packages/client/dist/adapters/grok-adapter.js +2 -42
  13. package/packages/client/dist/adapters/index.js +1 -22
  14. package/packages/client/dist/adapters/platform-detector.js +1 -212
  15. package/packages/client/dist/adapters/target-adapter.js +0 -12
  16. package/packages/client/dist/adapters/vscode-adapter.js +2 -72
  17. package/packages/client/dist/agent/refresh-stubs.js +2 -417
  18. package/packages/client/dist/agent/update-agent-yaml.js +1 -102
  19. package/packages/client/dist/agent/update-description.js +1 -251
  20. package/packages/client/dist/cache/crypto-utils.js +1 -78
  21. package/packages/client/dist/cache/encrypted-cache.d.ts +27 -0
  22. package/packages/client/dist/cache/encrypted-cache.js +1 -108
  23. package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
  24. package/packages/client/dist/cache/index.js +1 -13
  25. package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
  26. package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
  27. package/packages/client/dist/checkpoint/index.js +1 -11
  28. package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
  29. package/packages/client/dist/cli.js +5 -358
  30. package/packages/client/dist/commands/activate.js +8 -394
  31. package/packages/client/dist/commands/architecture-answers.js +7 -274
  32. package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
  33. package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
  34. package/packages/client/dist/commands/architecture-root-binding.js +1 -51
  35. package/packages/client/dist/commands/cache-status.js +2 -112
  36. package/packages/client/dist/commands/config.js +1 -88
  37. package/packages/client/dist/commands/doctor.js +2 -635
  38. package/packages/client/dist/commands/invoke.d.ts +38 -1
  39. package/packages/client/dist/commands/invoke.js +143 -7200
  40. package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
  41. package/packages/client/dist/commands/legacy-story-branch.js +1 -96
  42. package/packages/client/dist/commands/legacy-story-pr.js +1 -276
  43. package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
  44. package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
  45. package/packages/client/dist/commands/mutation-qa-git.js +1 -41
  46. package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
  47. package/packages/client/dist/commands/mutation-qa-run.js +3 -219
  48. package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
  49. package/packages/client/dist/commands/mutation-qa.js +1 -220
  50. package/packages/client/dist/commands/native-agent.js +2 -136
  51. package/packages/client/dist/commands/planning-diagnosis.js +1 -43
  52. package/packages/client/dist/commands/planning-generation.js +1 -53
  53. package/packages/client/dist/commands/planning-memory.js +1 -40
  54. package/packages/client/dist/commands/planning-research.js +1 -42
  55. package/packages/client/dist/commands/private-session.js +1 -75
  56. package/packages/client/dist/commands/property-qa.js +1 -139
  57. package/packages/client/dist/commands/qa-control.js +1 -16
  58. package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
  59. package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
  60. package/packages/client/dist/commands/qa-scan-capture.js +5 -663
  61. package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
  62. package/packages/client/dist/commands/qa-scan-review.js +5 -826
  63. package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
  64. package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
  65. package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
  66. package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
  67. package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
  68. package/packages/client/dist/commands/refactor-characterization.js +21 -671
  69. package/packages/client/dist/commands/refactor-commit.js +13 -399
  70. package/packages/client/dist/commands/refactor-control.js +3 -142
  71. package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
  72. package/packages/client/dist/commands/refactor-review.js +5 -283
  73. package/packages/client/dist/commands/refactor-root.js +7 -588
  74. package/packages/client/dist/commands/refresh-memory.js +3 -156
  75. package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
  76. package/packages/client/dist/commands/story-checkpoint.js +1 -171
  77. package/packages/client/dist/config/host-auth-broker.d.ts +31 -0
  78. package/packages/client/dist/config/host-auth-broker.js +1 -0
  79. package/packages/client/dist/config/host-auth-reference.d.ts +32 -0
  80. package/packages/client/dist/config/host-auth-reference.js +1 -0
  81. package/packages/client/dist/config/profile-directory.js +1 -13
  82. package/packages/client/dist/config/resolver-selection.js +1 -278
  83. package/packages/client/dist/config/secure-config.js +12 -281
  84. package/packages/client/dist/config.js +2 -223
  85. package/packages/client/dist/constants.js +1 -25
  86. package/packages/client/dist/context/context-collector.js +2 -222
  87. package/packages/client/dist/context/context-sanitizer.js +1 -145
  88. package/packages/client/dist/continuity/autonomous-governance.js +1 -285
  89. package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
  90. package/packages/client/dist/continuity/invoke-hooks.js +1 -129
  91. package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
  92. package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
  93. package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
  94. package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
  95. package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
  96. package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
  97. package/packages/client/dist/continuity/native-agent-store.js +1 -69
  98. package/packages/client/dist/continuity/native-agent-types.d.ts +11 -0
  99. package/packages/client/dist/continuity/native-agent-types.js +1 -90
  100. package/packages/client/dist/continuity/outbox.js +1 -117
  101. package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
  102. package/packages/client/dist/continuity/sqlite-store.js +81 -2612
  103. package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
  104. package/packages/client/dist/errors/error-messages.d.ts +3 -0
  105. package/packages/client/dist/errors/error-messages.js +2 -228
  106. package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
  107. package/packages/client/dist/evidence/collector.js +1 -347
  108. package/packages/client/dist/evidence/index.js +1 -1
  109. package/packages/client/dist/evidence/types.js +0 -2
  110. package/packages/client/dist/fs/atomic-state-replace.js +1 -152
  111. package/packages/client/dist/generated/command-registry.generated.js +1 -4076
  112. package/packages/client/dist/generated/public-projections.generated.js +1 -149
  113. package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
  114. package/packages/client/dist/git/direct-yolo-checkpoint.d.ts +11 -1
  115. package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
  116. package/packages/client/dist/git/epic-operational-state.js +2 -672
  117. package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
  118. package/packages/client/dist/git/git-lifecycle-store.d.ts +23 -0
  119. package/packages/client/dist/git/git-lifecycle-store.js +10 -1981
  120. package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
  121. package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
  122. package/packages/client/dist/git/legacy-story-pr.js +70 -3538
  123. package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
  124. package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
  125. package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
  126. package/packages/client/dist/i18n/first-run.js +2 -60
  127. package/packages/client/dist/index.d.ts +2 -0
  128. package/packages/client/dist/index.js +1 -47
  129. package/packages/client/dist/invocation/invoke-input.js +1 -24
  130. package/packages/client/dist/license/host-auth-recovery.d.ts +158 -0
  131. package/packages/client/dist/license/host-auth-recovery.js +1 -0
  132. package/packages/client/dist/license/index.js +1 -5
  133. package/packages/client/dist/license/license-client.d.ts +10 -1
  134. package/packages/client/dist/license/license-client.js +1 -304
  135. package/packages/client/dist/machine/fingerprint.js +2 -163
  136. package/packages/client/dist/machine/index.js +1 -5
  137. package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
  138. package/packages/client/dist/memory/project-memory-writer.js +40 -1007
  139. package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
  140. package/packages/client/dist/migrations/epic-lifecycle-backfill.js +3 -1060
  141. package/packages/client/dist/migrations/project-identity-capability.js +1 -50
  142. package/packages/client/dist/migrations/project-identity.js +7 -493
  143. package/packages/client/dist/migrations/state-json.js +4 -393
  144. package/packages/client/dist/policy/architecture-policy.js +2 -184
  145. package/packages/client/dist/policy/index.js +1 -7
  146. package/packages/client/dist/policy/shared-policy-types.js +0 -38
  147. package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
  148. package/packages/client/dist/private-execution/clean-baseline.js +2 -279
  149. package/packages/client/dist/private-execution/codex-executor.js +4 -574
  150. package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
  151. package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
  152. package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
  153. package/packages/client/dist/private-execution/delivery.js +13 -410
  154. package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
  155. package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
  156. package/packages/client/dist/private-execution/implementation-validation.js +2 -106
  157. package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
  158. package/packages/client/dist/private-execution/isolated-session.js +5 -725
  159. package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
  160. package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
  161. package/packages/client/dist/private-execution/pact-test-source.js +1 -258
  162. package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
  163. package/packages/client/dist/private-execution/pact-write-set.js +1 -172
  164. package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
  165. package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
  166. package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
  167. package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
  168. package/packages/client/dist/private-execution/private-report-store.js +1 -42
  169. package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
  170. package/packages/client/dist/private-execution/property-test-choices.js +3 -147
  171. package/packages/client/dist/private-execution/property-test-plan.js +7 -271
  172. package/packages/client/dist/private-execution/property-test-review.js +4 -258
  173. package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
  174. package/packages/client/dist/private-execution/property-test-source.js +1 -139
  175. package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
  176. package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
  177. package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
  178. package/packages/client/dist/private-execution/root-memory-request.js +1 -29
  179. package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
  180. package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
  181. package/packages/client/dist/private-execution/session-lease.js +1 -63
  182. package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
  183. package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
  184. package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
  185. package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
  186. package/packages/client/dist/private-execution/ux-write-set.js +2 -191
  187. package/packages/client/dist/registry/registry-reconciliation.js +1 -234
  188. package/packages/client/dist/resilience/circuit-breaker.js +1 -170
  189. package/packages/client/dist/resilience/degradation-manager.js +1 -164
  190. package/packages/client/dist/resilience/freshness-indicator.js +1 -100
  191. package/packages/client/dist/resilience/index.js +1 -8
  192. package/packages/client/dist/resilience/recovery-detector.js +1 -74
  193. package/packages/client/dist/resolvers/asset-resolver.js +0 -13
  194. package/packages/client/dist/resolvers/local-resolver.js +8 -255
  195. package/packages/client/dist/resolvers/remote-resolver.js +1 -233
  196. package/packages/client/dist/runner/binary.js +1 -404
  197. package/packages/client/dist/runner/cli.js +17 -1571
  198. package/packages/client/dist/runner/epic-background-dispatcher.d.ts +61 -0
  199. package/packages/client/dist/runner/epic-background-dispatcher.js +1 -0
  200. package/packages/client/dist/runner/headless/adapters.js +1 -49
  201. package/packages/client/dist/runner/headless/background-root.d.ts +65 -0
  202. package/packages/client/dist/runner/headless/background-root.js +1 -0
  203. package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
  204. package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
  205. package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
  206. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.d.ts +1 -1
  207. package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
  208. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.d.ts +2 -0
  209. package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +10 -1236
  210. package/packages/client/dist/runner/headless/epic-terminal-git-runner.d.ts +27 -2
  211. package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
  212. package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
  213. package/packages/client/dist/runner/headless/managed-environment-cleanup.d.ts +95 -0
  214. package/packages/client/dist/runner/headless/managed-environment-cleanup.js +1 -0
  215. package/packages/client/dist/runner/headless/managed-profile.js +1 -132
  216. package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
  217. package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
  218. package/packages/client/dist/runner/headless/resolver.js +1 -231
  219. package/packages/client/dist/runner/headless/run-yolo.js +1 -885
  220. package/packages/client/dist/runner/headless/run-yoloop.d.ts +1 -0
  221. package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
  222. package/packages/client/dist/runner/headless/types.js +2 -574
  223. package/packages/client/dist/runner/local-console.js +13 -396
  224. package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
  225. package/packages/client/dist/runner/project-identity.js +1 -106
  226. package/packages/client/dist/runner/scheduler.js +7 -995
  227. package/packages/client/dist/runner-cli.js +2 -18
  228. package/packages/client/dist/state/invocation-shape.js +1 -13
  229. package/packages/client/dist/state/project-state-snapshot.d.ts +7 -0
  230. package/packages/client/dist/state/project-state-snapshot.js +1 -1731
  231. package/packages/client/dist/state/state-json-repair.js +3 -785
  232. package/packages/client/dist/state/structural-dag-projection.js +1 -118
  233. package/packages/client/dist/telemetry/index.js +1 -5
  234. package/packages/client/dist/telemetry/offline-queue.js +1 -131
  235. package/packages/client/dist/tier/index.js +1 -5
  236. package/packages/client/dist/tier/tier-aware-client.js +1 -405
  237. package/packages/client/dist/types/index.js +1 -38
  238. package/packages/client/dist/version.js +1 -27
  239. package/packages/client/dist/yolo/change-evidence-collector.d.ts +21 -1
  240. package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
  241. package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
  242. package/packages/client/dist/yolo/spec-envelope-collector.js +5 -184
  243. package/packages/client/dist/yoloop/discovery-hook.js +2 -300
  244. package/packages/client/dist/yoloop/index.js +1 -8
  245. package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
  246. package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
  247. package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
  248. package/packages/client/dist/yoloop/target-normalization.js +1 -180
  249. package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1920
  250. package/packages/shared/dist/invocation/explicit-intent-recovery.d.ts +83 -0
  251. package/packages/shared/dist/invocation/explicit-intent-recovery.js +187 -0
  252. package/packages/shared/dist/invocation/index.d.ts +7 -0
  253. package/packages/shared/dist/invocation/index.js +22 -0
  254. package/packages/shared/dist/yolo/change-evidence.js +1 -1
  255. package/packages/shared/dist/yoloop/epic-terminal-git.js +144 -2
  256. package/targets-stubs/antigravity/gemini.md +1 -1
  257. package/targets-stubs/antigravity/skill/SKILL.md +1 -1
  258. package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
  259. package/targets-stubs/claude-code/neocortex-root.md +2 -2
  260. package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
  261. package/targets-stubs/claude-code/neocortex.md +2 -2
  262. package/targets-stubs/codex/AGENTS.md +24 -21
  263. package/targets-stubs/codex/README.md +6 -1
  264. package/targets-stubs/codex/neocortex.toml +7 -2
  265. package/targets-stubs/cursor/agent.md +2 -2
  266. package/targets-stubs/gemini-cli/agent.md +2 -2
  267. package/targets-stubs/opencode/neocortex-root.md +16 -1
  268. package/targets-stubs/opencode/neocortex.md +6 -0
  269. package/targets-stubs/vscode/neocortex.agent.md +2 -2
@@ -1,129 +1 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P180.05 -- invoke.ts hooks for client-owned continuity SQLite state.
6
- */
7
- import { CONTINUITY_CLIENT_REASON_CODES, ContinuityClientStateStoreError, continuitySqliteExists, createContinuityHardStopSnapshot, openContinuityClientStateStore, } from './continuity-client-state-store.js';
8
- import { buildAutonomousGovernanceEnvelope, parseAutonomousInvokeIntent, } from './autonomous-governance.js';
9
- export { RUNNER_BOOTSTRAP_POLICY_REASON_CODES, classifyRunnerBootstrapPolicy, classifyRunnerBootstrapPolicyFromArgs, parseRunnerBootstrapCommandIntent, } from './runner-bootstrap-policy.js';
10
- import { parseRunnerBootstrapCommandIntent } from './runner-bootstrap-policy.js';
11
- import { StrictReadOnlyError, } from '../../../shared/dist/strict-readonly.js';
12
- export function isContinuityTrigger(args) {
13
- return parseRunnerBootstrapCommandIntent(args).kind !== 'unknown' || parseAutonomousInvokeIntent(args) !== null;
14
- }
15
- export async function readContinuityForRequest(args, projectRoot, nowIso, effectAuthority, options = {}) {
16
- const autonomousIntent = parseAutonomousInvokeIntent(args);
17
- const shouldRead = autonomousIntent !== null
18
- || isContinuityTrigger(args)
19
- || (options.includeExistingStore !== false && continuitySqliteExists(projectRoot));
20
- // An authority object does not make continuity relevant. In strict mode,
21
- // attempting a read-only open for an absent, unrelated store would turn a
22
- // clean diagnose into a false physical-boundary failure.
23
- if (!shouldRead)
24
- return undefined;
25
- try {
26
- const opened = effectAuthority
27
- ? await effectAuthority.executeAsync({ phase: 'client-preflight', domain: 'client-persistence', category: 'continuity-store', operation: 'create' }, async () => shouldRead
28
- ? ({ kind: 'writable', store: await openContinuityClientStateStore({ projectRoot, now: () => nowIso ?? new Date().toISOString() }) })
29
- : ({ kind: 'skipped' }), async () => {
30
- try {
31
- return { kind: 'readonly', store: await openContinuityClientStateStore({
32
- projectRoot,
33
- now: () => nowIso ?? new Date().toISOString(),
34
- strictReadOnly: true,
35
- }) };
36
- }
37
- catch {
38
- throw new StrictReadOnlyError('readonly-physical-boundary-unsafe', 'boundary');
39
- }
40
- })
41
- : { kind: 'writable', store: await openContinuityClientStateStore({ projectRoot, now: () => nowIso ?? new Date().toISOString() }) };
42
- if (opened.kind === 'skipped')
43
- return undefined;
44
- if (opened.kind === 'readonly') {
45
- try {
46
- return opened.store.collectSnapshot({ nowIso });
47
- }
48
- finally {
49
- opened.store.close();
50
- }
51
- }
52
- const store = opened.store;
53
- try {
54
- if (autonomousIntent) {
55
- const timestamp = nowIso ?? new Date().toISOString();
56
- const envelope = buildAutonomousGovernanceEnvelope(autonomousIntent);
57
- if (effectAuthority) {
58
- effectAuthority.execute({ phase: 'client-preflight', domain: 'client-persistence', category: 'continuity-store', operation: 'create' }, () => store.recordAutonomousGovernance(envelope, timestamp), () => undefined);
59
- }
60
- else {
61
- store.recordAutonomousGovernance(envelope, timestamp);
62
- }
63
- return { ...store.collectSnapshot({ nowIso: timestamp }), autonomousGovernance: envelope };
64
- }
65
- return store.collectSnapshot({ nowIso });
66
- }
67
- finally {
68
- store.close();
69
- }
70
- }
71
- catch (error) {
72
- if (error instanceof StrictReadOnlyError)
73
- throw error;
74
- const reasonCodes = reasonCodesForError(error);
75
- if (isContinuityTrigger(args) || continuitySqliteExists(projectRoot)) {
76
- return createContinuityHardStopSnapshot(reasonCodes, nowIso ?? new Date().toISOString());
77
- }
78
- return undefined;
79
- }
80
- }
81
- export async function persistContinuityFromResponse(metadata, projectRoot) {
82
- const update = metadata?.continuityStateUpdate;
83
- if (!update) {
84
- return {
85
- ok: true,
86
- appliedOperationIds: [],
87
- ignoredOperationIds: [],
88
- reasonCodes: [CONTINUITY_CLIENT_REASON_CODES.OK],
89
- publicSafe: true,
90
- };
91
- }
92
- let store;
93
- try {
94
- store = await openContinuityClientStateStore({ projectRoot });
95
- const result = store.applyStateUpdate(update);
96
- return {
97
- ok: true,
98
- appliedOperationIds: result.appliedOperationIds,
99
- ignoredOperationIds: result.ignoredOperationIds,
100
- reasonCodes: result.reasonCodes,
101
- publicSafe: true,
102
- };
103
- }
104
- catch (error) {
105
- const reasonCodes = reasonCodesForError(error);
106
- const message = error instanceof Error ? error.message : String(error);
107
- return {
108
- ok: false,
109
- appliedOperationIds: [],
110
- ignoredOperationIds: [],
111
- reasonCodes,
112
- error: message,
113
- publicSafe: true,
114
- };
115
- }
116
- finally {
117
- store?.close();
118
- }
119
- }
120
- function reasonCodesForError(error) {
121
- if (error instanceof ContinuityClientStateStoreError)
122
- return error.reasonCodes;
123
- const message = error instanceof Error ? error.message : String(error);
124
- if (/sqlite-adapter-unavailable/i.test(message))
125
- return [CONTINUITY_CLIENT_REASON_CODES.SQLITE_ADAPTER_UNAVAILABLE];
126
- if (/integrity|corrupt|malformed|not a database/i.test(message))
127
- return [CONTINUITY_CLIENT_REASON_CODES.SQLITE_INTEGRITY_FAILED];
128
- return [CONTINUITY_CLIENT_REASON_CODES.SQLITE_MUTATION_FAILED];
129
- }
1
+ import{CONTINUITY_CLIENT_REASON_CODES as c,ContinuityClientStateStoreError as O,continuitySqliteExists as S,createContinuityHardStopSnapshot as C,openContinuityClientStateStore as d}from"./continuity-client-state-store.js";import{buildAutonomousGovernanceEnvelope as E,parseAutonomousInvokeIntent as f}from"./autonomous-governance.js";import{RUNNER_BOOTSTRAP_POLICY_REASON_CODES as D,classifyRunnerBootstrapPolicy as N,classifyRunnerBootstrapPolicyFromArgs as L,parseRunnerBootstrapCommandIntent as v}from"./runner-bootstrap-policy.js";import{parseRunnerBootstrapCommandIntent as g}from"./runner-bootstrap-policy.js";import{StrictReadOnlyError as y}from"../../../shared/dist/strict-readonly.js";function m(e){return g(e).kind!=="unknown"||f(e)!==null}async function _(e,t,n,i,r={}){const s=f(e),u=s!==null||m(e)||r.includeExistingStore!==!1&&S(t);if(u)try{const o=i?await i.executeAsync({phase:"client-preflight",domain:"client-persistence",category:"continuity-store",operation:"create"},async()=>u?{kind:"writable",store:await d({projectRoot:t,now:()=>n??new Date().toISOString()})}:{kind:"skipped"},async()=>{try{return{kind:"readonly",store:await d({projectRoot:t,now:()=>n??new Date().toISOString(),strictReadOnly:!0})}}catch{throw new y("readonly-physical-boundary-unsafe","boundary")}}):{kind:"writable",store:await d({projectRoot:t,now:()=>n??new Date().toISOString()})};if(o.kind==="skipped")return;if(o.kind==="readonly")try{return o.store.collectSnapshot({nowIso:n})}finally{o.store.close()}const a=o.store;try{if(s){const l=n??new Date().toISOString(),p=E(s);return i?i.execute({phase:"client-preflight",domain:"client-persistence",category:"continuity-store",operation:"create"},()=>a.recordAutonomousGovernance(p,l),()=>{}):a.recordAutonomousGovernance(p,l),{...a.collectSnapshot({nowIso:l}),autonomousGovernance:p}}return a.collectSnapshot({nowIso:n})}finally{a.close()}}catch(o){if(o instanceof y)throw o;const a=I(o);return m(e)||S(t)?C(a,n??new Date().toISOString()):void 0}}async function h(e,t){const n=e?.continuityStateUpdate;if(!n)return{ok:!0,appliedOperationIds:[],ignoredOperationIds:[],reasonCodes:[c.OK],publicSafe:!0};let i;try{i=await d({projectRoot:t});const r=i.applyStateUpdate(n);return{ok:!0,appliedOperationIds:r.appliedOperationIds,ignoredOperationIds:r.ignoredOperationIds,reasonCodes:r.reasonCodes,publicSafe:!0}}catch(r){const s=I(r),u=r instanceof Error?r.message:String(r);return{ok:!1,appliedOperationIds:[],ignoredOperationIds:[],reasonCodes:s,error:u,publicSafe:!0}}finally{i?.close()}}function I(e){if(e instanceof O)return e.reasonCodes;const t=e instanceof Error?e.message:String(e);return/sqlite-adapter-unavailable/i.test(t)?[c.SQLITE_ADAPTER_UNAVAILABLE]:/integrity|corrupt|malformed|not a database/i.test(t)?[c.SQLITE_INTEGRITY_FAILED]:[c.SQLITE_MUTATION_FAILED]}export{D as RUNNER_BOOTSTRAP_POLICY_REASON_CODES,N as classifyRunnerBootstrapPolicy,L as classifyRunnerBootstrapPolicyFromArgs,m as isContinuityTrigger,v as parseRunnerBootstrapCommandIntent,h as persistContinuityFromResponse,_ as readContinuityForRequest};
@@ -1,13 +1,4 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P180.04 -- Initial public-safe Enterprise Continuity Plane SQLite schema.
6
- */
7
- export const INITIAL_CONTINUITY_SQLITE_MIGRATION = Object.freeze({
8
- version: 1,
9
- name: 'initial-continuity-schema',
10
- sql: `
1
+ const E=Object.freeze({version:1,name:"initial-continuity-schema",sql:`
11
2
  CREATE TABLE IF NOT EXISTS jobs (
12
3
  job_id TEXT PRIMARY KEY,
13
4
  kind TEXT NOT NULL CHECK (kind IN ('goal', 'loop', 'runner', 'jobs')),
@@ -269,5 +260,4 @@ CREATE TABLE IF NOT EXISTS outbox (
269
260
 
270
261
  CREATE INDEX IF NOT EXISTS idx_outbox_status_next_attempt ON outbox(status, next_attempt_at);
271
262
  CREATE INDEX IF NOT EXISTS idx_outbox_job_id ON outbox(job_id);
272
- `,
273
- });
263
+ `});export{E as INITIAL_CONTINUITY_SQLITE_MIGRATION};
@@ -1,17 +1,7 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P185.02 -- Bounded processing-output summary cursor indexes.
6
- */
7
- export const PROCESSING_OUTPUT_SUMMARY_SQLITE_MIGRATION = Object.freeze({
8
- version: 2,
9
- name: 'processing-output-summary-indexes',
10
- sql: `
1
+ const e=Object.freeze({version:2,name:"processing-output-summary-indexes",sql:`
11
2
  CREATE INDEX IF NOT EXISTS idx_job_events_type_created_at_event_id
12
3
  ON job_events(type, created_at, event_id);
13
4
 
14
5
  CREATE INDEX IF NOT EXISTS idx_job_events_job_type_created_at_event_id
15
6
  ON job_events(job_id, type, created_at, event_id);
16
- `,
17
- });
7
+ `});export{e as PROCESSING_OUTPUT_SUMMARY_SQLITE_MIGRATION};
@@ -1,13 +1,4 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P190.03 -- Headless execution attempt queue, leases and public summaries.
6
- */
7
- export const HEADLESS_EXECUTION_ATTEMPTS_SQLITE_MIGRATION = Object.freeze({
8
- version: 3,
9
- name: 'headless-execution-attempts',
10
- sql: `
1
+ const e=Object.freeze({version:3,name:"headless-execution-attempts",sql:`
11
2
  CREATE TABLE IF NOT EXISTS headless_execution_attempts (
12
3
  attempt_id TEXT PRIMARY KEY,
13
4
  execution_id TEXT NOT NULL,
@@ -68,5 +59,4 @@ CREATE INDEX IF NOT EXISTS idx_headless_execution_attempts_runtime_model
68
59
  CREATE UNIQUE INDEX IF NOT EXISTS idx_headless_execution_attempts_active_lease
69
60
  ON headless_execution_attempts(lease_id)
70
61
  WHERE lease_id IS NOT NULL AND lease_released_at IS NULL;
71
- `,
72
- });
62
+ `});export{e as HEADLESS_EXECUTION_ATTEMPTS_SQLITE_MIGRATION};
@@ -1,13 +1,4 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P192.03 -- Replay-safe outbox delivery cursor, ack and dead-letter state.
6
- */
7
- export const OUTBOX_DELIVERY_STATE_SQLITE_MIGRATION = Object.freeze({
8
- version: 4,
9
- name: 'outbox-delivery-state',
10
- sql: `
1
+ const t=Object.freeze({version:4,name:"outbox-delivery-state",sql:`
11
2
  ALTER TABLE outbox ADD COLUMN delivery_cursor TEXT;
12
3
  ALTER TABLE outbox ADD COLUMN attempt_count INTEGER NOT NULL DEFAULT 0 CHECK (attempt_count >= 0);
13
4
  ALTER TABLE outbox ADD COLUMN last_attempt_at TEXT;
@@ -25,5 +16,4 @@ CREATE INDEX IF NOT EXISTS idx_outbox_delivery_batch
25
16
  ON outbox(status, next_attempt_at, created_at, outbox_id);
26
17
  CREATE INDEX IF NOT EXISTS idx_outbox_ack_state
27
18
  ON outbox(status, acked_at, updated_at);
28
- `,
29
- });
19
+ `});export{t as OUTBOX_DELIVERY_STATE_SQLITE_MIGRATION};
@@ -1,13 +1,4 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P199.04 -- Additive bounded queue metadata for headless execution attempts.
6
- */
7
- export const BOUNDED_HEADLESS_QUEUE_SQLITE_MIGRATION = Object.freeze({
8
- version: 5,
9
- name: 'bounded-headless-queue',
10
- sql: `
1
+ const e=Object.freeze({version:5,name:"bounded-headless-queue",sql:`
11
2
  ALTER TABLE headless_execution_attempts
12
3
  ADD COLUMN queue_priority INTEGER NOT NULL DEFAULT 0
13
4
  CHECK (queue_priority >= -100 AND queue_priority <= 100);
@@ -41,5 +32,4 @@ CREATE INDEX IF NOT EXISTS idx_headless_execution_attempts_bounded_due
41
32
 
42
33
  CREATE INDEX IF NOT EXISTS idx_headless_execution_attempts_dead_letter
43
34
  ON headless_execution_attempts(dead_lettered_at, attempt_id);
44
- `,
45
- });
35
+ `});export{e as BOUNDED_HEADLESS_QUEUE_SQLITE_MIGRATION};
@@ -1,11 +1,4 @@
1
- /**
2
- * Public-safe native-agent dispatch reservation and immutable observations.
3
- * Raw runtime handles, prompts and logs are deliberately absent.
4
- */
5
- export const NATIVE_AGENT_DISPATCHES_SQLITE_MIGRATION = Object.freeze({
6
- version: 6,
7
- name: 'native-agent-dispatches',
8
- sql: `
1
+ const e=Object.freeze({version:6,name:"native-agent-dispatches",sql:`
9
2
  CREATE TABLE IF NOT EXISTS native_agent_dispatches (
10
3
  dispatch_key TEXT PRIMARY KEY CHECK (dispatch_key GLOB 'sha256:*' AND length(dispatch_key) = 71),
11
4
  story_id TEXT NOT NULL,
@@ -52,5 +45,4 @@ CREATE TABLE IF NOT EXISTS native_agent_observations (
52
45
 
53
46
  CREATE INDEX IF NOT EXISTS idx_native_agent_observations_dispatch_observed
54
47
  ON native_agent_observations(dispatch_key, observed_at, sequence);
55
- `,
56
- });
48
+ `});export{e as NATIVE_AGENT_DISPATCHES_SQLITE_MIGRATION};
@@ -1,69 +1 @@
1
- /**
2
- * Private native-agent runtime store. The database and keyed-handle secret live
3
- * in the Git common-dir so worktrees share one dispatch authority without
4
- * writing runtime identifiers into tracked project state.
5
- */
6
- import { createHmac, randomBytes } from 'node:crypto';
7
- import { execFileSync } from 'node:child_process';
8
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from 'node:fs';
9
- import { isAbsolute, join, resolve } from 'node:path';
10
- import { openContinuitySqliteStore } from './sqlite-store.js';
11
- const PRIVATE_RUNTIME_DIR = 'neocortex-runtime/native-agent';
12
- const PRIVATE_DATABASE = 'continuity.sqlite';
13
- const HANDLE_KEY = 'handle-key';
14
- const SAFE_RAW_HANDLE = /^[^\r\n\0]{1,256}$/;
15
- export function resolveNativeAgentPrivateRuntimePaths(projectRoot) {
16
- const observed = execFileSync('git', ['rev-parse', '--path-format=absolute', '--git-common-dir'], { cwd: projectRoot, encoding: 'utf8', timeout: 3_000, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
17
- if (!observed || /[\r\n\0]/.test(observed))
18
- throw new Error('native-agent-git-common-dir-unavailable');
19
- const commonDir = isAbsolute(observed) ? observed : resolve(projectRoot, observed);
20
- const runtimeDir = join(commonDir, PRIVATE_RUNTIME_DIR);
21
- return Object.freeze({
22
- commonDir,
23
- runtimeDir,
24
- databasePath: join(runtimeDir, PRIVATE_DATABASE),
25
- handleKeyPath: join(runtimeDir, HANDLE_KEY),
26
- });
27
- }
28
- function ensurePrivateRuntime(paths) {
29
- mkdirSync(paths.runtimeDir, { recursive: true, mode: 0o700 });
30
- try {
31
- chmodSync(paths.runtimeDir, 0o700);
32
- }
33
- catch { /* best-effort on non-POSIX */ }
34
- if (!existsSync(paths.handleKeyPath)) {
35
- try {
36
- writeFileSync(paths.handleKeyPath, randomBytes(32).toString('hex'), {
37
- encoding: 'utf8',
38
- flag: 'wx',
39
- mode: 0o600,
40
- });
41
- }
42
- catch (error) {
43
- if (!existsSync(paths.handleKeyPath))
44
- throw error;
45
- }
46
- }
47
- try {
48
- chmodSync(paths.handleKeyPath, 0o600);
49
- }
50
- catch { /* best-effort on non-POSIX */ }
51
- }
52
- export function deriveOpaqueNativeAgentHandle(rawHandle, handleKeyPath) {
53
- if (!SAFE_RAW_HANDLE.test(rawHandle))
54
- throw new Error('native-agent-raw-handle-invalid');
55
- const key = readFileSync(handleKeyPath, 'utf8').trim();
56
- if (!/^[a-f0-9]{64}$/i.test(key))
57
- throw new Error('native-agent-handle-key-invalid');
58
- return `agt_${createHmac('sha256', Buffer.from(key, 'hex')).update(rawHandle, 'utf8').digest('hex')}`;
59
- }
60
- export async function openNativeAgentPrivateStore(projectRoot, options = {}) {
61
- const paths = resolveNativeAgentPrivateRuntimePaths(projectRoot);
62
- ensurePrivateRuntime(paths);
63
- const store = await openContinuitySqliteStore({
64
- ...options,
65
- projectRoot,
66
- filePath: paths.databasePath,
67
- });
68
- return Object.freeze({ store, paths });
69
- }
1
+ import{createHmac as c,randomBytes as m}from"node:crypto";import{execFileSync as s}from"node:child_process";import{chmodSync as o,existsSync as a,mkdirSync as u,readFileSync as d,writeFileSync as f}from"node:fs";import{isAbsolute as h,join as i,resolve as l}from"node:path";import{openContinuitySqliteStore as y}from"./sqlite-store.js";const v="neocortex-runtime/native-agent",g="continuity.sqlite",P="handle-key",A=/^[^\r\n\0]{1,256}$/;function S(e){const t=s("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).trim();if(!t||/[\r\n\0]/.test(t))throw new Error("native-agent-git-common-dir-unavailable");const n=h(t)?t:l(e,t),r=i(n,v);return Object.freeze({commonDir:n,runtimeDir:r,databasePath:i(r,g),handleKeyPath:i(r,P)})}function w(e){u(e.runtimeDir,{recursive:!0,mode:448});try{o(e.runtimeDir,448)}catch{}if(!a(e.handleKeyPath))try{f(e.handleKeyPath,m(32).toString("hex"),{encoding:"utf8",flag:"wx",mode:384})}catch(t){if(!a(e.handleKeyPath))throw t}try{o(e.handleKeyPath,384)}catch{}}function _(e,t){if(!A.test(e))throw new Error("native-agent-raw-handle-invalid");const n=d(t,"utf8").trim();if(!/^[a-f0-9]{64}$/i.test(n))throw new Error("native-agent-handle-key-invalid");return`agt_${c("sha256",Buffer.from(n,"hex")).update(e,"utf8").digest("hex")}`}async function K(e,t={}){const n=S(e);w(n);const r=await y({...t,projectRoot:e,filePath:n.databasePath});return Object.freeze({store:r,paths:n})}export{_ as deriveOpaqueNativeAgentHandle,K as openNativeAgentPrivateStore,S as resolveNativeAgentPrivateRuntimePaths};
@@ -24,6 +24,16 @@ export interface NativeDispatchBindingV1 {
24
24
  readonly maxDepth: 1;
25
25
  readonly publicSafe: true;
26
26
  }
27
+ export interface NativeBackgroundDispatchContractV1 {
28
+ readonly schemaVersion: 1;
29
+ readonly contractVersion: 'native-background-dispatch-v1';
30
+ readonly topology: 'native-agent';
31
+ readonly launchPolicy: 'all-eligible-before-settlement';
32
+ readonly settlementPolicy: 'first-admissible-to-root';
33
+ readonly integrationOwner: 'root';
34
+ readonly maxDepth: 1;
35
+ readonly publicSafe: true;
36
+ }
27
37
  export type NativeAgentState = 'requested' | 'spawned' | 'running' | 'completed' | 'failed' | 'interrupted' | 'unknown' | 'lost';
28
38
  export type NativeAgentTopology = 'native-agent' | 'headless-process' | 'inline';
29
39
  export type NativeAgentFreshness = 'fresh' | 'stale' | 'unknown';
@@ -49,6 +59,7 @@ export interface NativeAgentDispatchReceiptV1 {
49
59
  }
50
60
  export declare const NATIVE_AGENT_TERMINAL_STATES: ReadonlySet<NativeAgentState>;
51
61
  export declare function isNativeHostAttestationV1(value: unknown): value is NativeHostAttestationV1;
62
+ export declare function isNativeBackgroundDispatchContractV1(value: unknown): value is NativeBackgroundDispatchContractV1;
52
63
  export declare function isNativeDispatchBindingV1(value: unknown): value is NativeDispatchBindingV1;
53
64
  export declare function isNativeAgentDispatchReceiptV1(value: unknown): value is NativeAgentDispatchReceiptV1;
54
65
  export declare function isNativeAgentStateTransitionAllowed(previous: NativeAgentState, next: NativeAgentState): boolean;
@@ -1,90 +1 @@
1
- const STATES = ['requested', 'spawned', 'running', 'completed', 'failed', 'interrupted', 'unknown', 'lost'];
2
- const TOPOLOGIES = ['native-agent', 'headless-process', 'inline'];
3
- const FRESHNESS = ['fresh', 'stale', 'unknown'];
4
- const SOURCES = ['host-event', 'host-list', 'bounded-poll', 'local-reservation'];
5
- const HOST_KINDS = ['codex-cli', 'codex-desktop', 'unknown'];
6
- const HOST_ORIGINS = ['runtime-attested', 'host-observed', 'environment', 'explicit-override', 'unknown'];
7
- const HOST_CONFIDENCE = ['attested', 'observed', 'inferred', 'unknown'];
8
- export const NATIVE_AGENT_TERMINAL_STATES = new Set(['completed', 'failed', 'interrupted']);
9
- const STORY_ID = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/;
10
- const REVISION = /^(?:sha256:)?[a-f0-9]{64}$/i;
11
- const DISPATCH_KEY = /^sha256:[a-f0-9]{64}$/i;
12
- const HANDLE = /^agt_[a-f0-9]{24,64}$/i;
13
- const VERSION = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;
14
- const REASON = /^[a-z0-9][a-z0-9-]{0,95}$/;
15
- function record(value) {
16
- return !!value && typeof value === 'object' && !Array.isArray(value);
17
- }
18
- function exact(value, expected) {
19
- const keys = Object.keys(value).sort();
20
- const wanted = [...expected].sort();
21
- return keys.length === wanted.length && keys.every((key, index) => key === wanted[index]);
22
- }
23
- function timestamp(value) {
24
- return typeof value === 'string' && value.length >= 20 && value.length <= 40 && Number.isFinite(Date.parse(value));
25
- }
26
- export function isNativeHostAttestationV1(value) {
27
- if (!record(value) || !exact(value, ['schemaVersion', 'platformTarget', 'hostKind', 'hostVersion', 'origin', 'confidence', 'publicSafe']))
28
- return false;
29
- return value.schemaVersion === 1 && value.platformTarget === 'codex'
30
- && HOST_KINDS.includes(value.hostKind)
31
- && (value.hostVersion === null || (typeof value.hostVersion === 'string' && VERSION.test(value.hostVersion)))
32
- && HOST_ORIGINS.includes(value.origin)
33
- && HOST_CONFIDENCE.includes(value.confidence)
34
- && value.publicSafe === true;
35
- }
36
- export function isNativeDispatchBindingV1(value) {
37
- if (!record(value) || !exact(value, ['schemaVersion', 'storyId', 'graphRevision', 'dispatchKey', 'requiredCapability', 'maxDepth', 'publicSafe']))
38
- return false;
39
- return value.schemaVersion === 1
40
- && typeof value.storyId === 'string' && STORY_ID.test(value.storyId)
41
- && typeof value.graphRevision === 'string' && REVISION.test(value.graphRevision)
42
- && typeof value.dispatchKey === 'string' && DISPATCH_KEY.test(value.dispatchKey)
43
- && value.requiredCapability === 'native_safe' && value.maxDepth === 1 && value.publicSafe === true;
44
- }
45
- export function isNativeAgentDispatchReceiptV1(value) {
46
- if (!record(value) || !exact(value, [
47
- 'schemaVersion', 'storyId', 'graphRevision', 'dispatchKey', 'profile', 'parentHandle', 'handle', 'topology',
48
- 'state', 'requestedAt', 'observedAt', 'terminalAt', 'freshness', 'observationSource', 'reasonCode', 'revision', 'publicSafe',
49
- ]))
50
- return false;
51
- const state = value.state;
52
- if (value.schemaVersion !== 1 || typeof value.storyId !== 'string' || !STORY_ID.test(value.storyId)
53
- || typeof value.graphRevision !== 'string' || !REVISION.test(value.graphRevision)
54
- || typeof value.dispatchKey !== 'string' || !DISPATCH_KEY.test(value.dispatchKey)
55
- || value.profile !== 'neocortex'
56
- || (value.parentHandle !== null && (typeof value.parentHandle !== 'string' || !HANDLE.test(value.parentHandle)))
57
- || (value.handle !== null && (typeof value.handle !== 'string' || !HANDLE.test(value.handle)))
58
- || !TOPOLOGIES.includes(value.topology) || !STATES.includes(state)
59
- || !timestamp(value.requestedAt) || (value.observedAt !== null && !timestamp(value.observedAt))
60
- || (value.terminalAt !== null && !timestamp(value.terminalAt))
61
- || !FRESHNESS.includes(value.freshness)
62
- || !SOURCES.includes(value.observationSource)
63
- || typeof value.reasonCode !== 'string' || !REASON.test(value.reasonCode)
64
- || typeof value.revision !== 'number' || !Number.isSafeInteger(value.revision) || value.revision < 0
65
- || value.publicSafe !== true)
66
- return false;
67
- if (state === 'requested')
68
- return value.handle === null && value.observedAt === null && value.terminalAt === null
69
- && value.freshness === 'unknown' && value.observationSource === 'local-reservation';
70
- if (value.observationSource === 'local-reservation')
71
- return false;
72
- if ((state === 'spawned' || state === 'running') && (value.handle === null || value.freshness !== 'fresh'))
73
- return false;
74
- if (NATIVE_AGENT_TERMINAL_STATES.has(state) !== (value.terminalAt !== null))
75
- return false;
76
- return true;
77
- }
78
- const TRANSITIONS = {
79
- requested: new Set(['requested', 'spawned', 'failed', 'interrupted', 'unknown']),
80
- spawned: new Set(['spawned', 'running', 'completed', 'failed', 'interrupted', 'unknown', 'lost']),
81
- running: new Set(['running', 'completed', 'failed', 'interrupted', 'unknown', 'lost']),
82
- unknown: new Set(['unknown', 'spawned', 'running', 'completed', 'failed', 'interrupted', 'lost']),
83
- lost: new Set(['lost', 'running', 'completed', 'failed', 'interrupted']),
84
- completed: new Set(['completed']),
85
- failed: new Set(['failed']),
86
- interrupted: new Set(['interrupted']),
87
- };
88
- export function isNativeAgentStateTransitionAllowed(previous, next) {
89
- return TRANSITIONS[previous].has(next);
90
- }
1
+ const l=["requested","spawned","running","completed","failed","interrupted","unknown","lost"],g=["native-agent","headless-process","inline"],S=["fresh","stale","unknown"],y=["host-event","host-list","bounded-poll","local-reservation"],m=["codex-cli","codex-desktop","unknown"],b=["runtime-attested","host-observed","environment","explicit-override","unknown"],w=["attested","observed","inferred","unknown"],A=new Set(["completed","failed","interrupted"]),c=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+$/,d=/^(?:sha256:)?[a-f0-9]{64}$/i,p=/^sha256:[a-f0-9]{64}$/i,a=/^agt_[a-f0-9]{24,64}$/i,u=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/,I=/^[a-z0-9][a-z0-9-]{0,95}$/;function n(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function r(t,e){const o=Object.keys(t).sort(),i=[...e].sort();return o.length===i.length&&o.every((f,h)=>f===i[h])}function s(t){return typeof t=="string"&&t.length>=20&&t.length<=40&&Number.isFinite(Date.parse(t))}function V(t){return!n(t)||!r(t,["schemaVersion","platformTarget","hostKind","hostVersion","origin","confidence","publicSafe"])?!1:t.schemaVersion===1&&t.platformTarget==="codex"&&m.includes(t.hostKind)&&(t.hostVersion===null||typeof t.hostVersion=="string"&&u.test(t.hostVersion))&&b.includes(t.origin)&&w.includes(t.confidence)&&t.publicSafe===!0}function T(t){return!n(t)||!r(t,["schemaVersion","contractVersion","topology","launchPolicy","settlementPolicy","integrationOwner","maxDepth","publicSafe"])?!1:t.schemaVersion===1&&t.contractVersion==="native-background-dispatch-v1"&&t.topology==="native-agent"&&t.launchPolicy==="all-eligible-before-settlement"&&t.settlementPolicy==="first-admissible-to-root"&&t.integrationOwner==="root"&&t.maxDepth===1&&t.publicSafe===!0}function O(t){return!n(t)||!r(t,["schemaVersion","storyId","graphRevision","dispatchKey","requiredCapability","maxDepth","publicSafe"])?!1:t.schemaVersion===1&&typeof t.storyId=="string"&&c.test(t.storyId)&&typeof t.graphRevision=="string"&&d.test(t.graphRevision)&&typeof t.dispatchKey=="string"&&p.test(t.dispatchKey)&&t.requiredCapability==="native_safe"&&t.maxDepth===1&&t.publicSafe===!0}function k(t){if(!n(t)||!r(t,["schemaVersion","storyId","graphRevision","dispatchKey","profile","parentHandle","handle","topology","state","requestedAt","observedAt","terminalAt","freshness","observationSource","reasonCode","revision","publicSafe"]))return!1;const e=t.state;return t.schemaVersion!==1||typeof t.storyId!="string"||!c.test(t.storyId)||typeof t.graphRevision!="string"||!d.test(t.graphRevision)||typeof t.dispatchKey!="string"||!p.test(t.dispatchKey)||t.profile!=="neocortex"||t.parentHandle!==null&&(typeof t.parentHandle!="string"||!a.test(t.parentHandle))||t.handle!==null&&(typeof t.handle!="string"||!a.test(t.handle))||!g.includes(t.topology)||!l.includes(e)||!s(t.requestedAt)||t.observedAt!==null&&!s(t.observedAt)||t.terminalAt!==null&&!s(t.terminalAt)||!S.includes(t.freshness)||!y.includes(t.observationSource)||typeof t.reasonCode!="string"||!I.test(t.reasonCode)||typeof t.revision!="number"||!Number.isSafeInteger(t.revision)||t.revision<0||t.publicSafe!==!0?!1:e==="requested"?t.handle===null&&t.observedAt===null&&t.terminalAt===null&&t.freshness==="unknown"&&t.observationSource==="local-reservation":!(t.observationSource==="local-reservation"||(e==="spawned"||e==="running")&&(t.handle===null||t.freshness!=="fresh")||A.has(e)!==(t.terminalAt!==null))}const N={requested:new Set(["requested","spawned","failed","interrupted","unknown"]),spawned:new Set(["spawned","running","completed","failed","interrupted","unknown","lost"]),running:new Set(["running","completed","failed","interrupted","unknown","lost"]),unknown:new Set(["unknown","spawned","running","completed","failed","interrupted","lost"]),lost:new Set(["lost","running","completed","failed","interrupted"]),completed:new Set(["completed"]),failed:new Set(["failed"]),interrupted:new Set(["interrupted"])};function x(t,e){return N[t].has(e)}export{A as NATIVE_AGENT_TERMINAL_STATES,k as isNativeAgentDispatchReceiptV1,x as isNativeAgentStateTransitionAllowed,T as isNativeBackgroundDispatchContractV1,O as isNativeDispatchBindingV1,V as isNativeHostAttestationV1};
@@ -1,117 +1 @@
1
- /**
2
- * @license FSL-1.1
3
- * Copyright (c) 2026 OrNexus AI
4
- *
5
- * P192.03 -- Public-safe continuity outbox retry/dead-letter helpers.
6
- */
7
- export const DEFAULT_CONTINUITY_RETENTION_POLICY = Object.freeze({
8
- policyVersion: 1,
9
- receipts: Object.freeze({ maxAgeMs: 30 * 24 * 60 * 60_000, maxItems: 1_000, maxBytes: 2 * 1024 * 1024 }),
10
- processingOutputs: Object.freeze({ maxAgeMs: 7 * 24 * 60 * 60_000, maxItems: 500, maxBytes: 1024 * 1024 }),
11
- maxDeleteRowsPerRun: 5_000,
12
- maxCompactionSummariesPerJob: 20,
13
- });
14
- export const CONTINUITY_RECEIPT_COMPACTION_EVENT_TYPE = 'receipt_compaction';
15
- export const CONTINUITY_RECEIPT_RETENTION_REASON_CODES = Object.freeze({
16
- COMPACTED: 'receipt-compacted',
17
- NOOP: 'receipt-retention-noop',
18
- });
19
- export const CONTINUITY_QUEUE_SCOPES = Object.freeze(['project', 'workspace']);
20
- export const DEFAULT_CONTINUITY_QUEUE_PRIORITY = 0;
21
- export const MIN_CONTINUITY_QUEUE_PRIORITY = -100;
22
- export const MAX_CONTINUITY_QUEUE_PRIORITY = 100;
23
- export const DEFAULT_CONTINUITY_QUEUE_POLICY = Object.freeze({
24
- maxItems: 100,
25
- leaseMs: 5 * 60_000,
26
- maxAttempts: 3,
27
- baseDelayMs: 30_000,
28
- maxDelayMs: 15 * 60_000,
29
- });
30
- export const CONTINUITY_QUEUE_REASON_CODES = Object.freeze({
31
- CAP_REACHED: 'queue-cap-reached',
32
- LEASE_TIMEOUT_RETRY: 'queue-lease-timeout-retry',
33
- ATTEMPTS_EXHAUSTED: 'queue-attempts-exhausted',
34
- });
35
- export const DEFAULT_CONTINUITY_OUTBOX_RETRY_POLICY = Object.freeze({
36
- maxAttempts: 3,
37
- baseDelayMs: 60_000,
38
- maxDelayMs: 60 * 60_000,
39
- });
40
- export function normalizeContinuityQueuePolicy(policy) {
41
- const maxItems = boundedInteger(policy?.maxItems, 1, 10_000, DEFAULT_CONTINUITY_QUEUE_POLICY.maxItems);
42
- const leaseMs = boundedInteger(policy?.leaseMs, 1_000, 60 * 60_000, DEFAULT_CONTINUITY_QUEUE_POLICY.leaseMs);
43
- const maxAttempts = boundedInteger(policy?.maxAttempts, 1, 100, DEFAULT_CONTINUITY_QUEUE_POLICY.maxAttempts);
44
- const baseDelayMs = boundedInteger(policy?.baseDelayMs, 1_000, 24 * 60 * 60_000, DEFAULT_CONTINUITY_QUEUE_POLICY.baseDelayMs);
45
- const maxDelayMs = boundedInteger(policy?.maxDelayMs, baseDelayMs, 7 * 24 * 60 * 60_000, DEFAULT_CONTINUITY_QUEUE_POLICY.maxDelayMs);
46
- return { maxItems, leaseMs, maxAttempts, baseDelayMs, maxDelayMs };
47
- }
48
- export function normalizeContinuityRetentionPolicy(input) {
49
- return {
50
- policyVersion: 1,
51
- receipts: normalizeRetentionWindow(input?.receipts, DEFAULT_CONTINUITY_RETENTION_POLICY.receipts),
52
- processingOutputs: normalizeRetentionWindow(input?.processingOutputs, DEFAULT_CONTINUITY_RETENTION_POLICY.processingOutputs),
53
- maxDeleteRowsPerRun: boundedInteger(input?.maxDeleteRowsPerRun, 1, 50_000, DEFAULT_CONTINUITY_RETENTION_POLICY.maxDeleteRowsPerRun),
54
- maxCompactionSummariesPerJob: boundedInteger(input?.maxCompactionSummariesPerJob, 1, 100, DEFAULT_CONTINUITY_RETENTION_POLICY.maxCompactionSummariesPerJob),
55
- };
56
- }
57
- export function normalizeContinuityQueuePriority(value) {
58
- return boundedInteger(value, MIN_CONTINUITY_QUEUE_PRIORITY, MAX_CONTINUITY_QUEUE_PRIORITY, DEFAULT_CONTINUITY_QUEUE_PRIORITY);
59
- }
60
- export function normalizeContinuityQueueScope(value) {
61
- return value === 'workspace' ? 'workspace' : 'project';
62
- }
63
- export function computeContinuityQueueRetryAt(nowIso, retryCount, policy) {
64
- const normalized = normalizeContinuityQueuePolicy(policy);
65
- const nowMs = Date.parse(nowIso);
66
- const safeNowMs = Number.isFinite(nowMs) ? nowMs : Date.now();
67
- const exponent = Math.max(0, Math.min(16, Math.floor(retryCount) - 1));
68
- const delayMs = Math.min(normalized.maxDelayMs, normalized.baseDelayMs * (2 ** exponent));
69
- return new Date(safeNowMs + delayMs).toISOString();
70
- }
71
- export function normalizeContinuityOutboxRetryPolicy(policy) {
72
- const maxAttempts = boundedInteger(policy?.maxAttempts, 1, 100, DEFAULT_CONTINUITY_OUTBOX_RETRY_POLICY.maxAttempts);
73
- const baseDelayMs = boundedInteger(policy?.baseDelayMs, 1_000, 24 * 60 * 60_000, DEFAULT_CONTINUITY_OUTBOX_RETRY_POLICY.baseDelayMs);
74
- const maxDelayMs = boundedInteger(policy?.maxDelayMs, baseDelayMs, 7 * 24 * 60 * 60_000, DEFAULT_CONTINUITY_OUTBOX_RETRY_POLICY.maxDelayMs);
75
- return { maxAttempts, baseDelayMs, maxDelayMs };
76
- }
77
- export function computeContinuityOutboxFailureDecision(input) {
78
- const policy = normalizeContinuityOutboxRetryPolicy(input.policy);
79
- const attemptCount = boundedInteger(input.attemptCount, 0, Number.MAX_SAFE_INTEGER, 0);
80
- if (attemptCount >= policy.maxAttempts) {
81
- return {
82
- status: 'dead_letter',
83
- reasonCode: input.reasonCode,
84
- ...(input.summary ? { summary: input.summary } : {}),
85
- deadLetteredAt: input.nowIso,
86
- maxAttempts: policy.maxAttempts,
87
- publicSafe: true,
88
- };
89
- }
90
- return {
91
- status: 'failed',
92
- reasonCode: input.reasonCode,
93
- ...(input.summary ? { summary: input.summary } : {}),
94
- nextRetryAt: input.nextRetryAt ?? computeNextRetryAt(input.nowIso, attemptCount, policy),
95
- maxAttempts: policy.maxAttempts,
96
- publicSafe: true,
97
- };
98
- }
99
- function computeNextRetryAt(nowIso, attemptCount, policy) {
100
- const nowMs = Date.parse(nowIso);
101
- const safeNowMs = Number.isFinite(nowMs) ? nowMs : Date.now();
102
- const exponent = Math.max(0, Math.min(16, attemptCount - 1));
103
- const delayMs = Math.min(policy.maxDelayMs, policy.baseDelayMs * (2 ** exponent));
104
- return new Date(safeNowMs + delayMs).toISOString();
105
- }
106
- function boundedInteger(value, min, max, fallback) {
107
- if (!Number.isFinite(value))
108
- return fallback;
109
- return Math.max(min, Math.min(max, Math.floor(value)));
110
- }
111
- function normalizeRetentionWindow(input, fallback) {
112
- return {
113
- maxAgeMs: boundedInteger(input?.maxAgeMs, 60_000, 365 * 24 * 60 * 60_000, fallback.maxAgeMs),
114
- maxItems: boundedInteger(input?.maxItems, 1, 100_000, fallback.maxItems),
115
- maxBytes: boundedInteger(input?.maxBytes, 1_024, 256 * 1024 * 1024, fallback.maxBytes),
116
- };
117
- }
1
+ const c=Object.freeze({policyVersion:1,receipts:Object.freeze({maxAgeMs:2592e6,maxItems:1e3,maxBytes:2097152}),processingOutputs:Object.freeze({maxAgeMs:6048e5,maxItems:500,maxBytes:1048576}),maxDeleteRowsPerRun:5e3,maxCompactionSummariesPerJob:20}),E="receipt_compaction",C=Object.freeze({COMPACTED:"receipt-compacted",NOOP:"receipt-retention-noop"}),l=Object.freeze(["project","workspace"]),p=0,M=-100,I=100,r=Object.freeze({maxItems:100,leaseMs:5*6e4,maxAttempts:3,baseDelayMs:3e4,maxDelayMs:15*6e4}),D=Object.freeze({CAP_REACHED:"queue-cap-reached",LEASE_TIMEOUT_RETRY:"queue-lease-timeout-retry",ATTEMPTS_EXHAUSTED:"queue-attempts-exhausted"}),u=Object.freeze({maxAttempts:3,baseDelayMs:6e4,maxDelayMs:60*6e4});function y(e){const t=s(e?.maxItems,1,1e4,r.maxItems),a=s(e?.leaseMs,1e3,60*6e4,r.leaseMs),o=s(e?.maxAttempts,1,100,r.maxAttempts),m=s(e?.baseDelayMs,1e3,1440*6e4,r.baseDelayMs),n=s(e?.maxDelayMs,m,10080*6e4,r.maxDelayMs);return{maxItems:t,leaseMs:a,maxAttempts:o,baseDelayMs:m,maxDelayMs:n}}function A(e){return{policyVersion:1,receipts:i(e?.receipts,c.receipts),processingOutputs:i(e?.processingOutputs,c.processingOutputs),maxDeleteRowsPerRun:s(e?.maxDeleteRowsPerRun,1,5e4,c.maxDeleteRowsPerRun),maxCompactionSummariesPerJob:s(e?.maxCompactionSummariesPerJob,1,100,c.maxCompactionSummariesPerJob)}}function N(e){return s(e,M,I,p)}function R(e){return e==="workspace"?"workspace":"project"}function b(e,t,a){const o=y(a),m=Date.parse(e),n=Number.isFinite(m)?m:Date.now(),x=Math.max(0,Math.min(16,Math.floor(t)-1)),_=Math.min(o.maxDelayMs,o.baseDelayMs*2**x);return new Date(n+_).toISOString()}function O(e){const t=s(e?.maxAttempts,1,100,u.maxAttempts),a=s(e?.baseDelayMs,1e3,1440*6e4,u.baseDelayMs),o=s(e?.maxDelayMs,a,10080*6e4,u.maxDelayMs);return{maxAttempts:t,baseDelayMs:a,maxDelayMs:o}}function U(e){const t=O(e.policy),a=s(e.attemptCount,0,Number.MAX_SAFE_INTEGER,0);return a>=t.maxAttempts?{status:"dead_letter",reasonCode:e.reasonCode,...e.summary?{summary:e.summary}:{},deadLetteredAt:e.nowIso,maxAttempts:t.maxAttempts,publicSafe:!0}:{status:"failed",reasonCode:e.reasonCode,...e.summary?{summary:e.summary}:{},nextRetryAt:e.nextRetryAt??T(e.nowIso,a,t),maxAttempts:t.maxAttempts,publicSafe:!0}}function T(e,t,a){const o=Date.parse(e),m=Number.isFinite(o)?o:Date.now(),n=Math.max(0,Math.min(16,t-1)),x=Math.min(a.maxDelayMs,a.baseDelayMs*2**n);return new Date(m+x).toISOString()}function s(e,t,a,o){return Number.isFinite(e)?Math.max(t,Math.min(a,Math.floor(e))):o}function i(e,t){return{maxAgeMs:s(e?.maxAgeMs,6e4,365*24*60*6e4,t.maxAgeMs),maxItems:s(e?.maxItems,1,1e5,t.maxItems),maxBytes:s(e?.maxBytes,1024,256*1024*1024,t.maxBytes)}}export{D as CONTINUITY_QUEUE_REASON_CODES,l as CONTINUITY_QUEUE_SCOPES,E as CONTINUITY_RECEIPT_COMPACTION_EVENT_TYPE,C as CONTINUITY_RECEIPT_RETENTION_REASON_CODES,u as DEFAULT_CONTINUITY_OUTBOX_RETRY_POLICY,r as DEFAULT_CONTINUITY_QUEUE_POLICY,p as DEFAULT_CONTINUITY_QUEUE_PRIORITY,c as DEFAULT_CONTINUITY_RETENTION_POLICY,I as MAX_CONTINUITY_QUEUE_PRIORITY,M as MIN_CONTINUITY_QUEUE_PRIORITY,U as computeContinuityOutboxFailureDecision,b as computeContinuityQueueRetryAt,O as normalizeContinuityOutboxRetryPolicy,y as normalizeContinuityQueuePolicy,N as normalizeContinuityQueuePriority,R as normalizeContinuityQueueScope,A as normalizeContinuityRetentionPolicy};