@namzu/sdk 0.1.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -2
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +5 -2
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +3 -0
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +21 -5
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/bridge/a2a/index.d.ts +1 -1
- package/dist/bridge/a2a/index.d.ts.map +1 -1
- package/dist/bridge/a2a/index.js +1 -1
- package/dist/bridge/a2a/index.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +6 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/a2a/message.d.ts +0 -2
- package/dist/bridge/a2a/message.d.ts.map +1 -1
- package/dist/bridge/a2a/message.js +0 -26
- package/dist/bridge/a2a/message.js.map +1 -1
- package/dist/bridge/a2a/task.d.ts +5 -4
- package/dist/bridge/a2a/task.d.ts.map +1 -1
- package/dist/bridge/a2a/task.js +4 -4
- package/dist/bridge/a2a/task.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +6 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/constants/a2a/index.d.ts +2 -2
- package/dist/constants/a2a/index.d.ts.map +1 -1
- package/dist/constants/a2a/index.js.map +1 -1
- package/dist/contracts/api.d.ts +14 -27
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/ids.d.ts +1 -1
- package/dist/contracts/ids.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/schemas.d.ts +1 -31
- package/dist/contracts/schemas.d.ts.map +1 -1
- package/dist/contracts/schemas.js +1 -7
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/gateway/local.d.ts.map +1 -1
- package/dist/gateway/local.js +6 -0
- package/dist/gateway/local.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/manager/agent/__tests__/lifecycle.test.d.ts +2 -0
- package/dist/manager/agent/__tests__/lifecycle.test.d.ts.map +1 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js +316 -0
- package/dist/manager/agent/__tests__/lifecycle.test.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts +67 -3
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +375 -14
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/index.d.ts +2 -0
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +1 -0
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +10 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +20 -0
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/manager/thread/__tests__/lifecycle.test.d.ts +2 -0
- package/dist/manager/thread/__tests__/lifecycle.test.d.ts.map +1 -0
- package/dist/manager/thread/__tests__/lifecycle.test.js +216 -0
- package/dist/manager/thread/__tests__/lifecycle.test.js.map +1 -0
- package/dist/manager/thread/lifecycle.d.ts +105 -0
- package/dist/manager/thread/lifecycle.d.ts.map +1 -0
- package/dist/manager/thread/lifecycle.js +186 -0
- package/dist/manager/thread/lifecycle.js.map +1 -0
- package/dist/rag/retriever.js +2 -2
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +25 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/query/__tests__/context.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/context.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/context.test.js +85 -0
- package/dist/runtime/query/__tests__/context.test.js.map +1 -0
- package/dist/runtime/query/context-cache.d.ts +3 -3
- package/dist/runtime/query/context-cache.d.ts.map +1 -1
- package/dist/runtime/query/context-cache.js +2 -2
- package/dist/runtime/query/context-cache.js.map +1 -1
- package/dist/runtime/query/context.d.ts +45 -1
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +50 -8
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +8 -0
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/index.d.ts +22 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +11 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/session/__tests__/integration/_fixtures.d.ts +122 -0
- package/dist/session/__tests__/integration/_fixtures.d.ts.map +1 -0
- package/dist/session/__tests__/integration/_fixtures.js +215 -0
- package/dist/session/__tests__/integration/_fixtures.js.map +1 -0
- package/dist/session/__tests__/integration/archive-gate.test.d.ts +15 -0
- package/dist/session/__tests__/integration/archive-gate.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/archive-gate.test.js +214 -0
- package/dist/session/__tests__/integration/archive-gate.test.js.map +1 -0
- package/dist/session/__tests__/integration/capacity-caps.test.d.ts +13 -0
- package/dist/session/__tests__/integration/capacity-caps.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/capacity-caps.test.js +123 -0
- package/dist/session/__tests__/integration/capacity-caps.test.js.map +1 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.d.ts +18 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.js +238 -0
- package/dist/session/__tests__/integration/e2e-spawn.test.js.map +1 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts +15 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.js +330 -0
- package/dist/session/__tests__/integration/event-stream-ordering.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts +12 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js +182 -0
- package/dist/session/__tests__/integration/handoff-broadcast-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts +18 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js +156 -0
- package/dist/session/__tests__/integration/handoff-illegal-transition.test.js.map +1 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts +15 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js +179 -0
- package/dist/session/__tests__/integration/handoff-single-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts +12 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js +158 -0
- package/dist/session/__tests__/integration/hierarchy-lifecycle.test.js.map +1 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.d.ts +11 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.js +140 -0
- package/dist/session/__tests__/integration/migration-filesystem.test.js.map +1 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts +13 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.js +84 -0
- package/dist/session/__tests__/integration/migration-id-prefix.test.js.map +1 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts +14 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js +242 -0
- package/dist/session/__tests__/integration/prev-artifact-dag.test.js.map +1 -0
- package/dist/session/__tests__/integration/retention-archive.test.d.ts +12 -0
- package/dist/session/__tests__/integration/retention-archive.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/retention-archive.test.js +187 -0
- package/dist/session/__tests__/integration/retention-archive.test.js.map +1 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts +26 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.js +236 -0
- package/dist/session/__tests__/integration/spawn-rollback.test.js.map +1 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts +18 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js +201 -0
- package/dist/session/__tests__/integration/summary-materialization-e2e.test.js.map +1 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.d.ts +14 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.d.ts.map +1 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.js +189 -0
- package/dist/session/__tests__/integration/tenant-isolation.test.js.map +1 -0
- package/dist/session/errors.d.ts +139 -0
- package/dist/session/errors.d.ts.map +1 -0
- package/dist/session/errors.js +107 -0
- package/dist/session/errors.js.map +1 -0
- package/dist/session/events/index.d.ts +4 -0
- package/dist/session/events/index.d.ts.map +1 -0
- package/dist/session/events/index.js +8 -0
- package/dist/session/events/index.js.map +1 -0
- package/dist/session/events/schema-version.d.ts +13 -0
- package/dist/session/events/schema-version.d.ts.map +1 -0
- package/dist/session/events/schema-version.js +12 -0
- package/dist/session/events/schema-version.js.map +1 -0
- package/dist/session/events/types.d.ts +64 -0
- package/dist/session/events/types.d.ts.map +1 -0
- package/dist/session/events/types.js +2 -0
- package/dist/session/events/types.js.map +1 -0
- package/dist/session/handoff/__tests__/broadcast.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/broadcast.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/broadcast.test.js +261 -0
- package/dist/session/handoff/__tests__/broadcast.test.js.map +1 -0
- package/dist/session/handoff/__tests__/capacity.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/capacity.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/capacity.test.js +103 -0
- package/dist/session/handoff/__tests__/capacity.test.js.map +1 -0
- package/dist/session/handoff/__tests__/single.test.d.ts +2 -0
- package/dist/session/handoff/__tests__/single.test.d.ts.map +1 -0
- package/dist/session/handoff/__tests__/single.test.js +239 -0
- package/dist/session/handoff/__tests__/single.test.js.map +1 -0
- package/dist/session/handoff/assignment.d.ts +71 -0
- package/dist/session/handoff/assignment.d.ts.map +1 -0
- package/dist/session/handoff/assignment.js +11 -0
- package/dist/session/handoff/assignment.js.map +1 -0
- package/dist/session/handoff/broadcast.d.ts +54 -0
- package/dist/session/handoff/broadcast.d.ts.map +1 -0
- package/dist/session/handoff/broadcast.js +311 -0
- package/dist/session/handoff/broadcast.js.map +1 -0
- package/dist/session/handoff/capacity.d.ts +66 -0
- package/dist/session/handoff/capacity.d.ts.map +1 -0
- package/dist/session/handoff/capacity.js +60 -0
- package/dist/session/handoff/capacity.js.map +1 -0
- package/dist/session/handoff/events.d.ts +66 -0
- package/dist/session/handoff/events.d.ts.map +1 -0
- package/dist/session/handoff/events.js +13 -0
- package/dist/session/handoff/events.js.map +1 -0
- package/dist/session/handoff/index.d.ts +12 -0
- package/dist/session/handoff/index.d.ts.map +1 -0
- package/dist/session/handoff/index.js +9 -0
- package/dist/session/handoff/index.js.map +1 -0
- package/dist/session/handoff/single.d.ts +69 -0
- package/dist/session/handoff/single.d.ts.map +1 -0
- package/dist/session/handoff/single.js +229 -0
- package/dist/session/handoff/single.js.map +1 -0
- package/dist/session/handoff/version.d.ts +52 -0
- package/dist/session/handoff/version.d.ts.map +1 -0
- package/dist/session/handoff/version.js +36 -0
- package/dist/session/handoff/version.js.map +1 -0
- package/dist/session/hierarchy/__tests__/session.test.d.ts +2 -0
- package/dist/session/hierarchy/__tests__/session.test.d.ts.map +1 -0
- package/dist/session/hierarchy/__tests__/session.test.js +69 -0
- package/dist/session/hierarchy/__tests__/session.test.js.map +1 -0
- package/dist/session/hierarchy/actor.d.ts +26 -0
- package/dist/session/hierarchy/actor.d.ts.map +1 -0
- package/dist/session/hierarchy/actor.js +2 -0
- package/dist/session/hierarchy/actor.js.map +1 -0
- package/dist/session/hierarchy/index.d.ts +9 -0
- package/dist/session/hierarchy/index.d.ts.map +1 -0
- package/dist/session/hierarchy/index.js +4 -0
- package/dist/session/hierarchy/index.js.map +1 -0
- package/dist/session/hierarchy/lineage.d.ts +15 -0
- package/dist/session/hierarchy/lineage.d.ts.map +1 -0
- package/dist/session/hierarchy/lineage.js +2 -0
- package/dist/session/hierarchy/lineage.js.map +1 -0
- package/dist/session/hierarchy/project.d.ts +40 -0
- package/dist/session/hierarchy/project.d.ts.map +1 -0
- package/dist/session/hierarchy/project.js +2 -0
- package/dist/session/hierarchy/project.js.map +1 -0
- package/dist/session/hierarchy/session.d.ts +71 -0
- package/dist/session/hierarchy/session.d.ts.map +1 -0
- package/dist/session/hierarchy/session.js +51 -0
- package/dist/session/hierarchy/session.js.map +1 -0
- package/dist/session/hierarchy/sub-session.d.ts +76 -0
- package/dist/session/hierarchy/sub-session.d.ts.map +1 -0
- package/dist/session/hierarchy/sub-session.js +2 -0
- package/dist/session/hierarchy/sub-session.js.map +1 -0
- package/dist/session/hierarchy/tenant.d.ts +13 -0
- package/dist/session/hierarchy/tenant.d.ts.map +1 -0
- package/dist/session/hierarchy/tenant.js +2 -0
- package/dist/session/hierarchy/tenant.js.map +1 -0
- package/dist/session/hierarchy/thread.d.ts +54 -0
- package/dist/session/hierarchy/thread.d.ts.map +1 -0
- package/dist/session/hierarchy/thread.js +2 -0
- package/dist/session/hierarchy/thread.js.map +1 -0
- package/dist/session/index.d.ts +10 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +15 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.d.ts +2 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.d.ts.map +1 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.js +179 -0
- package/dist/session/intervention/__tests__/prev-artifact.test.js.map +1 -0
- package/dist/session/intervention/index.d.ts +3 -0
- package/dist/session/intervention/index.d.ts.map +1 -0
- package/dist/session/intervention/index.js +8 -0
- package/dist/session/intervention/index.js.map +1 -0
- package/dist/session/intervention/prev-artifact.d.ts +103 -0
- package/dist/session/intervention/prev-artifact.d.ts.map +1 -0
- package/dist/session/intervention/prev-artifact.js +112 -0
- package/dist/session/intervention/prev-artifact.js.map +1 -0
- package/dist/session/migration/__tests__/filesystem.test.d.ts +2 -0
- package/dist/session/migration/__tests__/filesystem.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/filesystem.test.js +188 -0
- package/dist/session/migration/__tests__/filesystem.test.js.map +1 -0
- package/dist/session/migration/__tests__/id-prefix.test.d.ts +2 -0
- package/dist/session/migration/__tests__/id-prefix.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/id-prefix.test.js +83 -0
- package/dist/session/migration/__tests__/id-prefix.test.js.map +1 -0
- package/dist/session/migration/__tests__/marker.test.d.ts +2 -0
- package/dist/session/migration/__tests__/marker.test.d.ts.map +1 -0
- package/dist/session/migration/__tests__/marker.test.js +75 -0
- package/dist/session/migration/__tests__/marker.test.js.map +1 -0
- package/dist/session/migration/errors.d.ts +26 -0
- package/dist/session/migration/errors.d.ts.map +1 -0
- package/dist/session/migration/errors.js +22 -0
- package/dist/session/migration/errors.js.map +1 -0
- package/dist/session/migration/filesystem.d.ts +94 -0
- package/dist/session/migration/filesystem.d.ts.map +1 -0
- package/dist/session/migration/filesystem.js +319 -0
- package/dist/session/migration/filesystem.js.map +1 -0
- package/dist/session/migration/id-prefix.d.ts +93 -0
- package/dist/session/migration/id-prefix.d.ts.map +1 -0
- package/dist/session/migration/id-prefix.js +111 -0
- package/dist/session/migration/id-prefix.js.map +1 -0
- package/dist/session/migration/index.d.ts +8 -0
- package/dist/session/migration/index.d.ts.map +1 -0
- package/dist/session/migration/index.js +8 -0
- package/dist/session/migration/index.js.map +1 -0
- package/dist/session/migration/marker.d.ts +57 -0
- package/dist/session/migration/marker.d.ts.map +1 -0
- package/dist/session/migration/marker.js +111 -0
- package/dist/session/migration/marker.js.map +1 -0
- package/dist/session/retention/__tests__/archive.test.d.ts +2 -0
- package/dist/session/retention/__tests__/archive.test.d.ts.map +1 -0
- package/dist/session/retention/__tests__/archive.test.js +253 -0
- package/dist/session/retention/__tests__/archive.test.js.map +1 -0
- package/dist/session/retention/__tests__/disk-backend.test.d.ts +2 -0
- package/dist/session/retention/__tests__/disk-backend.test.d.ts.map +1 -0
- package/dist/session/retention/__tests__/disk-backend.test.js +154 -0
- package/dist/session/retention/__tests__/disk-backend.test.js.map +1 -0
- package/dist/session/retention/archive-backend-ref.d.ts +18 -0
- package/dist/session/retention/archive-backend-ref.d.ts.map +1 -0
- package/dist/session/retention/archive-backend-ref.js +2 -0
- package/dist/session/retention/archive-backend-ref.js.map +1 -0
- package/dist/session/retention/archive.d.ts +130 -0
- package/dist/session/retention/archive.d.ts.map +1 -0
- package/dist/session/retention/archive.js +203 -0
- package/dist/session/retention/archive.js.map +1 -0
- package/dist/session/retention/backend.d.ts +101 -0
- package/dist/session/retention/backend.d.ts.map +1 -0
- package/dist/session/retention/backend.js +15 -0
- package/dist/session/retention/backend.js.map +1 -0
- package/dist/session/retention/disk-backend.d.ts +59 -0
- package/dist/session/retention/disk-backend.d.ts.map +1 -0
- package/dist/session/retention/disk-backend.js +236 -0
- package/dist/session/retention/disk-backend.js.map +1 -0
- package/dist/session/retention/index.d.ts +9 -0
- package/dist/session/retention/index.d.ts.map +1 -0
- package/dist/session/retention/index.js +6 -0
- package/dist/session/retention/index.js.map +1 -0
- package/dist/session/retention/policy.d.ts +49 -0
- package/dist/session/retention/policy.d.ts.map +1 -0
- package/dist/session/retention/policy.js +21 -0
- package/dist/session/retention/policy.js.map +1 -0
- package/dist/session/summary/__tests__/materialize.test.d.ts +2 -0
- package/dist/session/summary/__tests__/materialize.test.d.ts.map +1 -0
- package/dist/session/summary/__tests__/materialize.test.js +270 -0
- package/dist/session/summary/__tests__/materialize.test.js.map +1 -0
- package/dist/session/summary/deliverable.d.ts +74 -0
- package/dist/session/summary/deliverable.d.ts.map +1 -0
- package/dist/session/summary/deliverable.js +20 -0
- package/dist/session/summary/deliverable.js.map +1 -0
- package/dist/session/summary/index.d.ts +6 -0
- package/dist/session/summary/index.d.ts.map +1 -0
- package/dist/session/summary/index.js +9 -0
- package/dist/session/summary/index.js.map +1 -0
- package/dist/session/summary/materialize.d.ts +82 -0
- package/dist/session/summary/materialize.d.ts.map +1 -0
- package/dist/session/summary/materialize.js +117 -0
- package/dist/session/summary/materialize.js.map +1 -0
- package/dist/session/summary/ref.d.ts +91 -0
- package/dist/session/summary/ref.d.ts.map +1 -0
- package/dist/session/summary/ref.js +51 -0
- package/dist/session/summary/ref.js.map +1 -0
- package/dist/session/workspace/__tests__/git-worktree.test.d.ts +2 -0
- package/dist/session/workspace/__tests__/git-worktree.test.d.ts.map +1 -0
- package/dist/session/workspace/__tests__/git-worktree.test.js +244 -0
- package/dist/session/workspace/__tests__/git-worktree.test.js.map +1 -0
- package/dist/session/workspace/__tests__/path-builder.test.d.ts +2 -0
- package/dist/session/workspace/__tests__/path-builder.test.d.ts.map +1 -0
- package/dist/session/workspace/__tests__/path-builder.test.js +37 -0
- package/dist/session/workspace/__tests__/path-builder.test.js.map +1 -0
- package/dist/session/workspace/driver.d.ts +55 -0
- package/dist/session/workspace/driver.d.ts.map +1 -0
- package/dist/session/workspace/driver.js +12 -0
- package/dist/session/workspace/driver.js.map +1 -0
- package/dist/session/workspace/git-worktree.d.ts +65 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -0
- package/dist/session/workspace/git-worktree.js +156 -0
- package/dist/session/workspace/git-worktree.js.map +1 -0
- package/dist/session/workspace/index.d.ts +8 -0
- package/dist/session/workspace/index.d.ts.map +1 -0
- package/dist/session/workspace/index.js +7 -0
- package/dist/session/workspace/index.js.map +1 -0
- package/dist/session/workspace/path-builder.d.ts +50 -0
- package/dist/session/workspace/path-builder.d.ts.map +1 -0
- package/dist/session/workspace/path-builder.js +50 -0
- package/dist/session/workspace/path-builder.js.map +1 -0
- package/dist/session/workspace/ref.d.ts +46 -0
- package/dist/session/workspace/ref.d.ts.map +1 -0
- package/dist/session/workspace/ref.js +11 -0
- package/dist/session/workspace/ref.js.map +1 -0
- package/dist/session/workspace/registry.d.ts +26 -0
- package/dist/session/workspace/registry.d.ts.map +1 -0
- package/dist/session/workspace/registry.js +35 -0
- package/dist/session/workspace/registry.js.map +1 -0
- package/dist/store/index.d.ts +0 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +0 -1
- package/dist/store/index.js.map +1 -1
- package/dist/store/session/__tests__/disk.test.d.ts +2 -0
- package/dist/store/session/__tests__/disk.test.d.ts.map +1 -0
- package/dist/store/session/__tests__/disk.test.js +267 -0
- package/dist/store/session/__tests__/disk.test.js.map +1 -0
- package/dist/store/session/__tests__/memory.test.d.ts +2 -0
- package/dist/store/session/__tests__/memory.test.d.ts.map +1 -0
- package/dist/store/session/__tests__/memory.test.js +258 -0
- package/dist/store/session/__tests__/memory.test.js.map +1 -0
- package/dist/store/session/disk.d.ts +86 -0
- package/dist/store/session/disk.d.ts.map +1 -0
- package/dist/store/session/disk.js +818 -0
- package/dist/store/session/disk.js.map +1 -0
- package/dist/store/session/index.d.ts +7 -0
- package/dist/store/session/index.d.ts.map +1 -0
- package/dist/store/session/index.js +10 -0
- package/dist/store/session/index.js.map +1 -0
- package/dist/store/session/linkage.d.ts +38 -0
- package/dist/store/session/linkage.d.ts.map +1 -0
- package/dist/store/session/linkage.js +64 -0
- package/dist/store/session/linkage.js.map +1 -0
- package/dist/store/session/memory.d.ts +49 -0
- package/dist/store/session/memory.d.ts.map +1 -0
- package/dist/store/session/memory.js +335 -0
- package/dist/store/session/memory.js.map +1 -0
- package/dist/store/session/messages.d.ts +20 -0
- package/dist/store/session/messages.d.ts.map +1 -0
- package/dist/store/session/messages.js +12 -0
- package/dist/store/session/messages.js.map +1 -0
- package/dist/store/thread/disk.d.ts +41 -0
- package/dist/store/thread/disk.d.ts.map +1 -0
- package/dist/store/thread/disk.js +229 -0
- package/dist/store/thread/disk.js.map +1 -0
- package/dist/store/thread/index.d.ts +4 -0
- package/dist/store/thread/index.d.ts.map +1 -0
- package/dist/store/thread/index.js +6 -0
- package/dist/store/thread/index.js.map +1 -0
- package/dist/store/thread/memory.d.ts +23 -0
- package/dist/store/thread/memory.d.ts.map +1 -0
- package/dist/store/thread/memory.js +90 -0
- package/dist/store/thread/memory.js.map +1 -0
- package/dist/tools/builtins/__tests__/structuredOutput.example.d.ts +1 -1
- package/dist/types/agent/base.d.ts +24 -1
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +8 -2
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +57 -2
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/ids/index.d.ts +22 -3
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js +8 -1
- package/dist/types/ids/index.js.map +1 -1
- package/dist/types/invocation/__tests__/state.test.js +36 -29
- package/dist/types/invocation/__tests__/state.test.js.map +1 -1
- package/dist/types/invocation/index.d.ts +20 -4
- package/dist/types/invocation/index.d.ts.map +1 -1
- package/dist/types/invocation/index.js +10 -7
- package/dist/types/invocation/index.js.map +1 -1
- package/dist/types/rag/retrieval.d.ts +4 -3
- package/dist/types/rag/retrieval.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +12 -1
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +26 -1
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +8 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/metadata.d.ts +12 -2
- package/dist/types/run/metadata.d.ts.map +1 -1
- package/dist/types/run/status.d.ts +26 -0
- package/dist/types/run/status.d.ts.map +1 -0
- package/dist/types/run/status.js +2 -0
- package/dist/types/run/status.js.map +1 -0
- package/dist/types/session/ids.d.ts +9 -0
- package/dist/types/session/ids.d.ts.map +1 -0
- package/dist/types/session/ids.js +9 -0
- package/dist/types/session/ids.js.map +1 -0
- package/dist/types/session/index.d.ts +3 -0
- package/dist/types/session/index.d.ts.map +1 -0
- package/dist/types/session/index.js +5 -0
- package/dist/types/session/index.js.map +1 -0
- package/dist/types/session/store.d.ts +210 -0
- package/dist/types/session/store.d.ts.map +1 -0
- package/dist/types/session/store.js +9 -0
- package/dist/types/session/store.js.map +1 -0
- package/dist/types/thread/index.d.ts +2 -0
- package/dist/types/thread/index.d.ts.map +1 -0
- package/dist/types/thread/index.js +5 -0
- package/dist/types/thread/index.js.map +1 -0
- package/dist/types/thread/store.d.ts +86 -0
- package/dist/types/thread/store.d.ts.map +1 -0
- package/dist/types/thread/store.js +22 -0
- package/dist/types/thread/store.js.map +1 -0
- package/dist/utils/id.d.ts +8 -2
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +22 -4
- package/dist/utils/id.js.map +1 -1
- package/package.json +6 -11
- package/src/agents/ReactiveAgent.ts +7 -2
- package/src/agents/RouterAgent.ts +5 -0
- package/src/agents/SupervisorAgent.ts +29 -6
- package/src/bridge/a2a/index.ts +0 -1
- package/src/bridge/a2a/mapper.ts +7 -0
- package/src/bridge/a2a/message.ts +0 -32
- package/src/bridge/a2a/task.ts +9 -8
- package/src/bridge/sse/mapper.ts +8 -1
- package/src/constants/a2a/index.ts +2 -2
- package/src/contracts/api.ts +14 -30
- package/src/contracts/ids.ts +1 -1
- package/src/contracts/index.ts +3 -7
- package/src/contracts/schemas.ts +1 -8
- package/src/gateway/local.ts +6 -0
- package/src/index.ts +14 -4
- package/src/manager/agent/__tests__/lifecycle.test.ts +473 -0
- package/src/manager/agent/lifecycle.ts +515 -21
- package/src/manager/index.ts +3 -0
- package/src/manager/run/persistence.ts +26 -1
- package/src/manager/thread/__tests__/lifecycle.test.ts +286 -0
- package/src/manager/thread/lifecycle.ts +217 -0
- package/src/rag/retriever.ts +2 -2
- package/src/run/reporter.ts +28 -0
- package/src/runtime/query/__tests__/context.test.ts +102 -0
- package/src/runtime/query/context-cache.ts +4 -4
- package/src/runtime/query/context.ts +98 -9
- package/src/runtime/query/events.ts +8 -0
- package/src/runtime/query/index.ts +38 -1
- package/src/session/__tests__/integration/_fixtures.ts +310 -0
- package/src/session/__tests__/integration/archive-gate.test.ts +288 -0
- package/src/session/__tests__/integration/capacity-caps.test.ts +171 -0
- package/src/session/__tests__/integration/e2e-spawn.test.ts +296 -0
- package/src/session/__tests__/integration/event-stream-ordering.test.ts +410 -0
- package/src/session/__tests__/integration/handoff-broadcast-e2e.test.ts +271 -0
- package/src/session/__tests__/integration/handoff-illegal-transition.test.ts +214 -0
- package/src/session/__tests__/integration/handoff-single-e2e.test.ts +251 -0
- package/src/session/__tests__/integration/hierarchy-lifecycle.test.ts +240 -0
- package/src/session/__tests__/integration/migration-filesystem.test.ts +209 -0
- package/src/session/__tests__/integration/migration-id-prefix.test.ts +101 -0
- package/src/session/__tests__/integration/prev-artifact-dag.test.ts +325 -0
- package/src/session/__tests__/integration/retention-archive.test.ts +233 -0
- package/src/session/__tests__/integration/spawn-rollback.test.ts +313 -0
- package/src/session/__tests__/integration/summary-materialization-e2e.test.ts +239 -0
- package/src/session/__tests__/integration/tenant-isolation.test.ts +292 -0
- package/src/session/errors.ts +159 -0
- package/src/session/events/index.ts +16 -0
- package/src/session/events/schema-version.ts +13 -0
- package/src/session/events/types.ts +71 -0
- package/src/session/handoff/__tests__/broadcast.test.ts +378 -0
- package/src/session/handoff/__tests__/capacity.test.ts +129 -0
- package/src/session/handoff/__tests__/single.test.ts +333 -0
- package/src/session/handoff/assignment.ts +74 -0
- package/src/session/handoff/broadcast.ts +406 -0
- package/src/session/handoff/capacity.ts +121 -0
- package/src/session/handoff/events.ts +72 -0
- package/src/session/handoff/index.ts +29 -0
- package/src/session/handoff/single.ts +310 -0
- package/src/session/handoff/version.ts +59 -0
- package/src/session/hierarchy/__tests__/session.test.ts +100 -0
- package/src/session/hierarchy/actor.ts +17 -0
- package/src/session/hierarchy/index.ts +18 -0
- package/src/session/hierarchy/lineage.ts +15 -0
- package/src/session/hierarchy/project.ts +41 -0
- package/src/session/hierarchy/session.ts +109 -0
- package/src/session/hierarchy/sub-session.ts +92 -0
- package/src/session/hierarchy/tenant.ts +13 -0
- package/src/session/hierarchy/thread.ts +55 -0
- package/src/session/index.ts +15 -0
- package/src/session/intervention/__tests__/prev-artifact.test.ts +234 -0
- package/src/session/intervention/index.ts +16 -0
- package/src/session/intervention/prev-artifact.ts +180 -0
- package/src/session/migration/__tests__/filesystem.test.ts +263 -0
- package/src/session/migration/__tests__/id-prefix.test.ts +101 -0
- package/src/session/migration/__tests__/marker.test.ts +84 -0
- package/src/session/migration/errors.ts +23 -0
- package/src/session/migration/filesystem.ts +401 -0
- package/src/session/migration/id-prefix.ts +141 -0
- package/src/session/migration/index.ts +38 -0
- package/src/session/migration/marker.ts +131 -0
- package/src/session/retention/__tests__/archive.test.ts +318 -0
- package/src/session/retention/__tests__/disk-backend.test.ts +180 -0
- package/src/session/retention/archive-backend-ref.ts +17 -0
- package/src/session/retention/archive.ts +281 -0
- package/src/session/retention/backend.ts +107 -0
- package/src/session/retention/disk-backend.ts +304 -0
- package/src/session/retention/index.ts +16 -0
- package/src/session/retention/policy.ts +53 -0
- package/src/session/summary/__tests__/materialize.test.ts +343 -0
- package/src/session/summary/deliverable.ts +84 -0
- package/src/session/summary/index.ts +31 -0
- package/src/session/summary/materialize.ts +169 -0
- package/src/session/summary/ref.ts +104 -0
- package/src/session/workspace/__tests__/git-worktree.test.ts +258 -0
- package/src/session/workspace/__tests__/path-builder.test.ts +51 -0
- package/src/session/workspace/driver.ts +60 -0
- package/src/session/workspace/git-worktree.ts +209 -0
- package/src/session/workspace/index.ts +25 -0
- package/src/session/workspace/path-builder.ts +71 -0
- package/src/session/workspace/ref.ts +50 -0
- package/src/session/workspace/registry.ts +42 -0
- package/src/store/index.ts +0 -3
- package/src/store/session/__tests__/disk.test.ts +397 -0
- package/src/store/session/__tests__/memory.test.ts +402 -0
- package/src/store/session/disk.ts +976 -0
- package/src/store/session/index.ts +13 -0
- package/src/store/session/linkage.ts +80 -0
- package/src/store/session/memory.ts +412 -0
- package/src/store/session/messages.ts +21 -0
- package/src/store/thread/disk.ts +261 -0
- package/src/store/thread/index.ts +7 -0
- package/src/store/thread/memory.ts +104 -0
- package/src/types/agent/base.ts +27 -1
- package/src/types/agent/factory.ts +8 -3
- package/src/types/agent/task.ts +66 -2
- package/src/types/ids/index.ts +34 -3
- package/src/types/invocation/__tests__/state.test.ts +37 -29
- package/src/types/invocation/index.ts +26 -10
- package/src/types/rag/retrieval.ts +4 -3
- package/src/types/run/config.ts +13 -1
- package/src/types/run/events.ts +36 -1
- package/src/types/run/index.ts +8 -0
- package/src/types/run/metadata.ts +12 -2
- package/src/types/run/status.ts +33 -0
- package/src/types/session/ids.ts +23 -0
- package/src/types/session/index.ts +27 -0
- package/src/types/session/store.ts +252 -0
- package/src/types/thread/index.ts +5 -0
- package/src/types/thread/store.ts +92 -0
- package/src/utils/id.ts +34 -4
- package/dist/store/conversation/memory.d.ts +0 -21
- package/dist/store/conversation/memory.d.ts.map +0 -1
- package/dist/store/conversation/memory.js +0 -86
- package/dist/store/conversation/memory.js.map +0 -1
- package/dist/types/conversation/index.d.ts +0 -7
- package/dist/types/conversation/index.d.ts.map +0 -1
- package/dist/types/conversation/index.js +0 -2
- package/dist/types/conversation/index.js.map +0 -1
- package/src/store/conversation/memory.ts +0 -121
- package/src/types/conversation/index.ts +0 -8
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration — retention archive / restore round-trip wired through the
|
|
3
|
+
* real stack: `InMemorySessionStore` + `DiskArchiveBackend` (pointed at
|
|
4
|
+
* `tmpdir()`) + `ArchivalManager` + `GitWorktreeDriver`.
|
|
5
|
+
*
|
|
6
|
+
* Covers roadmap §5 invariants: §12.3 retention deny-by-default, §12.3
|
|
7
|
+
* archive produces tombstone (in-slot), tombstone navigable via `drill`,
|
|
8
|
+
* restore full fidelity round-trip (Phase 9 closed synthetic-id loss),
|
|
9
|
+
* idempotent workspace dispose.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { mkdtempSync, rmSync } from 'node:fs'
|
|
13
|
+
import { tmpdir } from 'node:os'
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
16
|
+
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
17
|
+
import { createUserMessage } from '../../../types/message/index.js'
|
|
18
|
+
import type { ThreadId, WorkspaceId } from '../../../types/session/ids.js'
|
|
19
|
+
import { ArchivalManager, ArchiveNotConfiguredError } from '../../retention/archive.js'
|
|
20
|
+
import { DiskArchiveBackend } from '../../retention/disk-backend.js'
|
|
21
|
+
import type { WorkspaceRef } from '../../workspace/ref.js'
|
|
22
|
+
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
23
|
+
import { DEFAULT_TENANT, agentActor, userActor } from './_fixtures.js'
|
|
24
|
+
|
|
25
|
+
const TEST_THREAD_ID = 'thd_test' as ThreadId
|
|
26
|
+
|
|
27
|
+
async function seedIdleSubSession(store: InMemorySessionStore) {
|
|
28
|
+
const project = await store.createProject(
|
|
29
|
+
{ tenantId: DEFAULT_TENANT, name: 'archive' },
|
|
30
|
+
DEFAULT_TENANT,
|
|
31
|
+
)
|
|
32
|
+
const parent = await store.createSession(
|
|
33
|
+
{ threadId: TEST_THREAD_ID, projectId: project.id, currentActor: userActor('usr_a') },
|
|
34
|
+
DEFAULT_TENANT,
|
|
35
|
+
)
|
|
36
|
+
const child = await store.createSession(
|
|
37
|
+
{ threadId: TEST_THREAD_ID, projectId: project.id, currentActor: agentActor('agt_w') },
|
|
38
|
+
DEFAULT_TENANT,
|
|
39
|
+
)
|
|
40
|
+
const sub = await store.createSubSession(
|
|
41
|
+
{
|
|
42
|
+
parentSessionId: parent.id,
|
|
43
|
+
childSessionId: child.id,
|
|
44
|
+
kind: 'agent_spawn',
|
|
45
|
+
spawnedBy: userActor('usr_a'),
|
|
46
|
+
},
|
|
47
|
+
DEFAULT_TENANT,
|
|
48
|
+
)
|
|
49
|
+
await store.updateSubSession({ ...sub, status: 'idle' }, DEFAULT_TENANT)
|
|
50
|
+
return { project, parent, child, sub }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe('Integration — retention archive / restore', () => {
|
|
54
|
+
let rootDir: string
|
|
55
|
+
let store: InMemorySessionStore
|
|
56
|
+
let backend: DiskArchiveBackend
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
rootDir = mkdtempSync(join(tmpdir(), 'namzu-integration-retention-'))
|
|
60
|
+
store = new InMemorySessionStore()
|
|
61
|
+
backend = new DiskArchiveBackend({ rootDir })
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
afterEach(() => {
|
|
65
|
+
rmSync(rootDir, { recursive: true, force: true })
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('archive idle sub-session → tombstone attached (status=archived + archiveRef + archivedAt)', async () => {
|
|
69
|
+
const { sub } = await seedIdleSubSession(store)
|
|
70
|
+
const manager = new ArchivalManager({
|
|
71
|
+
sessionStore: store,
|
|
72
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
73
|
+
archiveBackend: backend,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const tombstone = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
77
|
+
expect(tombstone.archiveRef.startsWith('arc_')).toBe(true)
|
|
78
|
+
|
|
79
|
+
const after = await store.getSubSession(sub.id, DEFAULT_TENANT)
|
|
80
|
+
expect(after?.status).toBe('archived')
|
|
81
|
+
expect(after?.archiveRef).toBe(tombstone.archiveRef)
|
|
82
|
+
expect(after?.archivedAt).toBeInstanceOf(Date)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('drill(parent) post-archive: archived SubSession still navigable with tombstone fields', async () => {
|
|
86
|
+
const { parent, sub } = await seedIdleSubSession(store)
|
|
87
|
+
const manager = new ArchivalManager({
|
|
88
|
+
sessionStore: store,
|
|
89
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
90
|
+
archiveBackend: backend,
|
|
91
|
+
})
|
|
92
|
+
const tombstone = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
93
|
+
|
|
94
|
+
const view = await store.drill(parent.id, DEFAULT_TENANT)
|
|
95
|
+
expect(view?.children).toHaveLength(1)
|
|
96
|
+
const child = view?.children[0]
|
|
97
|
+
expect(child?.id).toBe(sub.id)
|
|
98
|
+
expect(child?.status).toBe('archived')
|
|
99
|
+
expect(child?.archiveRef).toBe(tombstone.archiveRef)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('restore recovers the archive bundle with original MessageId fidelity (not synthetic msg_restored_N)', async () => {
|
|
103
|
+
const { sub, child } = await seedIdleSubSession(store)
|
|
104
|
+
const msg1Id = await store.appendMessage(child.id, createUserMessage('first'), DEFAULT_TENANT)
|
|
105
|
+
const msg2Id = await store.appendMessage(child.id, createUserMessage('second'), DEFAULT_TENANT)
|
|
106
|
+
|
|
107
|
+
const manager = new ArchivalManager({
|
|
108
|
+
sessionStore: store,
|
|
109
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
110
|
+
archiveBackend: backend,
|
|
111
|
+
})
|
|
112
|
+
const tombstone = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
113
|
+
|
|
114
|
+
// Restore via backend directly to verify round-trip fidelity
|
|
115
|
+
// (ArchivalManager.restore does NOT return the bundle — it only flips
|
|
116
|
+
// status back to idle).
|
|
117
|
+
const bundle = await backend.restore(tombstone.archiveRef)
|
|
118
|
+
expect(bundle.messages).toHaveLength(2)
|
|
119
|
+
expect(bundle.messages[0]?.id).toBe(msg1Id)
|
|
120
|
+
expect(bundle.messages[1]?.id).toBe(msg2Id)
|
|
121
|
+
expect(bundle.messages[0]?.id.startsWith('msg_restored_')).toBe(false)
|
|
122
|
+
|
|
123
|
+
await manager.restore(sub.id, DEFAULT_TENANT)
|
|
124
|
+
const after = await store.getSubSession(sub.id, DEFAULT_TENANT)
|
|
125
|
+
expect(after?.status).toBe('idle')
|
|
126
|
+
expect(after?.archiveRef).toBeUndefined()
|
|
127
|
+
expect(after?.archivedAt).toBeUndefined()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('deny-by-default: project without archiveBackend → ArchiveNotConfiguredError on archive()', async () => {
|
|
131
|
+
const { sub } = await seedIdleSubSession(store)
|
|
132
|
+
const manager = new ArchivalManager({
|
|
133
|
+
sessionStore: store,
|
|
134
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
135
|
+
// archiveBackend omitted — archival fully disabled.
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
await expect(manager.archive(sub.id, DEFAULT_TENANT)).rejects.toBeInstanceOf(
|
|
139
|
+
ArchiveNotConfiguredError,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
// Sub-session untouched.
|
|
143
|
+
const after = await store.getSubSession(sub.id, DEFAULT_TENANT)
|
|
144
|
+
expect(after?.status).toBe('idle')
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('idempotent dispose: workspace already disposed → archive completes without error', async () => {
|
|
148
|
+
const { sub } = await seedIdleSubSession(store)
|
|
149
|
+
|
|
150
|
+
// Registry with a driver whose `dispose` throws a generic error.
|
|
151
|
+
const registry = new WorkspaceBackendRegistry()
|
|
152
|
+
registry.register({
|
|
153
|
+
kind: 'git-worktree',
|
|
154
|
+
async create() {
|
|
155
|
+
return {
|
|
156
|
+
id: 'wsp_x' as WorkspaceId,
|
|
157
|
+
meta: {
|
|
158
|
+
backend: 'git-worktree',
|
|
159
|
+
repoRoot: '/r',
|
|
160
|
+
branch: 'main',
|
|
161
|
+
worktreePath: '/r/x',
|
|
162
|
+
},
|
|
163
|
+
createdAt: new Date(),
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
async branch(ref) {
|
|
167
|
+
return ref
|
|
168
|
+
},
|
|
169
|
+
async dispose() {
|
|
170
|
+
throw new Error('simulated already-disposed race')
|
|
171
|
+
},
|
|
172
|
+
async inspect() {
|
|
173
|
+
return { exists: false, currentRef: 'HEAD', isDirty: false }
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
const workspaceRef: WorkspaceRef = {
|
|
178
|
+
id: 'wsp_live' as WorkspaceId,
|
|
179
|
+
meta: { backend: 'git-worktree', repoRoot: '/r', branch: 'main', worktreePath: '/r/y' },
|
|
180
|
+
createdAt: new Date(),
|
|
181
|
+
}
|
|
182
|
+
await store.updateSubSession(
|
|
183
|
+
{ ...sub, status: 'idle', workspaceId: workspaceRef.id },
|
|
184
|
+
DEFAULT_TENANT,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
const manager = new ArchivalManager({
|
|
188
|
+
sessionStore: store,
|
|
189
|
+
workspaceRegistry: registry,
|
|
190
|
+
archiveBackend: backend,
|
|
191
|
+
workspaceResolver: async () => workspaceRef,
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
const tombstone = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
195
|
+
expect(tombstone.archiveRef.startsWith('arc_')).toBe(true)
|
|
196
|
+
|
|
197
|
+
// Committed record persists despite dispose failure.
|
|
198
|
+
const after = await store.getSubSession(sub.id, DEFAULT_TENANT)
|
|
199
|
+
expect(after?.status).toBe('archived')
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it('archive full round-trip: archive → restore → archive again succeeds', async () => {
|
|
203
|
+
const { sub } = await seedIdleSubSession(store)
|
|
204
|
+
const manager = new ArchivalManager({
|
|
205
|
+
sessionStore: store,
|
|
206
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
207
|
+
archiveBackend: backend,
|
|
208
|
+
})
|
|
209
|
+
const tombstone1 = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
210
|
+
await manager.restore(sub.id, DEFAULT_TENANT)
|
|
211
|
+
|
|
212
|
+
const after = await store.getSubSession(sub.id, DEFAULT_TENANT)
|
|
213
|
+
expect(after?.status).toBe('idle')
|
|
214
|
+
|
|
215
|
+
// Re-archive produces a fresh tombstone.
|
|
216
|
+
const tombstone2 = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
217
|
+
expect(tombstone2.archiveRef).not.toBe(tombstone1.archiveRef)
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
it('onArchived callback receives the tombstone exactly once', async () => {
|
|
221
|
+
const { sub } = await seedIdleSubSession(store)
|
|
222
|
+
const onArchived = vi.fn()
|
|
223
|
+
const manager = new ArchivalManager({
|
|
224
|
+
sessionStore: store,
|
|
225
|
+
workspaceRegistry: new WorkspaceBackendRegistry(),
|
|
226
|
+
archiveBackend: backend,
|
|
227
|
+
onArchived,
|
|
228
|
+
})
|
|
229
|
+
const tombstone = await manager.archive(sub.id, DEFAULT_TENANT)
|
|
230
|
+
expect(onArchived).toHaveBeenCalledTimes(1)
|
|
231
|
+
expect(onArchived).toHaveBeenCalledWith(tombstone)
|
|
232
|
+
})
|
|
233
|
+
})
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration — AgentManager.provisionSpawn compensating rollback.
|
|
3
|
+
*
|
|
4
|
+
* Covers Codex SPAWN-ROLLBACK critique (ses_001-hierarchy-redesign Phase 2
|
|
5
|
+
* adversarial review, 2026-04-18). Without the try/catch wrapper around the
|
|
6
|
+
* createSession → updateSession → createSubSession → workspace.create
|
|
7
|
+
* mutation block, a failure after createSession leaves an `active` child
|
|
8
|
+
* session with no subsession edge — invisible to the parent, but counted
|
|
9
|
+
* against `maxDelegationWidth` and visible to SessionStore.listSessions
|
|
10
|
+
* consumers (archive/delete flows in ThreadManager).
|
|
11
|
+
*
|
|
12
|
+
* Failure modes exercised:
|
|
13
|
+
* A. Workspace driver throws on create. Subsession exists; must flip to
|
|
14
|
+
* 'failed' for audit. Child session must be hard-deleted.
|
|
15
|
+
* B. Subsession insert fails (store injection). No subsession recorded.
|
|
16
|
+
* Child session must be hard-deleted.
|
|
17
|
+
*
|
|
18
|
+
* Assertions in both cases:
|
|
19
|
+
* - sendMessage rejects with the underlying error.
|
|
20
|
+
* - SessionStore.listSessions(threadId) returns no row with the child id.
|
|
21
|
+
* - Parent session remains untouched (status, currentActor).
|
|
22
|
+
* - Fan-out cap reclaims the slot (next spawn succeeds up to the same
|
|
23
|
+
* width).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { describe, expect, it } from 'vitest'
|
|
27
|
+
import { EMPTY_TOKEN_USAGE } from '../../../constants/limits.js'
|
|
28
|
+
import { AgentManager } from '../../../manager/agent/lifecycle.js'
|
|
29
|
+
import { ThreadManager } from '../../../manager/thread/lifecycle.js'
|
|
30
|
+
import { AgentRegistry } from '../../../registry/agent/definitions.js'
|
|
31
|
+
import { InMemorySessionStore } from '../../../store/session/memory.js'
|
|
32
|
+
import { InMemoryThreadStore } from '../../../store/thread/memory.js'
|
|
33
|
+
import type {
|
|
34
|
+
AgentCapabilities,
|
|
35
|
+
AgentInput,
|
|
36
|
+
BaseAgentConfig,
|
|
37
|
+
BaseAgentResult,
|
|
38
|
+
} from '../../../types/agent/base.js'
|
|
39
|
+
import type { Agent } from '../../../types/agent/core.js'
|
|
40
|
+
import type { AgentDefinition } from '../../../types/agent/factory.js'
|
|
41
|
+
import type { AgentTaskContext, SendMessageOptions } from '../../../types/agent/task.js'
|
|
42
|
+
import type { RunId, TenantId, UserId } from '../../../types/ids/index.js'
|
|
43
|
+
import { createAssistantMessage } from '../../../types/message/index.js'
|
|
44
|
+
import type { SummaryId } from '../../../types/session/ids.js'
|
|
45
|
+
import { ZERO_COST } from '../../../utils/cost.js'
|
|
46
|
+
import { DefaultCapacityValidator } from '../../handoff/capacity.js'
|
|
47
|
+
import type { ActorRef } from '../../hierarchy/actor.js'
|
|
48
|
+
import { SessionSummaryMaterializer } from '../../summary/materialize.js'
|
|
49
|
+
import type {
|
|
50
|
+
BranchWorkspaceParams,
|
|
51
|
+
CreateWorkspaceParams,
|
|
52
|
+
WorkspaceBackendDriver,
|
|
53
|
+
WorkspaceInspection,
|
|
54
|
+
} from '../../workspace/driver.js'
|
|
55
|
+
import type { WorkspaceRef } from '../../workspace/ref.js'
|
|
56
|
+
import { WorkspaceBackendRegistry } from '../../workspace/registry.js'
|
|
57
|
+
|
|
58
|
+
const tenant = 'tnt_alpha' as TenantId
|
|
59
|
+
|
|
60
|
+
const capabilities: AgentCapabilities = {
|
|
61
|
+
supportsTools: false,
|
|
62
|
+
supportsStreaming: false,
|
|
63
|
+
supportsConcurrency: false,
|
|
64
|
+
supportsSubAgents: false,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function buildAgent(id: string): Agent<BaseAgentConfig, BaseAgentResult> {
|
|
68
|
+
return {
|
|
69
|
+
type: 'reactive',
|
|
70
|
+
metadata: {
|
|
71
|
+
type: 'reactive',
|
|
72
|
+
id,
|
|
73
|
+
name: id,
|
|
74
|
+
version: '1.0.0',
|
|
75
|
+
category: 'test',
|
|
76
|
+
description: id,
|
|
77
|
+
capabilities,
|
|
78
|
+
},
|
|
79
|
+
run: async (_input: AgentInput, _config: BaseAgentConfig): Promise<BaseAgentResult> => ({
|
|
80
|
+
runId: 'run_child' as RunId,
|
|
81
|
+
status: 'completed',
|
|
82
|
+
usage: { ...EMPTY_TOKEN_USAGE },
|
|
83
|
+
cost: { ...ZERO_COST },
|
|
84
|
+
iterations: 1,
|
|
85
|
+
durationMs: 1,
|
|
86
|
+
messages: [createAssistantMessage('child did the work')],
|
|
87
|
+
result: 'child did the work',
|
|
88
|
+
}),
|
|
89
|
+
cancel: async () => undefined,
|
|
90
|
+
getCapabilities: () => capabilities,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function buildDefinition(agent: Agent<BaseAgentConfig, BaseAgentResult>): AgentDefinition {
|
|
95
|
+
return {
|
|
96
|
+
info: {
|
|
97
|
+
id: agent.metadata.id,
|
|
98
|
+
name: agent.metadata.name,
|
|
99
|
+
version: agent.metadata.version,
|
|
100
|
+
category: agent.metadata.category,
|
|
101
|
+
description: agent.metadata.description,
|
|
102
|
+
tools: [],
|
|
103
|
+
defaults: { model: 'test', tokenBudget: 1_000 },
|
|
104
|
+
},
|
|
105
|
+
typedAgent: agent,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class FailingWorkspaceDriver implements WorkspaceBackendDriver {
|
|
110
|
+
readonly kind = 'git-worktree' as const
|
|
111
|
+
createCalls = 0
|
|
112
|
+
|
|
113
|
+
async create(_params: CreateWorkspaceParams): Promise<WorkspaceRef> {
|
|
114
|
+
this.createCalls += 1
|
|
115
|
+
throw new Error('synthetic workspace backend failure')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async branch(_source: WorkspaceRef, _params: BranchWorkspaceParams): Promise<WorkspaceRef> {
|
|
119
|
+
throw new Error('unused in this test')
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async dispose(_ref: WorkspaceRef): Promise<void> {
|
|
123
|
+
/* no-op */
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async inspect(_ref: WorkspaceRef): Promise<WorkspaceInspection> {
|
|
127
|
+
throw new Error('unused in this test')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
describe('provisionSpawn compensating rollback', () => {
|
|
132
|
+
it('workspace driver failure — deletes child session, marks subsession failed, leaves no orphan', async () => {
|
|
133
|
+
const store = new InMemorySessionStore()
|
|
134
|
+
const threadStore = new InMemoryThreadStore()
|
|
135
|
+
const project = await store.createProject(
|
|
136
|
+
{ tenantId: tenant, name: 'rollback-project' },
|
|
137
|
+
tenant,
|
|
138
|
+
)
|
|
139
|
+
const thread = await threadStore.createThread(
|
|
140
|
+
{ projectId: project.id, title: 'rollback-topic' },
|
|
141
|
+
tenant,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
const userActor: ActorRef = {
|
|
145
|
+
kind: 'user',
|
|
146
|
+
userId: 'usr_root' as UserId,
|
|
147
|
+
tenantId: tenant,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const parentSession = await store.createSession(
|
|
151
|
+
{ threadId: thread.id, projectId: project.id, currentActor: userActor },
|
|
152
|
+
tenant,
|
|
153
|
+
)
|
|
154
|
+
await store.updateSession({ ...parentSession, status: 'active' }, tenant)
|
|
155
|
+
|
|
156
|
+
let summaryCounter = 0
|
|
157
|
+
const materializer = new SessionSummaryMaterializer({
|
|
158
|
+
store,
|
|
159
|
+
generateSummaryId: () => `sum_test_${++summaryCounter}` as SummaryId,
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
const registry = new AgentRegistry()
|
|
163
|
+
registry.register(buildDefinition(buildAgent('worker')))
|
|
164
|
+
|
|
165
|
+
const workspaceRegistry = new WorkspaceBackendRegistry()
|
|
166
|
+
const failingDriver = new FailingWorkspaceDriver()
|
|
167
|
+
workspaceRegistry.register(failingDriver)
|
|
168
|
+
|
|
169
|
+
const threadManager = new ThreadManager({ threadStore, sessionStore: store })
|
|
170
|
+
const manager = new AgentManager(registry, undefined, {
|
|
171
|
+
sessionStore: store,
|
|
172
|
+
summaryMaterializer: materializer,
|
|
173
|
+
workspaceRegistry,
|
|
174
|
+
capacity: new DefaultCapacityValidator(store),
|
|
175
|
+
threadManager,
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
const taskContext: AgentTaskContext = {
|
|
179
|
+
parentRunId: 'run_parent' as RunId,
|
|
180
|
+
parentAgentId: 'supervisor',
|
|
181
|
+
parentAbortController: new AbortController(),
|
|
182
|
+
depth: 0,
|
|
183
|
+
budgetTracker: { total: 100_000, remaining: 100_000 },
|
|
184
|
+
tenantId: tenant,
|
|
185
|
+
threadId: thread.id,
|
|
186
|
+
sessionId: parentSession.id,
|
|
187
|
+
projectId: project.id,
|
|
188
|
+
parentActor: userActor,
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const options: SendMessageOptions = {
|
|
192
|
+
agentId: 'worker',
|
|
193
|
+
input: { messages: [], workingDirectory: '/tmp' },
|
|
194
|
+
parentSessionId: parentSession.id,
|
|
195
|
+
tenantId: tenant,
|
|
196
|
+
projectId: project.id,
|
|
197
|
+
parentActor: userActor,
|
|
198
|
+
workspaceBackend: 'git-worktree',
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
await expect(manager.sendMessage(options, taskContext)).rejects.toThrow(
|
|
202
|
+
'synthetic workspace backend failure',
|
|
203
|
+
)
|
|
204
|
+
expect(failingDriver.createCalls).toBe(1)
|
|
205
|
+
|
|
206
|
+
// Child session is gone — archive/delete flows and fan-out caps see
|
|
207
|
+
// zero child attached to the thread beyond the parent.
|
|
208
|
+
const sessionsOnThread = await store.listSessions(thread.id, tenant)
|
|
209
|
+
expect(sessionsOnThread.map((s) => s.id)).toEqual([parentSession.id])
|
|
210
|
+
|
|
211
|
+
// Parent session is untouched.
|
|
212
|
+
const refetchedParent = await store.getSession(parentSession.id, tenant)
|
|
213
|
+
expect(refetchedParent?.status).toBe('active')
|
|
214
|
+
expect(refetchedParent?.currentActor).toEqual(userActor)
|
|
215
|
+
|
|
216
|
+
// No subsession breadcrumb — `subsession_spawned` never fired
|
|
217
|
+
// (provisionSpawn aborted before buildSpawnRecord), so nothing is
|
|
218
|
+
// expecting an audit row. Leaving a `status: 'failed'` record would
|
|
219
|
+
// dangle with no corresponding emission.
|
|
220
|
+
const subsessions = await store.getChildren(parentSession.id, tenant)
|
|
221
|
+
expect(subsessions).toHaveLength(0)
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it('repeated rollback does not accumulate orphan sessions or subsessions', async () => {
|
|
225
|
+
const store = new InMemorySessionStore()
|
|
226
|
+
const threadStore = new InMemoryThreadStore()
|
|
227
|
+
const project = await store.createProject(
|
|
228
|
+
{
|
|
229
|
+
tenantId: tenant,
|
|
230
|
+
name: 'rollback-repeat-project',
|
|
231
|
+
},
|
|
232
|
+
tenant,
|
|
233
|
+
)
|
|
234
|
+
const thread = await threadStore.createThread(
|
|
235
|
+
{ projectId: project.id, title: 'rollback-width-topic' },
|
|
236
|
+
tenant,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
const userActor: ActorRef = {
|
|
240
|
+
kind: 'user',
|
|
241
|
+
userId: 'usr_root' as UserId,
|
|
242
|
+
tenantId: tenant,
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const parentSession = await store.createSession(
|
|
246
|
+
{ threadId: thread.id, projectId: project.id, currentActor: userActor },
|
|
247
|
+
tenant,
|
|
248
|
+
)
|
|
249
|
+
await store.updateSession({ ...parentSession, status: 'active' }, tenant)
|
|
250
|
+
|
|
251
|
+
let summaryCounter = 0
|
|
252
|
+
const materializer = new SessionSummaryMaterializer({
|
|
253
|
+
store,
|
|
254
|
+
generateSummaryId: () => `sum_test_${++summaryCounter}` as SummaryId,
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const registry = new AgentRegistry()
|
|
258
|
+
registry.register(buildDefinition(buildAgent('worker')))
|
|
259
|
+
|
|
260
|
+
const workspaceRegistry = new WorkspaceBackendRegistry()
|
|
261
|
+
workspaceRegistry.register(new FailingWorkspaceDriver())
|
|
262
|
+
|
|
263
|
+
const threadManager = new ThreadManager({ threadStore, sessionStore: store })
|
|
264
|
+
const manager = new AgentManager(registry, undefined, {
|
|
265
|
+
sessionStore: store,
|
|
266
|
+
summaryMaterializer: materializer,
|
|
267
|
+
workspaceRegistry,
|
|
268
|
+
capacity: new DefaultCapacityValidator(store),
|
|
269
|
+
threadManager,
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
const taskContext: AgentTaskContext = {
|
|
273
|
+
parentRunId: 'run_parent' as RunId,
|
|
274
|
+
parentAgentId: 'supervisor',
|
|
275
|
+
parentAbortController: new AbortController(),
|
|
276
|
+
depth: 0,
|
|
277
|
+
budgetTracker: { total: 100_000, remaining: 100_000 },
|
|
278
|
+
tenantId: tenant,
|
|
279
|
+
threadId: thread.id,
|
|
280
|
+
sessionId: parentSession.id,
|
|
281
|
+
projectId: project.id,
|
|
282
|
+
parentActor: userActor,
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const options: SendMessageOptions = {
|
|
286
|
+
agentId: 'worker',
|
|
287
|
+
input: { messages: [], workingDirectory: '/tmp' },
|
|
288
|
+
parentSessionId: parentSession.id,
|
|
289
|
+
tenantId: tenant,
|
|
290
|
+
projectId: project.id,
|
|
291
|
+
parentActor: userActor,
|
|
292
|
+
workspaceBackend: 'git-worktree',
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Two consecutive failing spawns. Without rollback, two orphan
|
|
296
|
+
// `active` child sessions would accumulate; with rollback, each
|
|
297
|
+
// attempt cleans up after itself and the store stays at { parent }.
|
|
298
|
+
await expect(manager.sendMessage(options, taskContext)).rejects.toThrow(
|
|
299
|
+
'synthetic workspace backend failure',
|
|
300
|
+
)
|
|
301
|
+
await expect(manager.sendMessage(options, taskContext)).rejects.toThrow(
|
|
302
|
+
'synthetic workspace backend failure',
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
// Still no child session under the thread.
|
|
306
|
+
const sessionsOnThread = await store.listSessions(thread.id, tenant)
|
|
307
|
+
expect(sessionsOnThread.map((s) => s.id)).toEqual([parentSession.id])
|
|
308
|
+
|
|
309
|
+
// No lingering subsession rows — both attempts rolled back cleanly.
|
|
310
|
+
const subsessions = await store.getChildren(parentSession.id, tenant)
|
|
311
|
+
expect(subsessions).toHaveLength(0)
|
|
312
|
+
})
|
|
313
|
+
})
|