oh-my-super-agent 0.1.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/.agents/agents/advisor.md +15 -0
- package/.agents/agents/conductor.md +32 -0
- package/.agents/agents/dreamer.md +13 -0
- package/.agents/agents/executor.md +17 -0
- package/.agents/agents/grader.md +15 -0
- package/.agents/config/endurance-policy.json +8 -0
- package/.agents/config/oms-config.json +119 -0
- package/.agents/config/release-policy.json +12 -0
- package/.agents/config/secret-scan-policy.json +7 -0
- package/.agents/config/verification-plan.json +33 -0
- package/.agents/registry.json +11 -0
- package/.agents/rules/constitution.md +7 -0
- package/.agents/skills/conductor/SKILL.md +23 -0
- package/.agents/skills/dream/SKILL.md +14 -0
- package/.agents/skills/executor/SKILL.md +13 -0
- package/.agents/skills/oms/SKILL.md +52 -0
- package/.agents/skills/quota-aware/SKILL.md +12 -0
- package/.agents/skills/schedule/SKILL.md +13 -0
- package/.agents/skills/team-protocol/SKILL.md +20 -0
- package/LICENSE +21 -0
- package/README.md +146 -0
- package/dist/src/audit/run-ledger.d.ts +183 -0
- package/dist/src/audit/run-ledger.js +1655 -0
- package/dist/src/audit/run-ledger.js.map +1 -0
- package/dist/src/cli.d.ts +61 -0
- package/dist/src/cli.js +2096 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/github-queue-probe.d.ts +26 -0
- package/dist/src/commands/github-queue-probe.js +51 -0
- package/dist/src/commands/github-queue-probe.js.map +1 -0
- package/dist/src/commands/trace-fixture.d.ts +20 -0
- package/dist/src/commands/trace-fixture.js +72 -0
- package/dist/src/commands/trace-fixture.js.map +1 -0
- package/dist/src/conductor/activity.d.ts +46 -0
- package/dist/src/conductor/activity.js +224 -0
- package/dist/src/conductor/activity.js.map +1 -0
- package/dist/src/conductor/bridge.d.ts +53 -0
- package/dist/src/conductor/bridge.js +652 -0
- package/dist/src/conductor/bridge.js.map +1 -0
- package/dist/src/conductor/notifications.d.ts +59 -0
- package/dist/src/conductor/notifications.js +381 -0
- package/dist/src/conductor/notifications.js.map +1 -0
- package/dist/src/conductor/recovery.d.ts +29 -0
- package/dist/src/conductor/recovery.js +198 -0
- package/dist/src/conductor/recovery.js.map +1 -0
- package/dist/src/conductor/start.d.ts +73 -0
- package/dist/src/conductor/start.js +519 -0
- package/dist/src/conductor/start.js.map +1 -0
- package/dist/src/conductor/waiter.d.ts +88 -0
- package/dist/src/conductor/waiter.js +427 -0
- package/dist/src/conductor/waiter.js.map +1 -0
- package/dist/src/config.d.ts +9 -0
- package/dist/src/config.js +40 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/dispatch/advice-source.d.ts +61 -0
- package/dist/src/dispatch/advice-source.js +198 -0
- package/dist/src/dispatch/advice-source.js.map +1 -0
- package/dist/src/dispatch/advice-store.d.ts +41 -0
- package/dist/src/dispatch/advice-store.js +201 -0
- package/dist/src/dispatch/advice-store.js.map +1 -0
- package/dist/src/dispatch/advice.d.ts +34 -0
- package/dist/src/dispatch/advice.js +371 -0
- package/dist/src/dispatch/advice.js.map +1 -0
- package/dist/src/dispatch/authority.d.ts +124 -0
- package/dist/src/dispatch/authority.js +1202 -0
- package/dist/src/dispatch/authority.js.map +1 -0
- package/dist/src/dispatch/intent.d.ts +66 -0
- package/dist/src/dispatch/intent.js +71 -0
- package/dist/src/dispatch/intent.js.map +1 -0
- package/dist/src/dispatch/runtime-authority.d.ts +42 -0
- package/dist/src/dispatch/runtime-authority.js +52 -0
- package/dist/src/dispatch/runtime-authority.js.map +1 -0
- package/dist/src/doctor.d.ts +20 -0
- package/dist/src/doctor.js +85 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/domain/records.d.ts +44 -0
- package/dist/src/domain/records.js +138 -0
- package/dist/src/domain/records.js.map +1 -0
- package/dist/src/domain/role-policy.d.ts +67 -0
- package/dist/src/domain/role-policy.js +547 -0
- package/dist/src/domain/role-policy.js.map +1 -0
- package/dist/src/events/bus.d.ts +32 -0
- package/dist/src/events/bus.js +115 -0
- package/dist/src/events/bus.js.map +1 -0
- package/dist/src/events/kinds.d.ts +126 -0
- package/dist/src/events/kinds.js +14 -0
- package/dist/src/events/kinds.js.map +1 -0
- package/dist/src/evidence/immutable-file.d.ts +12 -0
- package/dist/src/evidence/immutable-file.js +141 -0
- package/dist/src/evidence/immutable-file.js.map +1 -0
- package/dist/src/evidence/store.d.ts +125 -0
- package/dist/src/evidence/store.js +1189 -0
- package/dist/src/evidence/store.js.map +1 -0
- package/dist/src/evidence/verdict.d.ts +17 -0
- package/dist/src/evidence/verdict.js +23 -0
- package/dist/src/evidence/verdict.js.map +1 -0
- package/dist/src/generation/agent.d.ts +5 -0
- package/dist/src/generation/agent.js +34 -0
- package/dist/src/generation/agent.js.map +1 -0
- package/dist/src/generation/frontmatter.d.ts +7 -0
- package/dist/src/generation/frontmatter.js +33 -0
- package/dist/src/generation/frontmatter.js.map +1 -0
- package/dist/src/github/adapter.d.ts +44 -0
- package/dist/src/github/adapter.js +592 -0
- package/dist/src/github/adapter.js.map +1 -0
- package/dist/src/github/dispatch-eligibility.d.ts +9 -0
- package/dist/src/github/dispatch-eligibility.js +94 -0
- package/dist/src/github/dispatch-eligibility.js.map +1 -0
- package/dist/src/github/projector.d.ts +23 -0
- package/dist/src/github/projector.js +181 -0
- package/dist/src/github/projector.js.map +1 -0
- package/dist/src/github/review.d.ts +39 -0
- package/dist/src/github/review.js +1450 -0
- package/dist/src/github/review.js.map +1 -0
- package/dist/src/github/sync.d.ts +21 -0
- package/dist/src/github/sync.js +518 -0
- package/dist/src/github/sync.js.map +1 -0
- package/dist/src/github/types.d.ts +134 -0
- package/dist/src/github/types.js +11 -0
- package/dist/src/github/types.js.map +1 -0
- package/dist/src/goals/artifact-store.d.ts +31 -0
- package/dist/src/goals/artifact-store.js +241 -0
- package/dist/src/goals/artifact-store.js.map +1 -0
- package/dist/src/goals/authority.d.ts +112 -0
- package/dist/src/goals/authority.js +621 -0
- package/dist/src/goals/authority.js.map +1 -0
- package/dist/src/goals/native-snapshot.d.ts +12 -0
- package/dist/src/goals/native-snapshot.js +53 -0
- package/dist/src/goals/native-snapshot.js.map +1 -0
- package/dist/src/goals/runtime-authority.d.ts +7 -0
- package/dist/src/goals/runtime-authority.js +20 -0
- package/dist/src/goals/runtime-authority.js.map +1 -0
- package/dist/src/health/release-assessment.d.ts +11 -0
- package/dist/src/health/release-assessment.js +83 -0
- package/dist/src/health/release-assessment.js.map +1 -0
- package/dist/src/health/release-policy.d.ts +16 -0
- package/dist/src/health/release-policy.js +40 -0
- package/dist/src/health/release-policy.js.map +1 -0
- package/dist/src/hooks/native.d.ts +30 -0
- package/dist/src/hooks/native.js +495 -0
- package/dist/src/hooks/native.js.map +1 -0
- package/dist/src/hooks/provider-runtime.d.ts +55 -0
- package/dist/src/hooks/provider-runtime.js +479 -0
- package/dist/src/hooks/provider-runtime.js.map +1 -0
- package/dist/src/hooks/provider.d.ts +102 -0
- package/dist/src/hooks/provider.js +358 -0
- package/dist/src/hooks/provider.js.map +1 -0
- package/dist/src/live/contact-journal.d.ts +73 -0
- package/dist/src/live/contact-journal.js +439 -0
- package/dist/src/live/contact-journal.js.map +1 -0
- package/dist/src/live-probes/gh-adapter.d.ts +28 -0
- package/dist/src/live-probes/gh-adapter.js +188 -0
- package/dist/src/live-probes/gh-adapter.js.map +1 -0
- package/dist/src/live-probes/github-queue.d.ts +1 -0
- package/dist/src/live-probes/github-queue.js +2 -0
- package/dist/src/live-probes/github-queue.js.map +1 -0
- package/dist/src/notifications/slack-request.d.ts +13 -0
- package/dist/src/notifications/slack-request.js +40 -0
- package/dist/src/notifications/slack-request.js.map +1 -0
- package/dist/src/outbox/processor.d.ts +27 -0
- package/dist/src/outbox/processor.js +63 -0
- package/dist/src/outbox/processor.js.map +1 -0
- package/dist/src/outbox/store.d.ts +158 -0
- package/dist/src/outbox/store.js +834 -0
- package/dist/src/outbox/store.js.map +1 -0
- package/dist/src/package-root.d.ts +1 -0
- package/dist/src/package-root.js +26 -0
- package/dist/src/package-root.js.map +1 -0
- package/dist/src/project.d.ts +12 -0
- package/dist/src/project.js +60 -0
- package/dist/src/project.js.map +1 -0
- package/dist/src/projection/generated-file.d.ts +15 -0
- package/dist/src/projection/generated-file.js +72 -0
- package/dist/src/projection/generated-file.js.map +1 -0
- package/dist/src/projection/project-workspace.d.ts +11 -0
- package/dist/src/projection/project-workspace.js +94 -0
- package/dist/src/projection/project-workspace.js.map +1 -0
- package/dist/src/projection/registry.d.ts +15 -0
- package/dist/src/projection/registry.js +59 -0
- package/dist/src/projection/registry.js.map +1 -0
- package/dist/src/projection/safe-path.d.ts +4 -0
- package/dist/src/projection/safe-path.js +106 -0
- package/dist/src/projection/safe-path.js.map +1 -0
- package/dist/src/providers/claude-interactive.d.ts +38 -0
- package/dist/src/providers/claude-interactive.js +287 -0
- package/dist/src/providers/claude-interactive.js.map +1 -0
- package/dist/src/providers/claude-structured-bridge.d.ts +32 -0
- package/dist/src/providers/claude-structured-bridge.js +215 -0
- package/dist/src/providers/claude-structured-bridge.js.map +1 -0
- package/dist/src/providers/claude-structured-completion.d.ts +23 -0
- package/dist/src/providers/claude-structured-completion.js +229 -0
- package/dist/src/providers/claude-structured-completion.js.map +1 -0
- package/dist/src/providers/claude-structured-pane.d.ts +23 -0
- package/dist/src/providers/claude-structured-pane.js +156 -0
- package/dist/src/providers/claude-structured-pane.js.map +1 -0
- package/dist/src/providers/claude-structured-store.d.ts +48 -0
- package/dist/src/providers/claude-structured-store.js +212 -0
- package/dist/src/providers/claude-structured-store.js.map +1 -0
- package/dist/src/providers/claude-structured.d.ts +56 -0
- package/dist/src/providers/claude-structured.js +250 -0
- package/dist/src/providers/claude-structured.js.map +1 -0
- package/dist/src/providers/codex-exec.d.ts +29 -0
- package/dist/src/providers/codex-exec.js +127 -0
- package/dist/src/providers/codex-exec.js.map +1 -0
- package/dist/src/providers/grading.d.ts +2 -0
- package/dist/src/providers/grading.js +20 -0
- package/dist/src/providers/grading.js.map +1 -0
- package/dist/src/providers/native-dispatch.d.ts +24 -0
- package/dist/src/providers/native-dispatch.js +34 -0
- package/dist/src/providers/native-dispatch.js.map +1 -0
- package/dist/src/providers/preflight.d.ts +65 -0
- package/dist/src/providers/preflight.js +256 -0
- package/dist/src/providers/preflight.js.map +1 -0
- package/dist/src/providers/process.d.ts +18 -0
- package/dist/src/providers/process.js +21 -0
- package/dist/src/providers/process.js.map +1 -0
- package/dist/src/queue/model.d.ts +37 -0
- package/dist/src/queue/model.js +51 -0
- package/dist/src/queue/model.js.map +1 -0
- package/dist/src/queue/service.d.ts +1 -0
- package/dist/src/queue/service.js +2 -0
- package/dist/src/queue/service.js.map +1 -0
- package/dist/src/reflections/store.d.ts +21 -0
- package/dist/src/reflections/store.js +60 -0
- package/dist/src/reflections/store.js.map +1 -0
- package/dist/src/reports/daily-trust.d.ts +11 -0
- package/dist/src/reports/daily-trust.js +98 -0
- package/dist/src/reports/daily-trust.js.map +1 -0
- package/dist/src/runs/controller.d.ts +187 -0
- package/dist/src/runs/controller.js +1182 -0
- package/dist/src/runs/controller.js.map +1 -0
- package/dist/src/runtime/composition.d.ts +9 -0
- package/dist/src/runtime/composition.js +35 -0
- package/dist/src/runtime/composition.js.map +1 -0
- package/dist/src/runtime/endurance-authorities.d.ts +44 -0
- package/dist/src/runtime/endurance-authorities.js +101 -0
- package/dist/src/runtime/endurance-authorities.js.map +1 -0
- package/dist/src/runtime/endurance-policy.d.ts +12 -0
- package/dist/src/runtime/endurance-policy.js +13 -0
- package/dist/src/runtime/endurance-policy.js.map +1 -0
- package/dist/src/runtime/lock.d.ts +63 -0
- package/dist/src/runtime/lock.js +577 -0
- package/dist/src/runtime/lock.js.map +1 -0
- package/dist/src/runtime/process-identity.d.ts +10 -0
- package/dist/src/runtime/process-identity.js +43 -0
- package/dist/src/runtime/process-identity.js.map +1 -0
- package/dist/src/runtime/quota.d.ts +130 -0
- package/dist/src/runtime/quota.js +590 -0
- package/dist/src/runtime/quota.js.map +1 -0
- package/dist/src/runtime/record-store.d.ts +45 -0
- package/dist/src/runtime/record-store.js +272 -0
- package/dist/src/runtime/record-store.js.map +1 -0
- package/dist/src/runtime/schema.d.ts +28 -0
- package/dist/src/runtime/schema.js +194 -0
- package/dist/src/runtime/schema.js.map +1 -0
- package/dist/src/runtime/stable-id.d.ts +3 -0
- package/dist/src/runtime/stable-id.js +27 -0
- package/dist/src/runtime/stable-id.js.map +1 -0
- package/dist/src/runtime/system-clock.d.ts +8 -0
- package/dist/src/runtime/system-clock.js +35 -0
- package/dist/src/runtime/system-clock.js.map +1 -0
- package/dist/src/schedule/service-plan.d.ts +58 -0
- package/dist/src/schedule/service-plan.js +327 -0
- package/dist/src/schedule/service-plan.js.map +1 -0
- package/dist/src/schedule/user-installation.d.ts +62 -0
- package/dist/src/schedule/user-installation.js +701 -0
- package/dist/src/schedule/user-installation.js.map +1 -0
- package/dist/src/schedule/user-plan.d.ts +47 -0
- package/dist/src/schedule/user-plan.js +286 -0
- package/dist/src/schedule/user-plan.js.map +1 -0
- package/dist/src/scheduler/minute.d.ts +31 -0
- package/dist/src/scheduler/minute.js +441 -0
- package/dist/src/scheduler/minute.js.map +1 -0
- package/dist/src/schemas/registry.d.ts +10 -0
- package/dist/src/schemas/registry.js +36 -0
- package/dist/src/schemas/registry.js.map +1 -0
- package/dist/src/security/secret-scan.d.ts +50 -0
- package/dist/src/security/secret-scan.js +384 -0
- package/dist/src/security/secret-scan.js.map +1 -0
- package/dist/src/sessions/registry.d.ts +89 -0
- package/dist/src/sessions/registry.js +443 -0
- package/dist/src/sessions/registry.js.map +1 -0
- package/dist/src/state.d.ts +27 -0
- package/dist/src/state.js +235 -0
- package/dist/src/state.js.map +1 -0
- package/dist/src/status/hud.d.ts +37 -0
- package/dist/src/status/hud.js +88 -0
- package/dist/src/status/hud.js.map +1 -0
- package/dist/src/team/plan.d.ts +31 -0
- package/dist/src/team/plan.js +184 -0
- package/dist/src/team/plan.js.map +1 -0
- package/dist/src/team/projection.d.ts +24 -0
- package/dist/src/team/projection.js +79 -0
- package/dist/src/team/projection.js.map +1 -0
- package/dist/src/tickets/admission.d.ts +34 -0
- package/dist/src/tickets/admission.js +169 -0
- package/dist/src/tickets/admission.js.map +1 -0
- package/dist/src/tickets/materializer.d.ts +1 -0
- package/dist/src/tickets/materializer.js +2 -0
- package/dist/src/tickets/materializer.js.map +1 -0
- package/dist/src/tickets/runtime-authority.d.ts +32 -0
- package/dist/src/tickets/runtime-authority.js +46 -0
- package/dist/src/tickets/runtime-authority.js.map +1 -0
- package/dist/src/tickets/store.d.ts +221 -0
- package/dist/src/tickets/store.js +2025 -0
- package/dist/src/tickets/store.js.map +1 -0
- package/dist/src/tracer/one-ticket.d.ts +58 -0
- package/dist/src/tracer/one-ticket.js +578 -0
- package/dist/src/tracer/one-ticket.js.map +1 -0
- package/dist/src/trust/assessment.d.ts +24 -0
- package/dist/src/trust/assessment.js +124 -0
- package/dist/src/trust/assessment.js.map +1 -0
- package/dist/src/trust/runs.d.ts +13 -0
- package/dist/src/trust/runs.js +46 -0
- package/dist/src/trust/runs.js.map +1 -0
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/fs.d.ts +13 -0
- package/dist/src/utils/fs.js +188 -0
- package/dist/src/utils/fs.js.map +1 -0
- package/dist/src/verification/authority.d.ts +28 -0
- package/dist/src/verification/authority.js +153 -0
- package/dist/src/verification/authority.js.map +1 -0
- package/dist/src/verification/grade-source.d.ts +17 -0
- package/dist/src/verification/grade-source.js +30 -0
- package/dist/src/verification/grade-source.js.map +1 -0
- package/dist/src/verification/plan.d.ts +20 -0
- package/dist/src/verification/plan.js +128 -0
- package/dist/src/verification/plan.js.map +1 -0
- package/dist/src/verification/protected-runner.d.ts +50 -0
- package/dist/src/verification/protected-runner.js +171 -0
- package/dist/src/verification/protected-runner.js.map +1 -0
- package/dist/src/verification/result-gate-store.d.ts +72 -0
- package/dist/src/verification/result-gate-store.js +193 -0
- package/dist/src/verification/result-gate-store.js.map +1 -0
- package/dist/src/verification/result-gate.d.ts +41 -0
- package/dist/src/verification/result-gate.js +731 -0
- package/dist/src/verification/result-gate.js.map +1 -0
- package/dist/src/verification/runner.d.ts +38 -0
- package/dist/src/verification/runner.js +143 -0
- package/dist/src/verification/runner.js.map +1 -0
- package/dist/src/verification/sandbox.d.ts +16 -0
- package/dist/src/verification/sandbox.js +199 -0
- package/dist/src/verification/sandbox.js.map +1 -0
- package/dist/src/verify.d.ts +8 -0
- package/dist/src/verify.js +35 -0
- package/dist/src/verify.js.map +1 -0
- package/dist/src/watchdog/reconcile.d.ts +42 -0
- package/dist/src/watchdog/reconcile.js +440 -0
- package/dist/src/watchdog/reconcile.js.map +1 -0
- package/dist/src/workers/bridge.d.ts +35 -0
- package/dist/src/workers/bridge.js +426 -0
- package/dist/src/workers/bridge.js.map +1 -0
- package/dist/src/workers/delivery.d.ts +31 -0
- package/dist/src/workers/delivery.js +876 -0
- package/dist/src/workers/delivery.js.map +1 -0
- package/dist/src/workers/panes.d.ts +32 -0
- package/dist/src/workers/panes.js +212 -0
- package/dist/src/workers/panes.js.map +1 -0
- package/dist/src/workers/registry.d.ts +80 -0
- package/dist/src/workers/registry.js +351 -0
- package/dist/src/workers/registry.js.map +1 -0
- package/dist/src/workers/runtime.d.ts +44 -0
- package/dist/src/workers/runtime.js +21 -0
- package/dist/src/workers/runtime.js.map +1 -0
- package/dist/src/worktrees/manager.d.ts +35 -0
- package/dist/src/worktrees/manager.js +315 -0
- package/dist/src/worktrees/manager.js.map +1 -0
- package/docs/ARCHITECTURE.md +323 -0
- package/docs/PLAN.md +216 -0
- package/docs/REFERENCES.md +42 -0
- package/docs/ROADMAP.md +327 -0
- package/docs/SECURITY.md +242 -0
- package/docs/adr/0001-tracer-first-file-backed-certification.md +41 -0
- package/docs/adr/0002-conductor-first-typed-dispatch.md +102 -0
- package/docs/adr/0003-mandatory-pre-dispatch-advice.md +59 -0
- package/docs/compatibility/claude-code-2.1.207.md +25 -0
- package/loop/contract.md +102 -0
- package/package.json +54 -0
- package/schemas/advisor-evidence.schema.json +54 -0
- package/schemas/advisor-output.schema.json +31 -0
- package/schemas/conductor-activity-payload.schema.json +38 -0
- package/schemas/conductor-decision.schema.json +29 -0
- package/schemas/conductor-dispatch-intent.schema.json +71 -0
- package/schemas/conductor-dispatch-preparation.schema.json +46 -0
- package/schemas/conductor-dispatch-proposal.schema.json +82 -0
- package/schemas/conductor-goal-proposal.schema.json +30 -0
- package/schemas/conductor-manage-worker.schema.json +17 -0
- package/schemas/conductor-notification-payload.schema.json +39 -0
- package/schemas/conductor-process-result.schema.json +14 -0
- package/schemas/conductor-route.schema.json +51 -0
- package/schemas/conductor-start-team.schema.json +16 -0
- package/schemas/conductor-waiter-payload.schema.json +68 -0
- package/schemas/deterministic-check.schema.json +107 -0
- package/schemas/dispatch-acknowledgement.schema.json +15 -0
- package/schemas/dispatch-advice-payload.schema.json +64 -0
- package/schemas/dispatch-payload.schema.json +131 -0
- package/schemas/dispatch-result.schema.json +28 -0
- package/schemas/endurance-policy.schema.json +16 -0
- package/schemas/events/dispatch-delivery-requested.schema.json +17 -0
- package/schemas/events/github-observed.schema.json +28 -0
- package/schemas/events/native-hook-observed.schema.json +35 -0
- package/schemas/events/provider-observed.schema.json +64 -0
- package/schemas/events/run-heartbeat-due.schema.json +10 -0
- package/schemas/events/slack-notification-requested.schema.json +14 -0
- package/schemas/events/structured-role-completed.schema.json +54 -0
- package/schemas/events/ticket-resume-due.schema.json +28 -0
- package/schemas/events/watchdog-lease-expired.schema.json +14 -0
- package/schemas/events/watchdog-outbox-stalled.schema.json +12 -0
- package/schemas/events/watchdog-session-stalled.schema.json +11 -0
- package/schemas/evidence-record.schema.json +37 -0
- package/schemas/executor-result.schema.json +17 -0
- package/schemas/github-observation.schema.json +33 -0
- package/schemas/github-watermark.schema.json +66 -0
- package/schemas/goal-artifact.schema.json +19 -0
- package/schemas/goal-create-input.schema.json +14 -0
- package/schemas/goal-executor-result.schema.json +18 -0
- package/schemas/goal-payload.schema.json +95 -0
- package/schemas/grader-output.schema.json +33 -0
- package/schemas/lease-expiry.schema.json +19 -0
- package/schemas/live-disclosure.schema.json +16 -0
- package/schemas/live-outcome.schema.json +52 -0
- package/schemas/native-goal-snapshot.schema.json +27 -0
- package/schemas/provider-observed.schema.json +64 -0
- package/schemas/quota-observation.schema.json +72 -0
- package/schemas/reflection-evidence.schema.json +61 -0
- package/schemas/reflection.schema.json +13 -0
- package/schemas/regression-request.schema.json +54 -0
- package/schemas/release-assessment.schema.json +34 -0
- package/schemas/release-policy.schema.json +30 -0
- package/schemas/result-gate-payload.schema.json +244 -0
- package/schemas/review-delivery-payload.schema.json +42 -0
- package/schemas/role-policy.schema.json +111 -0
- package/schemas/run-abort-input.schema.json +11 -0
- package/schemas/run-completion-proof.schema.json +62 -0
- package/schemas/run-ledger-entry.schema.json +78 -0
- package/schemas/run-manifest.schema.json +74 -0
- package/schemas/run-start-intent.schema.json +74 -0
- package/schemas/runtime-record.schema.json +111 -0
- package/schemas/service-plan.schema.json +35 -0
- package/schemas/session-payload.schema.json +80 -0
- package/schemas/structured-role-read-request.schema.json +14 -0
- package/schemas/structured-role-request.schema.json +44 -0
- package/schemas/structured-role-result.schema.json +38 -0
- package/schemas/structured-role-submit-result.schema.json +15 -0
- package/schemas/team-checkpoint.schema.json +42 -0
- package/schemas/team-plan.schema.json +30 -0
- package/schemas/ticket-content.schema.json +38 -0
- package/schemas/ticket-queue-payload.schema.json +191 -0
- package/schemas/trust-report.schema.json +68 -0
- package/schemas/trust-run.schema.json +47 -0
- package/schemas/ultragoal-checkpoint.schema.json +49 -0
- package/schemas/user-schedule-installation-v1.schema.json +32 -0
- package/schemas/user-schedule-installation.schema.json +38 -0
- package/schemas/user-schedule-plan.schema.json +39 -0
- package/schemas/verification-plan-evidence.schema.json +37 -0
- package/schemas/worker-acknowledge-dispatch.schema.json +12 -0
- package/schemas/worker-payload.schema.json +47 -0
- package/schemas/worker-read-dispatch.schema.json +11 -0
- package/schemas/worker-record-dispatch-result.schema.json +14 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { assertActorId, assertOpaqueId, assertRecordId, assertTransitionNonce, recordFileName, } from "../domain/records.js";
|
|
4
|
+
import { findPackageRoot } from "../package-root.js";
|
|
5
|
+
import { acquireDirectoryLock } from "../runtime/lock.js";
|
|
6
|
+
import { createRecordStore } from "../runtime/record-store.js";
|
|
7
|
+
import { assertSchema, loadJsonSchema } from "../runtime/schema.js";
|
|
8
|
+
import { createStableId } from "../runtime/stable-id.js";
|
|
9
|
+
import { assertTeamCheckpointProjection, projectReadOnlyTeamState } from "../team/projection.js";
|
|
10
|
+
import { validateExistingDirectory } from "../utils/fs.js";
|
|
11
|
+
import { assertGoalArtifactStore, } from "./artifact-store.js";
|
|
12
|
+
import { assertNativeGoalSnapshot, parseNativeGoalSnapshot } from "./native-snapshot.js";
|
|
13
|
+
const GOAL_AUTHORITIES = new WeakMap();
|
|
14
|
+
const GOAL_PLAN_GATES = new WeakMap();
|
|
15
|
+
export function createGoalAuthority(options) {
|
|
16
|
+
const artifactStore = options.artifactStore;
|
|
17
|
+
assertGoalArtifactStore(artifactStore);
|
|
18
|
+
const packageRoot = options.packageRoot ?? findPackageRoot();
|
|
19
|
+
const recordsRoot = validateExistingDirectory(options.recordsRoot, "goal records root");
|
|
20
|
+
const locksRoot = validateExistingDirectory(options.locksRoot, "goal locks root");
|
|
21
|
+
const payloadSchema = loadJsonSchema(join(packageRoot, "schemas", "goal-payload.schema.json"));
|
|
22
|
+
const store = createRecordStore({
|
|
23
|
+
recordsRoot,
|
|
24
|
+
locksRoot,
|
|
25
|
+
recordValidator: (record) => validateGoalRecord(record, payloadSchema, artifactStore),
|
|
26
|
+
transitionValidator: validateGoalTransition,
|
|
27
|
+
});
|
|
28
|
+
const facade = Object.freeze({
|
|
29
|
+
read(goalId) {
|
|
30
|
+
return freezeGoal(store.read(assertRecordId(goalId, "goal id")));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
GOAL_AUTHORITIES.set(facade, { store, artifacts: artifactStore, packageRoot, recordsRoot, locksRoot });
|
|
34
|
+
return facade;
|
|
35
|
+
}
|
|
36
|
+
export function assertGoalAuthority(value) {
|
|
37
|
+
if (typeof value !== "object" || value === null || !GOAL_AUTHORITIES.has(value)) {
|
|
38
|
+
throw new Error("goal operation requires a real branded OMS GoalAuthority");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function createGoal(authority, input) {
|
|
42
|
+
return createGoalWithReplay(authority, input).goal;
|
|
43
|
+
}
|
|
44
|
+
export function createGoalWithReplay(authority, input) {
|
|
45
|
+
const internals = internalsFor(authority);
|
|
46
|
+
const objective = assertText(input.objective, "goal objective");
|
|
47
|
+
const stoppingCondition = assertText(input.stoppingCondition, "goal stopping condition");
|
|
48
|
+
const repositoryScope = assertText(input.repositoryScope, "goal repository scope");
|
|
49
|
+
const queueScope = assertText(input.queueScope ?? "default", "goal queue scope");
|
|
50
|
+
const runtimeHorizon = assertRuntimeHorizon(input.runtimeHorizon ?? "until-empty");
|
|
51
|
+
const budgetProfile = assertBudgetProfile(input.budgetProfile ?? "subscription-only");
|
|
52
|
+
const policyProfile = assertPolicyProfile(input.policyProfile ?? "default");
|
|
53
|
+
const leader = assertActorId(input.leaderId, "goal leader id");
|
|
54
|
+
timestampEpoch(input.createdAt, "goal created_at");
|
|
55
|
+
const creationNonce = assertTransitionNonce(input.creationNonce ?? createStableId("goal-create", objective, repositoryScope, queueScope, stoppingCondition, runtimeHorizon, budgetProfile, policyProfile));
|
|
56
|
+
const goalId = goalIdentity({
|
|
57
|
+
objective,
|
|
58
|
+
repositoryScope,
|
|
59
|
+
queueScope,
|
|
60
|
+
stoppingCondition,
|
|
61
|
+
runtimeHorizon,
|
|
62
|
+
budgetProfile,
|
|
63
|
+
policyProfile,
|
|
64
|
+
creationNonce,
|
|
65
|
+
});
|
|
66
|
+
const nonce = creationNonce;
|
|
67
|
+
const record = {
|
|
68
|
+
schema_version: 1,
|
|
69
|
+
record_id: assertRecordId(goalId),
|
|
70
|
+
record_kind: assertOpaqueId("oms-goal", "goal record kind"),
|
|
71
|
+
version: 0,
|
|
72
|
+
state: "active",
|
|
73
|
+
attempt: 1,
|
|
74
|
+
max_attempts: 1,
|
|
75
|
+
actor: leader,
|
|
76
|
+
lease_token: null,
|
|
77
|
+
transition_nonce: nonce,
|
|
78
|
+
payload: {
|
|
79
|
+
goal_id: goalId,
|
|
80
|
+
objective,
|
|
81
|
+
repository_scope: repositoryScope,
|
|
82
|
+
queue_scope: queueScope,
|
|
83
|
+
stopping_condition: stoppingCondition,
|
|
84
|
+
runtime_horizon: runtimeHorizon,
|
|
85
|
+
budget_profile: budgetProfile,
|
|
86
|
+
policy_profile: policyProfile,
|
|
87
|
+
creation_nonce: creationNonce,
|
|
88
|
+
created_at: input.createdAt,
|
|
89
|
+
updated_at: input.createdAt,
|
|
90
|
+
native_snapshot: null,
|
|
91
|
+
team_checkpoint: null,
|
|
92
|
+
ultragoal_checkpoint: null,
|
|
93
|
+
regression_request: null,
|
|
94
|
+
park_reason: null,
|
|
95
|
+
},
|
|
96
|
+
transition_outcomes: [{
|
|
97
|
+
nonce,
|
|
98
|
+
version: 0,
|
|
99
|
+
state: "active",
|
|
100
|
+
attempt: 1,
|
|
101
|
+
actor: leader,
|
|
102
|
+
lease_token: null,
|
|
103
|
+
}],
|
|
104
|
+
};
|
|
105
|
+
const lock = acquireDirectoryLock({
|
|
106
|
+
locksRoot: internals.locksRoot,
|
|
107
|
+
lockId: "goal-authority-create",
|
|
108
|
+
ownerId: leader,
|
|
109
|
+
note: `create:${creationNonce}`,
|
|
110
|
+
});
|
|
111
|
+
try {
|
|
112
|
+
const existing = internals.store.list();
|
|
113
|
+
const nonceMatch = existing.find((candidate) => candidate.payload.creation_nonce === creationNonce);
|
|
114
|
+
if (nonceMatch) {
|
|
115
|
+
if (nonceMatch.actor !== leader || !sameGoalCreationPayload(nonceMatch.payload, record.payload)) {
|
|
116
|
+
throw new Error("goal creation nonce already exists with different authority or payload");
|
|
117
|
+
}
|
|
118
|
+
return Object.freeze({ status: "replayed", goal: freezeGoal(nonceMatch) });
|
|
119
|
+
}
|
|
120
|
+
const active = existing.filter((candidate) => candidate.state === "active");
|
|
121
|
+
if (active.length > 1)
|
|
122
|
+
throw new Error("goal authority contains multiple active goals");
|
|
123
|
+
if (active.length === 1)
|
|
124
|
+
throw new Error("goal authority already has an active goal with a different creation nonce");
|
|
125
|
+
return Object.freeze({ status: "created", goal: freezeGoal(internals.store.create(record)) });
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
lock.release();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function readGoal(authority, goalId) {
|
|
132
|
+
assertGoalAuthority(authority);
|
|
133
|
+
return authority.read(goalId);
|
|
134
|
+
}
|
|
135
|
+
export function issueActiveGoalPlanGate(authority, goalId) {
|
|
136
|
+
const internals = internalsFor(authority);
|
|
137
|
+
const current = readMutableGoal(internals, goalId);
|
|
138
|
+
if (current.state !== "active")
|
|
139
|
+
throw new Error(`GoalPlanGate requires an active goal: ${current.record_id}`);
|
|
140
|
+
const gate = Object.freeze(goalPlanBinding(internals, current));
|
|
141
|
+
GOAL_PLAN_GATES.set(gate, Object.freeze({ authority, binding: gate }));
|
|
142
|
+
return gate;
|
|
143
|
+
}
|
|
144
|
+
export function assertGoalPlanGate(value) {
|
|
145
|
+
if (typeof value !== "object" || value === null || !GOAL_PLAN_GATES.has(value)) {
|
|
146
|
+
throw new Error("Team planning requires a real GoalAuthority-issued GoalPlanGate");
|
|
147
|
+
}
|
|
148
|
+
if (!Object.isFrozen(value))
|
|
149
|
+
throw new Error("GoalPlanGate lost its frozen authority boundary");
|
|
150
|
+
}
|
|
151
|
+
export function assertFreshGoalPlanGate(gate) {
|
|
152
|
+
assertGoalPlanGate(gate);
|
|
153
|
+
const metadata = GOAL_PLAN_GATES.get(gate);
|
|
154
|
+
if (!metadata)
|
|
155
|
+
throw new Error("GoalPlanGate metadata is unavailable");
|
|
156
|
+
if (!sameGoalPlanBinding(gate, metadata.binding))
|
|
157
|
+
throw new Error("GoalPlanGate binding changed after issuance");
|
|
158
|
+
const internals = internalsFor(metadata.authority);
|
|
159
|
+
const current = readMutableGoal(internals, metadata.binding.goal_id);
|
|
160
|
+
if (current.state !== "active")
|
|
161
|
+
throw new Error(`stale GoalPlanGate: canonical goal is ${current.state}`);
|
|
162
|
+
if (!sameGoalPlanBinding(goalPlanBinding(internals, current), metadata.binding)) {
|
|
163
|
+
throw new Error("stale GoalPlanGate: canonical goal version or identity changed");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export function recordNativeGoalSnapshot(options) {
|
|
167
|
+
const internals = internalsFor(options.authority);
|
|
168
|
+
const current = readMutableGoal(internals, options.goalId);
|
|
169
|
+
if (current.state !== "active")
|
|
170
|
+
throw new Error(`native snapshot cannot attach while goal is ${current.state}`);
|
|
171
|
+
const observedAt = timestampEpoch(options.observedAt, "native snapshot observed_at");
|
|
172
|
+
const snapshot = parseNativeGoalSnapshot(options.snapshot, internals.packageRoot);
|
|
173
|
+
assertNativeGoalSnapshot(snapshot);
|
|
174
|
+
const capturedAt = timestampEpoch(snapshot.captured_at, "native snapshot captured_at");
|
|
175
|
+
if (observedAt < capturedAt)
|
|
176
|
+
throw new Error("native snapshot observation predates capture");
|
|
177
|
+
const artifact = writeNativeSnapshot(internals.artifacts, current, snapshot);
|
|
178
|
+
const identityMismatch = snapshot.native_goal_id !== current.record_id
|
|
179
|
+
|| snapshot.objective !== current.payload.objective
|
|
180
|
+
|| snapshot.stopping_condition !== current.payload.stopping_condition;
|
|
181
|
+
if (identityMismatch) {
|
|
182
|
+
return parkWithRegression(internals, current, {
|
|
183
|
+
reason: "native-goal-mismatch",
|
|
184
|
+
requestedAt: options.observedAt,
|
|
185
|
+
sources: [artifact.ref],
|
|
186
|
+
predicate: null,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
let stale = capturedAt <= timestampEpoch(current.payload.updated_at, "goal updated_at");
|
|
190
|
+
if (current.payload.native_snapshot) {
|
|
191
|
+
const previous = internals.artifacts.read(current.payload.native_snapshot);
|
|
192
|
+
stale ||= Number(snapshot.snapshot_version) <= Number(previous.payload.snapshot_version);
|
|
193
|
+
}
|
|
194
|
+
if (stale) {
|
|
195
|
+
return parkWithRegression(internals, current, {
|
|
196
|
+
reason: "stale-native-snapshot",
|
|
197
|
+
requestedAt: options.observedAt,
|
|
198
|
+
sources: [artifact.ref],
|
|
199
|
+
predicate: null,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const result = transitionGoal(internals, current, "active", createStableId("native-attach", current.record_id, artifact.ref.artifact_id), {
|
|
203
|
+
...current.payload,
|
|
204
|
+
updated_at: options.observedAt,
|
|
205
|
+
native_snapshot: artifact.ref,
|
|
206
|
+
});
|
|
207
|
+
return Object.freeze({ status: "attached", goal: freezeGoal(result), artifact: artifact.ref });
|
|
208
|
+
}
|
|
209
|
+
export function recordTeamCheckpoint(options) {
|
|
210
|
+
const internals = internalsFor(options.authority);
|
|
211
|
+
const current = readMutableGoal(internals, options.goalId);
|
|
212
|
+
if (current.state !== "active")
|
|
213
|
+
throw new Error(`Team checkpoint cannot attach while goal is ${current.state}`);
|
|
214
|
+
const projection = projectReadOnlyTeamState(options.teamState, internals.packageRoot);
|
|
215
|
+
assertTeamCheckpointProjection(projection);
|
|
216
|
+
if (projection.goal_id !== current.record_id)
|
|
217
|
+
throw new Error("Team checkpoint belongs to a different goal");
|
|
218
|
+
const completedAt = timestampEpoch(projection.delivery_wave.completed_at, "Team delivery completed_at");
|
|
219
|
+
const goalUpdatedAt = timestampEpoch(current.payload.updated_at, "goal updated_at");
|
|
220
|
+
if (completedAt <= goalUpdatedAt) {
|
|
221
|
+
throw new Error("stale Team checkpoint");
|
|
222
|
+
}
|
|
223
|
+
if (current.payload.team_checkpoint)
|
|
224
|
+
throw new Error("goal already has a different Team checkpoint");
|
|
225
|
+
const artifact = writeTeamArtifact(internals.artifacts, current.record_id, projection);
|
|
226
|
+
const result = transitionGoal(internals, current, "active", createStableId("team-attach", current.record_id, artifact.ref.artifact_id), {
|
|
227
|
+
...current.payload,
|
|
228
|
+
updated_at: projection.delivery_wave.completed_at,
|
|
229
|
+
team_checkpoint: artifact.ref,
|
|
230
|
+
});
|
|
231
|
+
return Object.freeze({ status: "attached", goal: freezeGoal(result), artifact: artifact.ref });
|
|
232
|
+
}
|
|
233
|
+
export function recordBrokenGoalPredicate(options) {
|
|
234
|
+
const internals = internalsFor(options.authority);
|
|
235
|
+
const current = readMutableGoal(internals, options.goalId);
|
|
236
|
+
if (current.state !== "active" && current.state !== "completed") {
|
|
237
|
+
throw new Error(`predicate failure cannot park goal while ${current.state}`);
|
|
238
|
+
}
|
|
239
|
+
assertRecordId(options.predicateId, "predicate id");
|
|
240
|
+
assertSha256(options.expectedSha256, "predicate expected digest");
|
|
241
|
+
assertSha256(options.actualSha256, "predicate actual digest");
|
|
242
|
+
if (options.expectedSha256 === options.actualSha256)
|
|
243
|
+
throw new Error("predicate result did not fail");
|
|
244
|
+
requireNewerTimestamp(options.observedAt, current.payload.updated_at, "predicate observed_at");
|
|
245
|
+
return parkWithRegression(internals, current, {
|
|
246
|
+
reason: "predicate-failed",
|
|
247
|
+
requestedAt: options.observedAt,
|
|
248
|
+
sources: [],
|
|
249
|
+
predicate: {
|
|
250
|
+
predicate_id: options.predicateId,
|
|
251
|
+
expected_sha256: options.expectedSha256,
|
|
252
|
+
actual_sha256: options.actualSha256,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export function checkpointUltragoal(options) {
|
|
257
|
+
const internals = internalsFor(options.authority);
|
|
258
|
+
const current = readMutableGoal(internals, options.goalId);
|
|
259
|
+
const leader = assertActorId(options.leaderId, "Ultragoal leader id");
|
|
260
|
+
if (leader !== current.actor)
|
|
261
|
+
throw new Error("only the canonical goal leader may checkpoint Ultragoal");
|
|
262
|
+
if (current.state !== "active")
|
|
263
|
+
throw new Error(`Ultragoal cannot checkpoint while goal is ${current.state}`);
|
|
264
|
+
requireNewerTimestamp(options.checkpointedAt, current.payload.updated_at, "Ultragoal checkpointed_at");
|
|
265
|
+
if (!current.payload.native_snapshot
|
|
266
|
+
|| !current.payload.team_checkpoint
|
|
267
|
+
|| !sameReference(options.nativeSnapshot, current.payload.native_snapshot)
|
|
268
|
+
|| !sameReference(options.teamCheckpoint, current.payload.team_checkpoint)) {
|
|
269
|
+
const sources = [];
|
|
270
|
+
if (current.payload.native_snapshot)
|
|
271
|
+
sources.push(current.payload.native_snapshot);
|
|
272
|
+
if (current.payload.team_checkpoint)
|
|
273
|
+
sources.push(current.payload.team_checkpoint);
|
|
274
|
+
return parkWithRegression(internals, current, {
|
|
275
|
+
reason: "ultragoal-mismatch",
|
|
276
|
+
requestedAt: options.checkpointedAt,
|
|
277
|
+
sources,
|
|
278
|
+
predicate: null,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
const native = internals.artifacts.read(current.payload.native_snapshot);
|
|
282
|
+
const team = internals.artifacts.read(current.payload.team_checkpoint);
|
|
283
|
+
const nativeCapturedAt = timestampEpoch(String(native.payload.captured_at), "native snapshot captured_at");
|
|
284
|
+
const deliveryCompletedAt = timestampEpoch(String(team.payload.delivery_wave.completed_at), "Team delivery completed_at");
|
|
285
|
+
const invalid = native.artifact_kind !== "native-goal-snapshot"
|
|
286
|
+
|| team.artifact_kind !== "team-checkpoint"
|
|
287
|
+
|| native.payload.status !== "complete"
|
|
288
|
+
|| native.payload.terminal !== true
|
|
289
|
+
|| native.payload.native_goal_id !== current.record_id
|
|
290
|
+
|| native.payload.objective !== current.payload.objective
|
|
291
|
+
|| native.payload.stopping_condition !== current.payload.stopping_condition
|
|
292
|
+
|| nativeCapturedAt <= deliveryCompletedAt;
|
|
293
|
+
if (invalid) {
|
|
294
|
+
return parkWithRegression(internals, current, {
|
|
295
|
+
reason: "ultragoal-mismatch",
|
|
296
|
+
requestedAt: options.checkpointedAt,
|
|
297
|
+
sources: [current.payload.native_snapshot, current.payload.team_checkpoint],
|
|
298
|
+
predicate: null,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
const artifact = writeUltragoalArtifact(internals.artifacts, current, options);
|
|
302
|
+
const result = transitionGoal(internals, current, "completed", createStableId("goal-complete", current.record_id, artifact.ref.artifact_id), {
|
|
303
|
+
...current.payload,
|
|
304
|
+
updated_at: options.checkpointedAt,
|
|
305
|
+
ultragoal_checkpoint: artifact.ref,
|
|
306
|
+
regression_request: null,
|
|
307
|
+
park_reason: null,
|
|
308
|
+
});
|
|
309
|
+
return Object.freeze({ status: "completed", goal: freezeGoal(result), artifact: artifact.ref });
|
|
310
|
+
}
|
|
311
|
+
function writeNativeSnapshot(artifacts, goal, snapshot) {
|
|
312
|
+
const artifactId = createStableId("native-goal", goal.record_id, String(snapshot.snapshot_version), snapshot.captured_at);
|
|
313
|
+
return artifacts.write({
|
|
314
|
+
schema_version: 1,
|
|
315
|
+
artifact_id: artifactId,
|
|
316
|
+
artifact_kind: "native-goal-snapshot",
|
|
317
|
+
goal_id: goal.record_id,
|
|
318
|
+
producer: "codex-get-goal",
|
|
319
|
+
created_at: snapshot.captured_at,
|
|
320
|
+
payload: snapshot,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function writeTeamArtifact(artifacts, goalId, projection) {
|
|
324
|
+
const artifactId = createStableId("team-check", goalId, projection.delivery_wave.wave_id, projection.test_sha256);
|
|
325
|
+
return artifacts.write({
|
|
326
|
+
schema_version: 1,
|
|
327
|
+
artifact_id: artifactId,
|
|
328
|
+
artifact_kind: "team-checkpoint",
|
|
329
|
+
goal_id: goalId,
|
|
330
|
+
producer: "oms-team-projection",
|
|
331
|
+
created_at: projection.delivery_wave.completed_at,
|
|
332
|
+
payload: projection,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function writeUltragoalArtifact(artifacts, goal, options) {
|
|
336
|
+
const artifactId = createStableId("ultragoal", goal.record_id, options.nativeSnapshot.sha256, options.teamCheckpoint.sha256);
|
|
337
|
+
return artifacts.write({
|
|
338
|
+
schema_version: 1,
|
|
339
|
+
artifact_id: artifactId,
|
|
340
|
+
artifact_kind: "ultragoal-checkpoint",
|
|
341
|
+
goal_id: goal.record_id,
|
|
342
|
+
producer: "oms-ultragoal-leader",
|
|
343
|
+
created_at: options.checkpointedAt,
|
|
344
|
+
payload: {
|
|
345
|
+
schema_version: 1,
|
|
346
|
+
goal_id: goal.record_id,
|
|
347
|
+
leader_id: options.leaderId,
|
|
348
|
+
checkpointed_at: options.checkpointedAt,
|
|
349
|
+
native_snapshot: options.nativeSnapshot,
|
|
350
|
+
team_checkpoint: options.teamCheckpoint,
|
|
351
|
+
objective_sha256: sha256(goal.payload.objective),
|
|
352
|
+
stopping_condition_sha256: sha256(goal.payload.stopping_condition),
|
|
353
|
+
terminal: true,
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
function parkWithRegression(internals, current, input) {
|
|
358
|
+
requireNewerTimestamp(input.requestedAt, current.payload.updated_at, "regression requested_at");
|
|
359
|
+
const sourceArtifacts = [...input.sources].sort(compareReferences);
|
|
360
|
+
const artifactId = createStableId("regression", current.record_id, input.reason, input.requestedAt, JSON.stringify(sourceArtifacts), JSON.stringify(input.predicate));
|
|
361
|
+
const regression = internals.artifacts.write({
|
|
362
|
+
schema_version: 1,
|
|
363
|
+
artifact_id: artifactId,
|
|
364
|
+
artifact_kind: "regression-request",
|
|
365
|
+
goal_id: current.record_id,
|
|
366
|
+
producer: "oms-goal-authority",
|
|
367
|
+
created_at: input.requestedAt,
|
|
368
|
+
payload: {
|
|
369
|
+
schema_version: 1,
|
|
370
|
+
goal_id: current.record_id,
|
|
371
|
+
reason: input.reason,
|
|
372
|
+
objective: current.payload.objective,
|
|
373
|
+
stopping_condition: current.payload.stopping_condition,
|
|
374
|
+
requested_at: input.requestedAt,
|
|
375
|
+
source_artifacts: sourceArtifacts,
|
|
376
|
+
predicate: input.predicate,
|
|
377
|
+
disposition: "queue-request-only",
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
const goal = transitionGoal(internals, current, "parked", createStableId("goal-park", current.record_id, regression.ref.artifact_id), {
|
|
381
|
+
...current.payload,
|
|
382
|
+
updated_at: input.requestedAt,
|
|
383
|
+
regression_request: regression.ref,
|
|
384
|
+
park_reason: input.reason,
|
|
385
|
+
});
|
|
386
|
+
return Object.freeze({ status: "parked", goal: freezeGoal(goal), regression: regression.ref });
|
|
387
|
+
}
|
|
388
|
+
function transitionGoal(internals, current, toState, nonce, payload) {
|
|
389
|
+
return internals.store.transition({
|
|
390
|
+
recordId: current.record_id,
|
|
391
|
+
ownerId: current.actor,
|
|
392
|
+
expectedVersion: current.version,
|
|
393
|
+
nonce,
|
|
394
|
+
expectedActor: current.actor,
|
|
395
|
+
expectedAttempt: 1,
|
|
396
|
+
expectedLeaseToken: null,
|
|
397
|
+
fromStates: [current.state],
|
|
398
|
+
toState,
|
|
399
|
+
updatePayload: () => payload,
|
|
400
|
+
}).record;
|
|
401
|
+
}
|
|
402
|
+
function validateGoalRecord(raw, payloadSchema, artifacts) {
|
|
403
|
+
if (raw.record_kind !== "oms-goal")
|
|
404
|
+
throw new Error("goal authority accepts only oms-goal records");
|
|
405
|
+
if (raw.attempt !== 1 || raw.max_attempts !== 1 || raw.lease_token !== null) {
|
|
406
|
+
throw new Error("goal lifecycle does not use ticket attempts or leases");
|
|
407
|
+
}
|
|
408
|
+
assertSchema(raw.payload, payloadSchema, "canonical goal payload");
|
|
409
|
+
const record = raw;
|
|
410
|
+
if (record.payload.goal_id !== record.record_id)
|
|
411
|
+
throw new Error("goal payload id mismatch");
|
|
412
|
+
assertText(record.payload.objective, "goal objective");
|
|
413
|
+
assertText(record.payload.repository_scope, "goal repository scope");
|
|
414
|
+
assertText(record.payload.queue_scope, "goal queue scope");
|
|
415
|
+
assertText(record.payload.stopping_condition, "goal stopping condition");
|
|
416
|
+
assertRuntimeHorizon(record.payload.runtime_horizon);
|
|
417
|
+
assertBudgetProfile(record.payload.budget_profile);
|
|
418
|
+
assertPolicyProfile(record.payload.policy_profile);
|
|
419
|
+
assertTransitionNonce(record.payload.creation_nonce, "goal creation nonce");
|
|
420
|
+
if (record.record_id !== goalIdentity({
|
|
421
|
+
objective: record.payload.objective,
|
|
422
|
+
repositoryScope: record.payload.repository_scope,
|
|
423
|
+
queueScope: record.payload.queue_scope,
|
|
424
|
+
stoppingCondition: record.payload.stopping_condition,
|
|
425
|
+
runtimeHorizon: record.payload.runtime_horizon,
|
|
426
|
+
budgetProfile: record.payload.budget_profile,
|
|
427
|
+
policyProfile: record.payload.policy_profile,
|
|
428
|
+
creationNonce: record.payload.creation_nonce,
|
|
429
|
+
})) {
|
|
430
|
+
throw new Error("canonical goal objective and stopping condition, scope, profiles, and nonce do not match goal identity");
|
|
431
|
+
}
|
|
432
|
+
const createdAt = timestampEpoch(record.payload.created_at, "goal created_at");
|
|
433
|
+
const updatedAt = timestampEpoch(record.payload.updated_at, "goal updated_at");
|
|
434
|
+
if (updatedAt < createdAt)
|
|
435
|
+
throw new Error("goal updated_at predates creation");
|
|
436
|
+
if (!["active", "parked", "completed"].includes(record.state))
|
|
437
|
+
throw new Error("invalid goal state");
|
|
438
|
+
const native = validateGoalArtifact(record.payload.native_snapshot, "native-goal-snapshot", record.record_id, artifacts);
|
|
439
|
+
const team = validateGoalArtifact(record.payload.team_checkpoint, "team-checkpoint", record.record_id, artifacts);
|
|
440
|
+
const ultragoal = validateGoalArtifact(record.payload.ultragoal_checkpoint, "ultragoal-checkpoint", record.record_id, artifacts);
|
|
441
|
+
const regression = validateGoalArtifact(record.payload.regression_request, "regression-request", record.record_id, artifacts);
|
|
442
|
+
if (record.state !== "parked" && native && (native.payload.native_goal_id !== record.record_id
|
|
443
|
+
|| native.payload.objective !== record.payload.objective
|
|
444
|
+
|| native.payload.stopping_condition !== record.payload.stopping_condition)) {
|
|
445
|
+
throw new Error("active goal native snapshot does not match canonical identity");
|
|
446
|
+
}
|
|
447
|
+
if (team && team.payload.goal_id !== record.record_id)
|
|
448
|
+
throw new Error("goal Team checkpoint identity mismatch");
|
|
449
|
+
if (regression && (regression.payload.objective !== record.payload.objective
|
|
450
|
+
|| regression.payload.stopping_condition !== record.payload.stopping_condition)) {
|
|
451
|
+
throw new Error("goal regression request changed canonical objective");
|
|
452
|
+
}
|
|
453
|
+
if (record.state === "active" && (record.payload.park_reason !== null || regression !== undefined || record.payload.ultragoal_checkpoint !== null)) {
|
|
454
|
+
throw new Error("active goal contains terminal or regression authority");
|
|
455
|
+
}
|
|
456
|
+
if (record.state === "parked") {
|
|
457
|
+
if (!record.payload.park_reason || !regression)
|
|
458
|
+
throw new Error("parked goal requires a typed regression request");
|
|
459
|
+
if (regression.payload.reason !== record.payload.park_reason)
|
|
460
|
+
throw new Error("parked goal reason does not match regression request");
|
|
461
|
+
}
|
|
462
|
+
if (record.state === "completed") {
|
|
463
|
+
if (!record.payload.ultragoal_checkpoint || !ultragoal || !record.payload.native_snapshot || !record.payload.team_checkpoint
|
|
464
|
+
|| record.payload.park_reason !== null || regression !== undefined) {
|
|
465
|
+
throw new Error("completed goal requires only terminal Ultragoal authority");
|
|
466
|
+
}
|
|
467
|
+
if (!sameReference(ultragoal.payload.native_snapshot, record.payload.native_snapshot)
|
|
468
|
+
|| !sameReference(ultragoal.payload.team_checkpoint, record.payload.team_checkpoint)
|
|
469
|
+
|| ultragoal.payload.leader_id !== record.actor
|
|
470
|
+
|| ultragoal.payload.objective_sha256 !== sha256(record.payload.objective)
|
|
471
|
+
|| ultragoal.payload.stopping_condition_sha256 !== sha256(record.payload.stopping_condition)) {
|
|
472
|
+
throw new Error("completed goal Ultragoal checkpoint does not bind canonical authority");
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function validateGoalTransition(currentRaw, nextRaw) {
|
|
477
|
+
const current = currentRaw;
|
|
478
|
+
const next = nextRaw;
|
|
479
|
+
if (next.record_id !== current.record_id
|
|
480
|
+
|| next.record_kind !== current.record_kind
|
|
481
|
+
|| next.actor !== current.actor
|
|
482
|
+
|| next.payload.goal_id !== current.payload.goal_id
|
|
483
|
+
|| next.payload.objective !== current.payload.objective
|
|
484
|
+
|| next.payload.repository_scope !== current.payload.repository_scope
|
|
485
|
+
|| next.payload.queue_scope !== current.payload.queue_scope
|
|
486
|
+
|| next.payload.stopping_condition !== current.payload.stopping_condition
|
|
487
|
+
|| next.payload.runtime_horizon !== current.payload.runtime_horizon
|
|
488
|
+
|| next.payload.budget_profile !== current.payload.budget_profile
|
|
489
|
+
|| next.payload.policy_profile !== current.payload.policy_profile
|
|
490
|
+
|| next.payload.creation_nonce !== current.payload.creation_nonce
|
|
491
|
+
|| next.payload.created_at !== current.payload.created_at) {
|
|
492
|
+
throw new Error("canonical goal identity, objective, and stopping condition are immutable");
|
|
493
|
+
}
|
|
494
|
+
if (timestampEpoch(next.payload.updated_at, "next goal updated_at") < timestampEpoch(current.payload.updated_at, "goal updated_at")) {
|
|
495
|
+
throw new Error("goal updated_at cannot move backwards");
|
|
496
|
+
}
|
|
497
|
+
const allowed = {
|
|
498
|
+
active: ["active", "parked", "completed"],
|
|
499
|
+
parked: ["parked"],
|
|
500
|
+
completed: ["completed", "parked"],
|
|
501
|
+
};
|
|
502
|
+
if (!allowed[current.state].includes(next.state))
|
|
503
|
+
throw new Error(`illegal goal transition ${current.state} -> ${next.state}`);
|
|
504
|
+
}
|
|
505
|
+
function validateGoalArtifact(reference, kind, goalId, artifacts) {
|
|
506
|
+
if (reference === null)
|
|
507
|
+
return undefined;
|
|
508
|
+
if (reference.kind !== kind)
|
|
509
|
+
throw new Error(`goal artifact must be ${kind}`);
|
|
510
|
+
const artifact = artifacts.read(reference);
|
|
511
|
+
if (artifact.goal_id !== goalId || artifact.artifact_kind !== kind)
|
|
512
|
+
throw new Error("goal artifact authority mismatch");
|
|
513
|
+
return artifact;
|
|
514
|
+
}
|
|
515
|
+
function readMutableGoal(internals, goalId) {
|
|
516
|
+
return internals.store.read(assertRecordId(goalId, "goal id"));
|
|
517
|
+
}
|
|
518
|
+
function goalPlanBinding(internals, goal) {
|
|
519
|
+
return {
|
|
520
|
+
goal_id: goal.record_id,
|
|
521
|
+
goal_version: goal.version,
|
|
522
|
+
goal_state: "active",
|
|
523
|
+
objective_sha256: sha256(goal.payload.objective),
|
|
524
|
+
stopping_condition_sha256: sha256(goal.payload.stopping_condition),
|
|
525
|
+
goal_record_path: join(internals.recordsRoot, recordFileName(goal.record_id)),
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function sameGoalPlanBinding(left, right) {
|
|
529
|
+
return left.goal_id === right.goal_id
|
|
530
|
+
&& left.goal_version === right.goal_version
|
|
531
|
+
&& left.goal_state === right.goal_state
|
|
532
|
+
&& left.objective_sha256 === right.objective_sha256
|
|
533
|
+
&& left.stopping_condition_sha256 === right.stopping_condition_sha256
|
|
534
|
+
&& left.goal_record_path === right.goal_record_path;
|
|
535
|
+
}
|
|
536
|
+
function internalsFor(authority) {
|
|
537
|
+
assertGoalAuthority(authority);
|
|
538
|
+
const internals = GOAL_AUTHORITIES.get(authority);
|
|
539
|
+
if (!internals)
|
|
540
|
+
throw new Error("goal authority internals are unavailable");
|
|
541
|
+
return internals;
|
|
542
|
+
}
|
|
543
|
+
function freezeGoal(record) {
|
|
544
|
+
return deepFreeze(structuredClone(record));
|
|
545
|
+
}
|
|
546
|
+
function sameReference(left, right) {
|
|
547
|
+
return left.kind === right.kind
|
|
548
|
+
&& left.artifact_id === right.artifact_id
|
|
549
|
+
&& left.sha256 === right.sha256
|
|
550
|
+
&& left.file_name === right.file_name;
|
|
551
|
+
}
|
|
552
|
+
function compareReferences(left, right) {
|
|
553
|
+
return compareText(left.artifact_id, right.artifact_id)
|
|
554
|
+
|| compareText(left.sha256, right.sha256)
|
|
555
|
+
|| compareText(left.file_name, right.file_name);
|
|
556
|
+
}
|
|
557
|
+
function compareText(left, right) {
|
|
558
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
559
|
+
}
|
|
560
|
+
function requireNewerTimestamp(next, current, label) {
|
|
561
|
+
const nextEpoch = timestampEpoch(next, label);
|
|
562
|
+
if (nextEpoch <= timestampEpoch(current, "goal updated_at"))
|
|
563
|
+
throw new Error(`${label} is stale`);
|
|
564
|
+
return nextEpoch;
|
|
565
|
+
}
|
|
566
|
+
function timestampEpoch(value, label) {
|
|
567
|
+
const epoch = Date.parse(value);
|
|
568
|
+
const normalized = value.includes(".") ? value : value.replace("Z", ".000Z");
|
|
569
|
+
if (!Number.isFinite(epoch) || new Date(epoch).toISOString() !== normalized)
|
|
570
|
+
throw new Error(`${label} is invalid`);
|
|
571
|
+
return epoch;
|
|
572
|
+
}
|
|
573
|
+
function assertText(value, label) {
|
|
574
|
+
if (typeof value !== "string" || value.trim().length === 0)
|
|
575
|
+
throw new Error(`${label} must not be blank`);
|
|
576
|
+
return value;
|
|
577
|
+
}
|
|
578
|
+
function assertRuntimeHorizon(value) {
|
|
579
|
+
if (value !== "until-empty" && value !== "12h" && value !== "24h")
|
|
580
|
+
throw new Error("goal runtime horizon is invalid");
|
|
581
|
+
return value;
|
|
582
|
+
}
|
|
583
|
+
function assertBudgetProfile(value) {
|
|
584
|
+
if (value !== "subscription-only")
|
|
585
|
+
throw new Error("goal budget profile is invalid");
|
|
586
|
+
return value;
|
|
587
|
+
}
|
|
588
|
+
function assertPolicyProfile(value) {
|
|
589
|
+
if (value !== "default")
|
|
590
|
+
throw new Error("goal policy profile is invalid");
|
|
591
|
+
return value;
|
|
592
|
+
}
|
|
593
|
+
function goalIdentity(input) {
|
|
594
|
+
return createStableId("goal", input.objective, input.repositoryScope, input.queueScope, input.stoppingCondition, input.runtimeHorizon, input.budgetProfile, input.policyProfile, input.creationNonce);
|
|
595
|
+
}
|
|
596
|
+
function sameGoalCreationPayload(left, right) {
|
|
597
|
+
return left.objective === right.objective
|
|
598
|
+
&& left.repository_scope === right.repository_scope
|
|
599
|
+
&& left.queue_scope === right.queue_scope
|
|
600
|
+
&& left.stopping_condition === right.stopping_condition
|
|
601
|
+
&& left.runtime_horizon === right.runtime_horizon
|
|
602
|
+
&& left.budget_profile === right.budget_profile
|
|
603
|
+
&& left.policy_profile === right.policy_profile
|
|
604
|
+
&& left.creation_nonce === right.creation_nonce;
|
|
605
|
+
}
|
|
606
|
+
function assertSha256(value, label) {
|
|
607
|
+
if (!/^[a-f0-9]{64}$/.test(value))
|
|
608
|
+
throw new Error(`${label} is invalid`);
|
|
609
|
+
return value;
|
|
610
|
+
}
|
|
611
|
+
function sha256(value) {
|
|
612
|
+
return createHash("sha256").update(value, "utf8").digest("hex");
|
|
613
|
+
}
|
|
614
|
+
function deepFreeze(value) {
|
|
615
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value))
|
|
616
|
+
return value;
|
|
617
|
+
for (const child of Object.values(value))
|
|
618
|
+
deepFreeze(child);
|
|
619
|
+
return Object.freeze(value);
|
|
620
|
+
}
|
|
621
|
+
//# sourceMappingURL=authority.js.map
|