agentera 3.0.0-dev.2 → 3.0.0-dev.21
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/README.md +84 -6
- package/bundle/.agentera-npx-bundle.json +1 -1
- package/bundle/.codex-plugin/plugin.json +92 -0
- package/bundle/.cursor/agents/agentera.md +7 -0
- package/bundle/.cursor/hooks.json +32 -0
- package/bundle/.cursor-plugin/plugin.json +34 -0
- package/bundle/.github/hooks/postToolUse.json +9 -0
- package/bundle/.github/hooks/preToolUse.json +8 -0
- package/bundle/.github/hooks/sessionEnd.json +8 -0
- package/bundle/.github/hooks/sessionStart.json +8 -0
- package/bundle/.github/plugin/plugin.json +7 -0
- package/bundle/.opencode/agents/agentera.md +12 -0
- package/bundle/.opencode/commands/agentera.md +5 -0
- package/bundle/.opencode/package.json +31 -0
- package/bundle/.opencode/plugins/agentera.js +820 -0
- package/bundle/CHANGELOG.md +1101 -0
- package/bundle/DESIGN.md +233 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +158 -0
- package/bundle/UPGRADE.md +265 -0
- package/bundle/agents/openai.yaml +87 -0
- package/bundle/extract-corpus-parity.json +21 -0
- package/bundle/hooks/codex-hooks.json +31 -0
- package/bundle/hooks/codex-plugin-hooks.json +31 -0
- package/bundle/plugin.json +13 -0
- package/bundle/references/adapters/cursor.md +53 -42
- package/bundle/references/adapters/opencode.md +46 -47
- package/bundle/references/adapters/package-manifest-interface-model.yaml +32 -43
- package/bundle/references/adapters/package-registry.yaml +19 -53
- package/bundle/references/adapters/package-surface-characterization.md +55 -35
- package/bundle/references/adapters/runtime-adapter-characterization.md +44 -79
- package/bundle/references/adapters/runtime-adapter-registry.yaml +21 -182
- package/bundle/references/adapters/runtime-feature-parity.md +114 -174
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +288 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +90 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +33 -0
- package/bundle/references/analysis/benchmark.md +6 -6
- package/bundle/references/analysis/startup-measurement-contract.yaml +37 -26
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +9 -8
- package/bundle/references/artifacts/state-storage-authority.yaml +1446 -0
- package/bundle/references/cli/agent-ready-state-contract.yaml +37 -62
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +4 -4
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +57 -28
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +4 -32
- package/bundle/references/cli/capability-instruction-contract.yaml +98 -57
- package/bundle/references/cli/capability-instruction-structure.md +144 -0
- package/bundle/references/cli/capability-tool-classification.yaml +12 -12
- package/bundle/references/cli/coexistence-probe.yaml +13 -0
- package/bundle/references/cli/parity-expected-actual-template.md +30 -0
- package/bundle/references/cli/routing-execution-vocabulary.yaml +12 -12
- package/bundle/references/cli/routing-model.md +94 -0
- package/bundle/references/cli/single-name-protocol.yaml +42 -0
- package/bundle/references/cli/trigger-schema-enrichment.md +136 -0
- package/bundle/references/cli/update-channels.yaml +43 -7
- package/bundle/references/cli/upgrade-repair-wording.md +45 -0
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +98 -0
- package/bundle/references/cli/vocabulary-index.yaml +20 -15
- package/bundle/references/cli/vocabulary.md +342 -326
- package/bundle/references/meta/documentation-inventory.md +10 -3
- package/bundle/registry.json +14 -14
- package/bundle/skills/agentera/SKILL.md +136 -408
- package/bundle/skills/agentera/agents/audit.toml +6 -0
- package/bundle/skills/agentera/agents/build.toml +6 -0
- package/bundle/skills/agentera/agents/design.toml +6 -0
- package/bundle/skills/agentera/agents/discuss.toml +6 -0
- package/bundle/skills/agentera/agents/document.toml +6 -0
- package/bundle/skills/agentera/agents/optimize.toml +6 -0
- package/bundle/skills/agentera/agents/orchestrate.toml +6 -0
- package/bundle/skills/agentera/agents/plan.toml +6 -0
- package/bundle/skills/agentera/agents/profile.toml +6 -0
- package/bundle/skills/agentera/agents/research.toml +6 -0
- package/bundle/skills/agentera/agents/status.toml +6 -0
- package/bundle/skills/agentera/agents/vision.toml +6 -0
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +84 -0
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/triggers.yaml +15 -6
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +20 -19
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/artifacts.yaml +22 -17
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/triggers.yaml +13 -3
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/validation.yaml +11 -11
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/triggers.yaml +15 -3
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/validation.yaml +7 -7
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +49 -0
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/triggers.yaml +11 -3
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/validation.yaml +9 -8
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/artifacts.yaml +23 -16
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/triggers.yaml +14 -4
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +18 -18
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +9 -9
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/triggers.yaml +11 -3
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +71 -0
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/triggers.yaml +16 -3
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +120 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +63 -0
- package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/triggers.yaml +15 -3
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +89 -0
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/artifacts.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/triggers.yaml +7 -3
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/triggers.yaml +9 -3
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/artifacts.yaml +14 -11
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/triggers.yaml +12 -8
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +8 -8
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/triggers.yaml +19 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
- package/bundle/skills/agentera/capability_schema_contract.yaml +201 -38
- package/bundle/skills/agentera/protocol.yaml +29 -29
- package/bundle/skills/agentera/references/contract.md +387 -329
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +4 -4
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +25 -20
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +4 -4
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +8 -7
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +139 -8
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +21 -15
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +22 -8
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +285 -11
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +36 -51
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +77 -24
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
- package/dist/analytics/extractCorpus/cli.js +163 -0
- package/dist/analytics/extractCorpus/cli.js.map +1 -0
- package/dist/analytics/extractCorpus/copilotSessions.js +276 -0
- package/dist/analytics/extractCorpus/copilotSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/core.js +393 -0
- package/dist/analytics/extractCorpus/core.js.map +1 -0
- package/dist/analytics/extractCorpus/corpus.js +168 -0
- package/dist/analytics/extractCorpus/corpus.js.map +1 -0
- package/dist/analytics/extractCorpus/coverageAudit.js +261 -0
- package/dist/analytics/extractCorpus/coverageAudit.js.map +1 -0
- package/dist/analytics/extractCorpus/cursorSessions.js +426 -0
- package/dist/analytics/extractCorpus/cursorSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +105 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js.map +1 -0
- package/dist/analytics/extractCorpus/filesystemSources.js +119 -0
- package/dist/analytics/extractCorpus/filesystemSources.js.map +1 -0
- package/dist/analytics/extractCorpus/index.js +12 -0
- package/dist/analytics/extractCorpus/index.js.map +1 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js +205 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/sqliteCaps.js +44 -0
- package/dist/analytics/extractCorpus/sqliteCaps.js.map +1 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js +368 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +1 -0
- package/dist/analytics/extractCorpus.js +2 -1790
- package/dist/analytics/extractCorpus.js.map +1 -1
- package/dist/analytics/usageStats.js +93 -27
- package/dist/analytics/usageStats.js.map +1 -1
- package/dist/bin/agentera.js +3 -1
- package/dist/bin/agentera.js.map +1 -1
- package/dist/capabilities/audit/instructions.js +4 -0
- package/dist/capabilities/audit/instructions.js.map +1 -0
- package/dist/capabilities/build/instructions.js +5 -0
- package/dist/capabilities/build/instructions.js.map +1 -0
- package/dist/capabilities/design/instructions.js +5 -0
- package/dist/capabilities/design/instructions.js.map +1 -0
- package/dist/capabilities/discuss/instructions.js +6 -0
- package/dist/capabilities/discuss/instructions.js.map +1 -0
- package/dist/capabilities/document/instructions.js +4 -0
- package/dist/capabilities/document/instructions.js.map +1 -0
- package/dist/capabilities/index.js +38 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/optimize/instructions.js +5 -0
- package/dist/capabilities/optimize/instructions.js.map +1 -0
- package/dist/capabilities/orchestrate/instructions.js +10 -0
- package/dist/capabilities/orchestrate/instructions.js.map +1 -0
- package/dist/capabilities/plan/instructions.js +6 -0
- package/dist/capabilities/plan/instructions.js.map +1 -0
- package/dist/capabilities/profile/instructions.js +5 -0
- package/dist/capabilities/profile/instructions.js.map +1 -0
- package/dist/capabilities/research/instructions.js +6 -0
- package/dist/capabilities/research/instructions.js.map +1 -0
- package/dist/capabilities/status/instructions.js +5 -0
- package/dist/capabilities/status/instructions.js.map +1 -0
- package/dist/capabilities/vision/instructions.js +5 -0
- package/dist/capabilities/vision/instructions.js.map +1 -0
- package/dist/cli/appContext.js +30 -23
- package/dist/cli/appContext.js.map +1 -1
- package/dist/cli/capabilityContext/benchmark.js +564 -0
- package/dist/cli/capabilityContext/benchmark.js.map +1 -0
- package/dist/cli/capabilityContext/bespoke.js +38 -0
- package/dist/cli/capabilityContext/bespoke.js.map +1 -0
- package/dist/cli/capabilityContext/build.js +191 -0
- package/dist/cli/capabilityContext/build.js.map +1 -0
- package/dist/cli/capabilityContext/closeout.js +231 -0
- package/dist/cli/capabilityContext/closeout.js.map +1 -0
- package/dist/cli/capabilityContext/contract.js +219 -0
- package/dist/cli/capabilityContext/contract.js.map +1 -0
- package/dist/cli/capabilityContext/evidence.js +457 -0
- package/dist/cli/capabilityContext/evidence.js.map +1 -0
- package/dist/cli/capabilityContext/index.js +4 -0
- package/dist/cli/capabilityContext/index.js.map +1 -0
- package/dist/cli/capabilityContext/orchestration.js +118 -0
- package/dist/cli/capabilityContext/orchestration.js.map +1 -0
- package/dist/cli/capabilityContext/planState.js +279 -0
- package/dist/cli/capabilityContext/planState.js.map +1 -0
- package/dist/cli/capabilityContext/progress.js +143 -0
- package/dist/cli/capabilityContext/progress.js.map +1 -0
- package/dist/cli/capabilityContext/shared.js +94 -0
- package/dist/cli/capabilityContext/shared.js.map +1 -0
- package/dist/cli/capabilityContext/slim.js +139 -0
- package/dist/cli/capabilityContext/slim.js.map +1 -0
- package/dist/cli/capabilityContext/startup.js +241 -0
- package/dist/cli/capabilityContext/startup.js.map +1 -0
- package/dist/cli/capabilityContext/types.js +51 -0
- package/dist/cli/capabilityContext/types.js.map +1 -0
- package/dist/cli/capabilityContext.js +1 -2420
- package/dist/cli/capabilityContext.js.map +1 -1
- package/dist/cli/commands/appHome.js +23 -0
- package/dist/cli/commands/appHome.js.map +1 -0
- package/dist/cli/commands/backfill.js +186 -76
- package/dist/cli/commands/backfill.js.map +1 -1
- package/dist/cli/commands/capability.js +3 -10
- package/dist/cli/commands/capability.js.map +1 -1
- package/dist/cli/commands/compact.js +41 -12
- package/dist/cli/commands/compact.js.map +1 -1
- package/dist/cli/commands/doctor.js +116 -96
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/durability.js +85 -0
- package/dist/cli/commands/durability.js.map +1 -0
- package/dist/cli/commands/lint.js +16 -41
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/migrate.js +677 -0
- package/dist/cli/commands/migrate.js.map +1 -0
- package/dist/cli/commands/prime/bundleStatus.js +185 -0
- package/dist/cli/commands/prime/bundleStatus.js.map +1 -0
- package/dist/cli/commands/prime/collectOrientationState.js +202 -0
- package/dist/cli/commands/prime/collectOrientationState.js.map +1 -0
- package/dist/cli/commands/prime/orientationOutput.js +235 -0
- package/dist/cli/commands/prime/orientationOutput.js.map +1 -0
- package/dist/cli/commands/prime/types.js +2 -0
- package/dist/cli/commands/prime/types.js.map +1 -0
- package/dist/cli/commands/prime/v1Migration.js +39 -0
- package/dist/cli/commands/prime/v1Migration.js.map +1 -0
- package/dist/cli/commands/prime.js +11 -519
- package/dist/cli/commands/prime.js.map +1 -1
- package/dist/cli/commands/query.js +25 -4
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/report.js +50 -14
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/schema.js +343 -76
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/state/decisions.js +421 -0
- package/dist/cli/commands/state/decisions.js.map +1 -0
- package/dist/cli/commands/state/docs.js +97 -0
- package/dist/cli/commands/state/docs.js.map +1 -0
- package/dist/cli/commands/state/experimentRecords.js +156 -0
- package/dist/cli/commands/state/experimentRecords.js.map +1 -0
- package/dist/cli/commands/state/experiments.js +68 -0
- package/dist/cli/commands/state/experiments.js.map +1 -0
- package/dist/cli/commands/state/get.js +141 -0
- package/dist/cli/commands/state/get.js.map +1 -0
- package/dist/cli/commands/state/health.js +116 -0
- package/dist/cli/commands/state/health.js.map +1 -0
- package/dist/cli/commands/state/index.js +51 -0
- package/dist/cli/commands/state/index.js.map +1 -0
- package/dist/cli/commands/state/list.js +159 -0
- package/dist/cli/commands/state/list.js.map +1 -0
- package/dist/cli/commands/state/objective.js +69 -0
- package/dist/cli/commands/state/objective.js.map +1 -0
- package/dist/cli/commands/state/plan.js +379 -0
- package/dist/cli/commands/state/plan.js.map +1 -0
- package/dist/cli/commands/state/planTasks.js +164 -0
- package/dist/cli/commands/state/planTasks.js.map +1 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/plans.js.map +1 -0
- package/dist/cli/commands/state/progress.js +47 -0
- package/dist/cli/commands/state/progress.js.map +1 -0
- package/dist/cli/commands/state/shared.js +15 -0
- package/dist/cli/commands/state/shared.js.map +1 -0
- package/dist/cli/commands/state/todo.js +121 -0
- package/dist/cli/commands/state/todo.js.map +1 -0
- package/dist/cli/commands/state/write.js +346 -0
- package/dist/cli/commands/state/write.js.map +1 -0
- package/dist/cli/commands/upgrade.js +79 -1
- package/dist/cli/commands/upgrade.js.map +1 -1
- package/dist/cli/commands/upgradeVerify.js +81 -0
- package/dist/cli/commands/upgradeVerify.js.map +1 -0
- package/dist/cli/commands/validate.js +56 -96
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/commands/verify.js +13 -7
- package/dist/cli/commands/verify.js.map +1 -1
- package/dist/cli/contracts/bundleStatus.js +2 -0
- package/dist/cli/contracts/bundleStatus.js.map +1 -0
- package/dist/cli/contracts/orientationState.js +2 -0
- package/dist/cli/contracts/orientationState.js.map +1 -0
- package/dist/cli/dispatch/argvParser.js +33 -0
- package/dist/cli/dispatch/argvParser.js.map +1 -0
- package/dist/cli/dispatch/check.js +395 -0
- package/dist/cli/dispatch/check.js.map +1 -0
- package/dist/cli/dispatch/commands.js +27 -0
- package/dist/cli/dispatch/commands.js.map +1 -0
- package/dist/cli/dispatch/index.js +201 -0
- package/dist/cli/dispatch/index.js.map +1 -0
- package/dist/cli/dispatch/lifecycle.js +671 -0
- package/dist/cli/dispatch/lifecycle.js.map +1 -0
- package/dist/cli/dispatch/prime.js +104 -0
- package/dist/cli/dispatch/prime.js.map +1 -0
- package/dist/cli/dispatch/shared.js +64 -0
- package/dist/cli/dispatch/shared.js.map +1 -0
- package/dist/cli/dispatch/state.js +168 -0
- package/dist/cli/dispatch/state.js.map +1 -0
- package/dist/cli/dispatch.js +1 -957
- package/dist/cli/dispatch.js.map +1 -1
- package/dist/cli/errors.js +53 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/help.js +421 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/orientation/attention.js +163 -0
- package/dist/cli/orientation/attention.js.map +1 -0
- package/dist/cli/orientation/corpusCoverage.js +71 -0
- package/dist/cli/orientation/corpusCoverage.js.map +1 -0
- package/dist/cli/orientation.js +336 -144
- package/dist/cli/orientation.js.map +1 -1
- package/dist/cli/planArtifacts.js +201 -0
- package/dist/cli/planArtifacts.js.map +1 -0
- package/dist/cli/planEvidence.js +158 -0
- package/dist/cli/planEvidence.js.map +1 -0
- package/dist/cli/planLifecycleState.js +34 -0
- package/dist/cli/planLifecycleState.js.map +1 -0
- package/dist/cli/prime-blob.js +69 -2
- package/dist/cli/prime-blob.js.map +1 -1
- package/dist/cli/startupCompletenessContract.js +57 -0
- package/dist/cli/startupCompletenessContract.js.map +1 -0
- package/dist/cli/stateQuery.js +22 -5
- package/dist/cli/stateQuery.js.map +1 -1
- package/dist/cli/todoMarkdown.js +33 -0
- package/dist/cli/todoMarkdown.js.map +1 -0
- package/dist/cli/todoSeverity.js +19 -0
- package/dist/cli/todoSeverity.js.map +1 -0
- package/dist/core/atomicWriter.js +21 -0
- package/dist/core/atomicWriter.js.map +1 -0
- package/dist/core/envPaths.js +21 -0
- package/dist/core/envPaths.js.map +1 -0
- package/dist/core/jsonValue.js +6 -0
- package/dist/core/jsonValue.js.map +1 -0
- package/dist/core/pyjson.js +67 -2
- package/dist/core/pyjson.js.map +1 -1
- package/dist/core/text.js +11 -0
- package/dist/core/text.js.map +1 -0
- package/dist/core/yaml.js +8 -0
- package/dist/core/yaml.js.map +1 -1
- package/dist/eval/evalSkills.js +30 -25
- package/dist/eval/evalSkills.js.map +1 -1
- package/dist/eval/semanticEval.js +43 -19
- package/dist/eval/semanticEval.js.map +1 -1
- package/dist/eval/semanticFixtures.js +16 -4
- package/dist/eval/semanticFixtures.js.map +1 -1
- package/dist/hooks/common.js +9 -26
- package/dist/hooks/common.js.map +1 -1
- package/dist/hooks/compaction/apply.js +447 -0
- package/dist/hooks/compaction/apply.js.map +1 -0
- package/dist/hooks/compaction/dryRun.js +185 -0
- package/dist/hooks/compaction/dryRun.js.map +1 -0
- package/dist/hooks/compaction/index.js +23 -0
- package/dist/hooks/compaction/index.js.map +1 -0
- package/dist/hooks/compaction/parse.js +326 -0
- package/dist/hooks/compaction/parse.js.map +1 -0
- package/dist/hooks/compaction/retention.js +203 -0
- package/dist/hooks/compaction/retention.js.map +1 -0
- package/dist/hooks/compaction/status.js +336 -0
- package/dist/hooks/compaction/status.js.map +1 -0
- package/dist/hooks/compaction/types.js +6 -0
- package/dist/hooks/compaction/types.js.map +1 -0
- package/dist/hooks/cursorPreToolUse.js +1 -1
- package/dist/hooks/cursorPreToolUse.js.map +1 -1
- package/dist/hooks/cursorSessionStart.js +10 -2
- package/dist/hooks/cursorSessionStart.js.map +1 -1
- package/dist/hooks/sessionStart.js +57 -18
- package/dist/hooks/sessionStart.js.map +1 -1
- package/dist/hooks/sessionStop.js +8 -14
- package/dist/hooks/sessionStop.js.map +1 -1
- package/dist/hooks/validateArtifact/agentFacing.js +10 -0
- package/dist/hooks/validateArtifact/agentFacing.js.map +1 -0
- package/dist/hooks/validateArtifact/index.js +151 -0
- package/dist/hooks/validateArtifact/index.js.map +1 -0
- package/dist/hooks/validateArtifact/markdown.js +146 -0
- package/dist/hooks/validateArtifact/markdown.js.map +1 -0
- package/dist/hooks/validateArtifact/runtime.js +86 -0
- package/dist/hooks/validateArtifact/runtime.js.map +1 -0
- package/dist/hooks/validateArtifact/schema.js +541 -0
- package/dist/hooks/validateArtifact/schema.js.map +1 -0
- package/dist/hooks/validateArtifact/traversal.js +108 -0
- package/dist/hooks/validateArtifact/traversal.js.map +1 -0
- package/dist/hooks/validateArtifact/violations.js +108 -0
- package/dist/hooks/validateArtifact/violations.js.map +1 -0
- package/dist/migrate/v2HandoffManifest.js +455 -0
- package/dist/migrate/v2HandoffManifest.js.map +1 -0
- package/dist/registries/artifactProtocolIds.js +77 -0
- package/dist/registries/artifactProtocolIds.js.map +1 -0
- package/dist/registries/artifactRegistry.js +203 -53
- package/dist/registries/artifactRegistry.js.map +1 -1
- package/dist/registries/capabilityContract.js +156 -12
- package/dist/registries/capabilityContract.js.map +1 -1
- package/dist/registries/evaluatorHandoffContract.js +171 -0
- package/dist/registries/evaluatorHandoffContract.js.map +1 -0
- package/dist/registries/packageRegistry.js +40 -6
- package/dist/registries/packageRegistry.js.map +1 -1
- package/dist/registries/runtimeAdapterRegistry.js +30 -21
- package/dist/registries/runtimeAdapterRegistry.js.map +1 -1
- package/dist/registries/triggerLoader.js +211 -0
- package/dist/registries/triggerLoader.js.map +1 -0
- package/dist/release/releaseMetadata.js +329 -0
- package/dist/release/releaseMetadata.js.map +1 -0
- package/dist/runtime/lifecycleAdapterContract.js +458 -0
- package/dist/runtime/lifecycleAdapterContract.js.map +1 -0
- package/dist/runtime/lifecycleAdapters.js +766 -0
- package/dist/runtime/lifecycleAdapters.js.map +1 -0
- package/dist/runtime/lifecycleAuthority.js +493 -0
- package/dist/runtime/lifecycleAuthority.js.map +1 -0
- package/dist/runtime/lifecycleOperationContract.js +113 -0
- package/dist/runtime/lifecycleOperationContract.js.map +1 -0
- package/dist/runtime/lifecycleOperations.js +635 -0
- package/dist/runtime/lifecycleOperations.js.map +1 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +623 -0
- package/dist/runtime/lifecycleOwnershipJournal.js.map +1 -0
- package/dist/runtime/lifecyclePublication.js +395 -0
- package/dist/runtime/lifecyclePublication.js.map +1 -0
- package/dist/runtime/lifecycleSnapshot.js +439 -0
- package/dist/runtime/lifecycleSnapshot.js.map +1 -0
- package/dist/runtime/retiredRuntimeCleanup.js +238 -0
- package/dist/runtime/retiredRuntimeCleanup.js.map +1 -0
- package/dist/setup/codex/agents.js +96 -0
- package/dist/setup/codex/agents.js.map +1 -0
- package/dist/setup/codex/cli.js +161 -0
- package/dist/setup/codex/cli.js.map +1 -0
- package/dist/setup/codex/configToml.js +639 -0
- package/dist/setup/codex/configToml.js.map +1 -0
- package/dist/setup/codex/constants.js +29 -0
- package/dist/setup/codex/constants.js.map +1 -0
- package/dist/setup/codex/installRoot.js +64 -0
- package/dist/setup/codex/installRoot.js.map +1 -0
- package/dist/setup/codex/state.js +270 -0
- package/dist/setup/codex/state.js.map +1 -0
- package/dist/setup/codex.js +11 -1055
- package/dist/setup/codex.js.map +1 -1
- package/dist/setup/copilot.js +1 -1
- package/dist/setup/copilot.js.map +1 -1
- package/dist/setup/cursor.js +7 -5
- package/dist/setup/cursor.js.map +1 -1
- package/dist/setup/cursorSurfaces.js +67 -0
- package/dist/setup/cursorSurfaces.js.map +1 -0
- package/dist/setup/doctor/core.js +296 -0
- package/dist/setup/doctor/core.js.map +1 -0
- package/dist/setup/doctor/diagnostics.js +201 -0
- package/dist/setup/doctor/diagnostics.js.map +1 -0
- package/dist/setup/doctor/opencode.js +301 -0
- package/dist/setup/doctor/opencode.js.map +1 -0
- package/dist/setup/doctor/report.js +425 -0
- package/dist/setup/doctor/report.js.map +1 -0
- package/dist/setup/doctor.js +9 -1275
- package/dist/setup/doctor.js.map +1 -1
- package/dist/setup/opencode.js +13 -0
- package/dist/setup/opencode.js.map +1 -0
- package/dist/setup/opencodeConstants.js +2 -0
- package/dist/setup/opencodeConstants.js.map +1 -0
- package/dist/setup/smokeChecks.js +109 -0
- package/dist/setup/smokeChecks.js.map +1 -0
- package/dist/state/archiveDiscovery.js +589 -0
- package/dist/state/archiveDiscovery.js.map +1 -0
- package/dist/state/archivePublication.js +225 -0
- package/dist/state/archivePublication.js.map +1 -0
- package/dist/state/archiveRecovery.js +238 -0
- package/dist/state/archiveRecovery.js.map +1 -0
- package/dist/state/archiveReplay.js +54 -0
- package/dist/state/archiveReplay.js.map +1 -0
- package/dist/state/decisionOverlay.js +255 -0
- package/dist/state/decisionOverlay.js.map +1 -0
- package/dist/state/directRetrieval.js +322 -0
- package/dist/state/directRetrieval.js.map +1 -0
- package/dist/state/durability.js +451 -0
- package/dist/state/durability.js.map +1 -0
- package/dist/state/experimentArchive.js +64 -0
- package/dist/state/experimentArchive.js.map +1 -0
- package/dist/state/experimentIdentity.js +191 -0
- package/dist/state/experimentIdentity.js.map +1 -0
- package/dist/state/experimentRetrieval.js +447 -0
- package/dist/state/experimentRetrieval.js.map +1 -0
- package/dist/state/gitBackfill.js +561 -0
- package/dist/state/gitBackfill.js.map +1 -0
- package/dist/state/gitBackfillAuthority.js +141 -0
- package/dist/state/gitBackfillAuthority.js.map +1 -0
- package/dist/state/gitBackfillHistory.js +278 -0
- package/dist/state/gitBackfillHistory.js.map +1 -0
- package/dist/state/gitBackfillOutput.js +209 -0
- package/dist/state/gitBackfillOutput.js.map +1 -0
- package/dist/state/healthRepair.js +70 -0
- package/dist/state/healthRepair.js.map +1 -0
- package/dist/state/installRoot.js +64 -24
- package/dist/state/installRoot.js.map +1 -1
- package/dist/state/legacyIdentity.js +48 -0
- package/dist/state/legacyIdentity.js.map +1 -0
- package/dist/state/legacyMigration.js +516 -0
- package/dist/state/legacyMigration.js.map +1 -0
- package/dist/state/legacyMigrationParser.js +489 -0
- package/dist/state/legacyMigrationParser.js.map +1 -0
- package/dist/state/listAccounting.js +55 -0
- package/dist/state/listAccounting.js.map +1 -0
- package/dist/state/listClassification.js +18 -0
- package/dist/state/listClassification.js.map +1 -0
- package/dist/state/listRetrieval.js +782 -0
- package/dist/state/listRetrieval.js.map +1 -0
- package/dist/state/migrationAuthority.js +413 -0
- package/dist/state/migrationAuthority.js.map +1 -0
- package/dist/state/migrationEnrichment.js +35 -0
- package/dist/state/migrationEnrichment.js.map +1 -0
- package/dist/state/planIdentity.js +45 -0
- package/dist/state/planIdentity.js.map +1 -0
- package/dist/state/planRetrieval.js +314 -0
- package/dist/state/planRetrieval.js.map +1 -0
- package/dist/state/planTaskRetrieval.js +285 -0
- package/dist/state/planTaskRetrieval.js.map +1 -0
- package/dist/state/projectionPolicy.js +184 -0
- package/dist/state/projectionPolicy.js.map +1 -0
- package/dist/state/retrievalAuthority.js +326 -0
- package/dist/state/retrievalAuthority.js.map +1 -0
- package/dist/state/startupAnalysis/benchmark.js +371 -0
- package/dist/state/startupAnalysis/benchmark.js.map +1 -0
- package/dist/state/startupAnalysis/contract.js +126 -0
- package/dist/state/startupAnalysis/contract.js.map +1 -0
- package/dist/state/startupAnalysis/helpers.js +287 -0
- package/dist/state/startupAnalysis/helpers.js.map +1 -0
- package/dist/state/startupAnalysis/index.js +7 -0
- package/dist/state/startupAnalysis/index.js.map +1 -0
- package/dist/state/startupAnalysis/metrics.js +341 -0
- package/dist/state/startupAnalysis/metrics.js.map +1 -0
- package/dist/state/startupAnalysis/records.js +199 -0
- package/dist/state/startupAnalysis/records.js.map +1 -0
- package/dist/state/startupAnalysis/report.js +112 -0
- package/dist/state/startupAnalysis/report.js.map +1 -0
- package/dist/state/startupAnalysis/threshold.js +500 -0
- package/dist/state/startupAnalysis/threshold.js.map +1 -0
- package/dist/state/startupAnalysis.js +2 -1952
- package/dist/state/startupAnalysis.js.map +1 -1
- package/dist/state/startupProjection.js +498 -0
- package/dist/state/startupProjection.js.map +1 -0
- package/dist/state/write/assign.js +21 -0
- package/dist/state/write/assign.js.map +1 -0
- package/dist/state/write/errors.js +12 -0
- package/dist/state/write/errors.js.map +1 -0
- package/dist/state/write/experimentPublication.js +193 -0
- package/dist/state/write/experimentPublication.js.map +1 -0
- package/dist/state/write/explain.js +169 -0
- package/dist/state/write/explain.js.map +1 -0
- package/dist/state/write/fields.js +62 -0
- package/dist/state/write/fields.js.map +1 -0
- package/dist/state/write/helpers.js +8 -0
- package/dist/state/write/helpers.js.map +1 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/index.js.map +1 -0
- package/dist/state/write/input.js +22 -0
- package/dist/state/write/input.js.map +1 -0
- package/dist/state/write/lock.js +131 -0
- package/dist/state/write/lock.js.map +1 -0
- package/dist/state/write/mutation.js +190 -0
- package/dist/state/write/mutation.js.map +1 -0
- package/dist/state/write/operations.js +254 -0
- package/dist/state/write/operations.js.map +1 -0
- package/dist/state/write/planPublication.js +172 -0
- package/dist/state/write/planPublication.js.map +1 -0
- package/dist/state/write/serialize.js +2 -0
- package/dist/state/write/serialize.js.map +1 -0
- package/dist/state/write/transaction.js +800 -0
- package/dist/state/write/transaction.js.map +1 -0
- package/dist/state/write/validate.js +8 -0
- package/dist/state/write/validate.js.map +1 -0
- package/dist/upgrade/appContentRefresh.js +374 -0
- package/dist/upgrade/appContentRefresh.js.map +1 -0
- package/dist/upgrade/appModel.js +11 -6
- package/dist/upgrade/appModel.js.map +1 -1
- package/dist/upgrade/atomicWriter.js +2 -0
- package/dist/upgrade/atomicWriter.js.map +1 -0
- package/dist/upgrade/bundleEvidence.js +34 -0
- package/dist/upgrade/bundleEvidence.js.map +1 -0
- package/dist/upgrade/channels.js +27 -7
- package/dist/upgrade/channels.js.map +1 -1
- package/dist/upgrade/coexistenceProbe.js +105 -0
- package/dist/upgrade/coexistenceProbe.js.map +1 -0
- package/dist/upgrade/compatibility.js +52 -16
- package/dist/upgrade/compatibility.js.map +1 -1
- package/dist/upgrade/doctor.js +195 -193
- package/dist/upgrade/doctor.js.map +1 -1
- package/dist/upgrade/doctorClassifier.js +188 -0
- package/dist/upgrade/doctorClassifier.js.map +1 -0
- package/dist/upgrade/installedHooksRetirement.js +190 -0
- package/dist/upgrade/installedHooksRetirement.js.map +1 -0
- package/dist/upgrade/legacyAgentCleanup.js +183 -0
- package/dist/upgrade/legacyAgentCleanup.js.map +1 -0
- package/dist/upgrade/lifecycleUpgrade.js +427 -0
- package/dist/upgrade/lifecycleUpgrade.js.map +1 -0
- package/dist/upgrade/migrateArtifactsV1ToV2.js +568 -0
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +1 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +273 -144
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
- package/dist/upgrade/nextMajorDoctor.js +156 -0
- package/dist/upgrade/nextMajorDoctor.js.map +1 -0
- package/dist/upgrade/npxPlatformStatus.js +23 -0
- package/dist/upgrade/npxPlatformStatus.js.map +1 -0
- package/dist/upgrade/projectIntegration.js +259 -104
- package/dist/upgrade/projectIntegration.js.map +1 -1
- package/dist/upgrade/projectIntegrationDecision.js +141 -0
- package/dist/upgrade/projectIntegrationDecision.js.map +1 -0
- package/dist/upgrade/runtimeMigration.js +342 -89
- package/dist/upgrade/runtimeMigration.js.map +1 -1
- package/dist/upgrade/upgradeCommands.js +8 -0
- package/dist/upgrade/upgradeCommands.js.map +1 -1
- package/dist/upgrade/upgradeLock.js +54 -0
- package/dist/upgrade/upgradeLock.js.map +1 -0
- package/dist/upgrade/upgradeOrchestrator.js +170 -46
- package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
- package/dist/upgrade/upgradeSnapshot.js +93 -0
- package/dist/upgrade/upgradeSnapshot.js.map +1 -0
- package/dist/upgrade/v3CapabilitySurface.js +15 -0
- package/dist/upgrade/v3CapabilitySurface.js.map +1 -0
- package/dist/upgrade/versionResolution.js +12 -4
- package/dist/upgrade/versionResolution.js.map +1 -1
- package/dist/validate/appHomeContract.js +5 -5
- package/dist/validate/appHomeContract.js.map +1 -1
- package/dist/validate/capability.js +135 -14
- package/dist/validate/capability.js.map +1 -1
- package/dist/validate/crossCapability.js +10 -7
- package/dist/validate/crossCapability.js.map +1 -1
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js +93 -0
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +1 -0
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js +481 -0
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +1 -0
- package/dist/validate/lifecycleAdapters/shared.js +198 -0
- package/dist/validate/lifecycleAdapters/shared.js.map +1 -0
- package/dist/validate/lifecycleAdapters.js +91 -702
- package/dist/validate/lifecycleAdapters.js.map +1 -1
- package/dist/validate/selfAudit.js +63 -21
- package/dist/validate/selfAudit.js.map +1 -1
- package/dist/validate/vocabularyAuthority.js +303 -0
- package/dist/validate/vocabularyAuthority.js.map +1 -0
- package/package.json +30 -27
- package/bundle/references/v1-section-mapping.md +0 -47
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/dokumentera.toml +0 -6
- package/bundle/skills/agentera/agents/hej.toml +0 -6
- package/bundle/skills/agentera/agents/inspektera.toml +0 -6
- package/bundle/skills/agentera/agents/inspirera.toml +0 -6
- package/bundle/skills/agentera/agents/optimera.toml +0 -6
- package/bundle/skills/agentera/agents/orkestrera.toml +0 -6
- package/bundle/skills/agentera/agents/planera.toml +0 -6
- package/bundle/skills/agentera/agents/profilera.toml +0 -6
- package/bundle/skills/agentera/agents/realisera.toml +0 -6
- package/bundle/skills/agentera/agents/resonera.toml +0 -6
- package/bundle/skills/agentera/agents/visionera.toml +0 -6
- package/bundle/skills/agentera/agents/visualisera.toml +0 -6
- package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +0 -428
- package/bundle/skills/agentera/capabilities/hej/instructions.md +0 -331
- package/bundle/skills/agentera/capabilities/inspektera/instructions.md +0 -514
- package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +0 -76
- package/bundle/skills/agentera/capabilities/inspirera/instructions.md +0 -280
- package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +0 -24
- package/bundle/skills/agentera/capabilities/optimera/instructions.md +0 -437
- package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +0 -433
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +0 -64
- package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +0 -107
- package/bundle/skills/agentera/capabilities/planera/instructions.md +0 -368
- package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +0 -62
- package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +0 -61
- package/bundle/skills/agentera/capabilities/profilera/instructions.md +0 -419
- package/bundle/skills/agentera/capabilities/realisera/instructions.md +0 -403
- package/bundle/skills/agentera/capabilities/resonera/instructions.md +0 -329
- package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +0 -47
- package/bundle/skills/agentera/capabilities/visionera/instructions.md +0 -309
- package/bundle/skills/agentera/capabilities/visualisera/instructions.md +0 -400
- package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
- package/bundle/skills/hej/SKILL.md +0 -69
- package/bundle/skills/hej/agents/hej.toml +0 -11
- package/bundle/skills/hej/agents/openai.yaml +0 -8
- package/dist/cli/commands/state.js +0 -1012
- package/dist/cli/commands/state.js.map +0 -1
- package/dist/core/git.js +0 -43
- package/dist/core/git.js.map +0 -1
- package/dist/hooks/compaction.js +0 -935
- package/dist/hooks/compaction.js.map +0 -1
- package/dist/hooks/validateArtifact.js +0 -933
- package/dist/hooks/validateArtifact.js.map +0 -1
- package/dist/state/progressCommit.js +0 -289
- package/dist/state/progressCommit.js.map +0 -1
- /package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/exit.yaml +0 -0
- /package/bundle/skills/agentera/capabilities/{hej → status}/schemas/exit.yaml +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { loadYamlMapping } from "../core/yaml.js";
|
|
5
|
+
import { canonicalRecordJson } from "./archiveDiscovery.js";
|
|
6
|
+
export const PERSISTED_OBJECTIVE_ID = /^objective:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
7
|
+
export const LEGACY_OBJECTIVE_ID = /^legacy-objective:[0-9a-f]{64}$/;
|
|
8
|
+
export const OBJECTIVE_ID = /^(objective:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|legacy-objective:[0-9a-f]{64})$/;
|
|
9
|
+
function mapping(value) {
|
|
10
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
11
|
+
}
|
|
12
|
+
function list(value) {
|
|
13
|
+
return Array.isArray(value) ? value.filter((entry) => entry !== null && typeof entry === "object" && !Array.isArray(entry)) : [];
|
|
14
|
+
}
|
|
15
|
+
/** Identity inputs deliberately exclude title, lifecycle, closure, root, and slug. */
|
|
16
|
+
export function canonicalObjectiveIdentityDocument(document) {
|
|
17
|
+
const objective = mapping(document.objective);
|
|
18
|
+
return {
|
|
19
|
+
baseline: mapping(document.baseline),
|
|
20
|
+
constraints: document.constraints ?? objective.constraints ?? [],
|
|
21
|
+
description: objective.description ?? document.description ?? "",
|
|
22
|
+
gates: mapping(document.gates),
|
|
23
|
+
measurement: objective.measurement ?? document.measurement ?? "",
|
|
24
|
+
metric: mapping(document.metric),
|
|
25
|
+
scope: mapping(document.scope),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function resolveObjectiveIdentity(document) {
|
|
29
|
+
const canonicalJson = canonicalRecordJson(canonicalObjectiveIdentityDocument(document));
|
|
30
|
+
const persisted = mapping(document.header).id;
|
|
31
|
+
if (persisted !== undefined) {
|
|
32
|
+
if (typeof persisted !== "string" || !PERSISTED_OBJECTIVE_ID.test(persisted)) {
|
|
33
|
+
throw new Error("objective header.id is not a valid persisted objective identity");
|
|
34
|
+
}
|
|
35
|
+
return { stableId: persisted, persisted: true, canonicalJson, compatibility: "canonical" };
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
stableId: `legacy-objective:${createHash("sha256").update(canonicalJson, "utf8").digest("hex")}`,
|
|
39
|
+
persisted: false,
|
|
40
|
+
canonicalJson,
|
|
41
|
+
compatibility: "legacy_derived_identity",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function discoverObjectiveArtifacts(projectRoot) {
|
|
45
|
+
const inspected = [];
|
|
46
|
+
const diagnostics = [];
|
|
47
|
+
for (const root of ["optimize", "optimera"]) {
|
|
48
|
+
const directory = path.join(projectRoot, ".agentera", root);
|
|
49
|
+
let slugs = [];
|
|
50
|
+
try {
|
|
51
|
+
slugs = fs.readdirSync(directory).sort();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
for (const slug of slugs) {
|
|
57
|
+
const objectivePath = path.join(directory, slug, "objective.yaml");
|
|
58
|
+
if (!fs.existsSync(objectivePath))
|
|
59
|
+
continue;
|
|
60
|
+
try {
|
|
61
|
+
const identity = resolveObjectiveIdentity(loadYamlMapping(fs.readFileSync(objectivePath, "utf8")));
|
|
62
|
+
inspected.push({ ...identity, path: objectivePath, slug, root });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
diagnostics.push({
|
|
66
|
+
class: "corrupt",
|
|
67
|
+
message: error.message,
|
|
68
|
+
candidate_paths: [objectivePath],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const objectives = [];
|
|
74
|
+
for (const stableId of [...new Set(inspected.map((candidate) => candidate.stableId))].sort()) {
|
|
75
|
+
const candidates = inspected.filter((candidate) => candidate.stableId === stableId);
|
|
76
|
+
const ambiguous = new Set(candidates.map((candidate) => candidate.canonicalJson)).size > 1;
|
|
77
|
+
if (ambiguous) {
|
|
78
|
+
diagnostics.push({
|
|
79
|
+
class: "ambiguous",
|
|
80
|
+
message: `objective identity ${stableId} resolves to conflicting documents`,
|
|
81
|
+
stable_id: stableId,
|
|
82
|
+
candidate_paths: candidates.map((candidate) => candidate.path).sort(),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
objectives.push({
|
|
86
|
+
stableId,
|
|
87
|
+
persisted: candidates.every((candidate) => candidate.persisted),
|
|
88
|
+
canonicalJson: candidates[0].canonicalJson,
|
|
89
|
+
compatibility: candidates.every((candidate) => candidate.persisted) ? "canonical" : "legacy_derived_identity",
|
|
90
|
+
paths: candidates.map((candidate) => candidate.path).sort(),
|
|
91
|
+
slugs: [...new Set(candidates.map((candidate) => candidate.slug))].sort(),
|
|
92
|
+
roots: [...new Set(candidates.map((candidate) => candidate.root))].sort(),
|
|
93
|
+
ambiguous,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
for (const slug of [...new Set(inspected.map((candidate) => candidate.slug))].sort()) {
|
|
97
|
+
const candidates = inspected.filter((candidate) => candidate.slug === slug);
|
|
98
|
+
const roots = new Set(candidates.map((candidate) => candidate.root));
|
|
99
|
+
const candidateIds = [...new Set(candidates.map((candidate) => candidate.stableId))].sort();
|
|
100
|
+
if (roots.size === 2 && candidateIds.length > 1) {
|
|
101
|
+
const candidatePaths = candidates.map((candidate) => candidate.path).sort();
|
|
102
|
+
diagnostics.push({
|
|
103
|
+
class: "ambiguous",
|
|
104
|
+
message: `canonical and legacy objective roots conflict for slug ${slug}`,
|
|
105
|
+
slug,
|
|
106
|
+
candidate_ids: candidateIds,
|
|
107
|
+
candidate_paths: candidatePaths,
|
|
108
|
+
});
|
|
109
|
+
for (const objective of objectives.filter((candidate) => candidateIds.includes(candidate.stableId)))
|
|
110
|
+
objective.ambiguous = true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { objectives, diagnostics };
|
|
114
|
+
}
|
|
115
|
+
export function inspectExperimentIdentities(objectiveId, document) {
|
|
116
|
+
if (!OBJECTIVE_ID.test(objectiveId))
|
|
117
|
+
throw new Error("objective identity is invalid");
|
|
118
|
+
const collections = [
|
|
119
|
+
["experiments", list(document.experiments)],
|
|
120
|
+
["archive", list(document.archive)],
|
|
121
|
+
["archived_experiments", list(document.archived_experiments)],
|
|
122
|
+
];
|
|
123
|
+
const counts = new Map();
|
|
124
|
+
for (const [, entries] of collections) {
|
|
125
|
+
for (const entry of entries) {
|
|
126
|
+
if (Number.isInteger(entry.number) && Number(entry.number) >= 0)
|
|
127
|
+
counts.set(Number(entry.number), (counts.get(Number(entry.number)) ?? 0) + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const caveats = [];
|
|
131
|
+
const entries = collections.flatMap(([collection, values]) => values.map((data, index) => {
|
|
132
|
+
const number = Number.isInteger(data.number) && Number(data.number) >= 0 ? Number(data.number) : null;
|
|
133
|
+
let compatibility = "canonical";
|
|
134
|
+
const entryCaveats = [];
|
|
135
|
+
if (data.number === undefined || data.number === null) {
|
|
136
|
+
compatibility = "legacy_missing_identity";
|
|
137
|
+
entryCaveats.push(`legacy ${collection}[${index}] is missing experiment number and remains visible but unaddressable`);
|
|
138
|
+
}
|
|
139
|
+
else if (number === null) {
|
|
140
|
+
compatibility = "legacy_invalid_identity";
|
|
141
|
+
entryCaveats.push(`legacy ${collection}[${index}] has invalid experiment number and remains visible but unaddressable`);
|
|
142
|
+
}
|
|
143
|
+
else if ((counts.get(number) ?? 0) > 1) {
|
|
144
|
+
compatibility = "legacy_duplicate_identity";
|
|
145
|
+
entryCaveats.push(`duplicate experiment number ${number} remains visible but ambiguous and unaddressable`);
|
|
146
|
+
}
|
|
147
|
+
caveats.push(...entryCaveats);
|
|
148
|
+
return {
|
|
149
|
+
stableId: number === null ? null : `${objectiveId}/experiment:${number}`,
|
|
150
|
+
number,
|
|
151
|
+
addressable: compatibility === "canonical",
|
|
152
|
+
compatibility,
|
|
153
|
+
provenance: { collection, index },
|
|
154
|
+
data,
|
|
155
|
+
caveats: entryCaveats,
|
|
156
|
+
};
|
|
157
|
+
}));
|
|
158
|
+
return { objectiveId, entries, caveats: [...new Set(caveats)] };
|
|
159
|
+
}
|
|
160
|
+
export class ExperimentIdentityError extends Error {
|
|
161
|
+
className;
|
|
162
|
+
details;
|
|
163
|
+
constructor(className, message, details = {}) {
|
|
164
|
+
super(message);
|
|
165
|
+
this.className = className;
|
|
166
|
+
this.details = details;
|
|
167
|
+
this.name = "ExperimentIdentityError";
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** Pure preflight used by later publication work; this function never changes project state. */
|
|
171
|
+
export function validateExperimentPublicationIdentity(discovery, projection, objectiveId, number) {
|
|
172
|
+
if (!OBJECTIVE_ID.test(objectiveId) || !Number.isInteger(number) || number < 0) {
|
|
173
|
+
throw new ExperimentIdentityError("invalid_request", "publication requires a valid objective identity and non-negative integer experiment number");
|
|
174
|
+
}
|
|
175
|
+
const objective = discovery.objectives.find((candidate) => candidate.stableId === objectiveId);
|
|
176
|
+
if (!objective)
|
|
177
|
+
throw new ExperimentIdentityError("not_found", `objective identity ${objectiveId} was not found`);
|
|
178
|
+
if (objective.ambiguous || projection.objectiveId !== objectiveId || projection.entries.some((entry) => !entry.addressable)) {
|
|
179
|
+
throw new ExperimentIdentityError("ambiguous", "experiment publication identity is ambiguous; no effects are allowed", {
|
|
180
|
+
stable_id: `${objectiveId}/experiment:${number}`,
|
|
181
|
+
candidate_paths: objective.paths,
|
|
182
|
+
compatibility_caveats: projection.caveats,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const stableId = `${objectiveId}/experiment:${number}`;
|
|
186
|
+
if (projection.entries.some((entry) => entry.stableId === stableId)) {
|
|
187
|
+
throw new ExperimentIdentityError("ambiguous", `experiment identity ${stableId} already exists; no effects are allowed`, { stable_id: stableId });
|
|
188
|
+
}
|
|
189
|
+
return stableId;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=experimentIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experimentIdentity.js","sourceRoot":"","sources":["../../src/state/experimentIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,UAAU,CAAC,OAAO;SAC1C,CAAC,CAAC;IACL,CAAC;IACD,MAAM,QAAQ,GAAG,GAAG,WAAW,eAAe,MAAM,EAAE,CAAC;IACvD,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,uBAAuB,CAAC,WAAW,EAAE,uBAAuB,QAAQ,yCAAyC,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;IACpJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { deflateRawSync, inflateRawSync } from "node:zlib";
|
|
5
|
+
import YAML from "yaml";
|
|
6
|
+
import { loadYamlMapping } from "../core/yaml.js";
|
|
7
|
+
import { canonicalRecordJson } from "./archiveDiscovery.js";
|
|
8
|
+
import { StateRetrievalFailure } from "./directRetrieval.js";
|
|
9
|
+
import { OBJECTIVE_ID, discoverObjectiveArtifacts, inspectExperimentIdentities, } from "./experimentIdentity.js";
|
|
10
|
+
const CURSOR_VERSION = 1;
|
|
11
|
+
const ORDER = "experiment_number_desc";
|
|
12
|
+
const MAX_LIST_BYTES = 32_768;
|
|
13
|
+
const AUTHORITY = "references/artifacts/state-storage-authority.yaml";
|
|
14
|
+
function hash(value) {
|
|
15
|
+
return createHash("sha256").update(canonicalRecordJson(value), "utf8").digest("hex");
|
|
16
|
+
}
|
|
17
|
+
function mapping(value) {
|
|
18
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function fail(exitCode, className, message, verb, details = {}) {
|
|
21
|
+
const list = verb === "list";
|
|
22
|
+
return new StateRetrievalFailure({
|
|
23
|
+
schemaVersion: "agentera.stateFailure.v1",
|
|
24
|
+
status: "fail",
|
|
25
|
+
error: {
|
|
26
|
+
class: className,
|
|
27
|
+
message,
|
|
28
|
+
syntax: list
|
|
29
|
+
? "agentera state experiments list --objective OBJECTIVE_ID [--limit N] [--cursor TOKEN] --format json"
|
|
30
|
+
: "agentera state experiments get --objective OBJECTIVE_ID --number N --format json",
|
|
31
|
+
example: list
|
|
32
|
+
? "agentera state experiments list --objective objective:123e4567-e89b-42d3-a456-426614174000 --limit 20 --format json"
|
|
33
|
+
: "agentera state experiments get --objective objective:123e4567-e89b-42d3-a456-426614174000 --number 0 --format json",
|
|
34
|
+
recovery: details.recovery ?? "Correct the objective-scoped experiment command and retry; no state was changed.",
|
|
35
|
+
valid_values: list
|
|
36
|
+
? ["--objective OBJECTIVE_ID", "--limit 1..100", "--cursor TOKEN", "--format text|json|yaml"]
|
|
37
|
+
: ["--objective OBJECTIVE_ID", "--number 0|1|2|...", "--format text|json|yaml"],
|
|
38
|
+
...details,
|
|
39
|
+
},
|
|
40
|
+
}, exitCode);
|
|
41
|
+
}
|
|
42
|
+
function selectedObjective(projectRoot, objectiveId, verb) {
|
|
43
|
+
if (!OBJECTIVE_ID.test(objectiveId)) {
|
|
44
|
+
throw fail(2, "invalid_request", `invalid objective identity '${objectiveId}'`, verb, {
|
|
45
|
+
valid_values: ["objective:<lowercase-rfc9562-uuid>", "legacy-objective:<64-lowercase-hex-digest>"],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const discovery = discoverObjectiveArtifacts(projectRoot);
|
|
49
|
+
const objective = discovery.objectives.find((candidate) => candidate.stableId === objectiveId);
|
|
50
|
+
if (!objective) {
|
|
51
|
+
throw fail(1, "not_found", `objective identity '${objectiveId}' was not found`, verb, {
|
|
52
|
+
stable_id: objectiveId,
|
|
53
|
+
recovery: "Use an objective identity returned by Agentera objective state, then retry.",
|
|
54
|
+
details: { compatibility_diagnostics: discovery.diagnostics },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (objective.ambiguous) {
|
|
58
|
+
throw fail(1, "ambiguous", `objective identity '${objectiveId}' resolves to incompatible canonical or legacy candidates`, verb, {
|
|
59
|
+
stable_id: objectiveId,
|
|
60
|
+
recovery: "Repair the objective identity/root collision; Agentera will not choose by path or root preference.",
|
|
61
|
+
details: { candidate_paths: objective.paths, compatibility_diagnostics: discovery.diagnostics },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return objective;
|
|
65
|
+
}
|
|
66
|
+
function readProjection(objectiveId, objectivePath) {
|
|
67
|
+
const projectionPath = path.join(path.dirname(objectivePath), "experiments.yaml");
|
|
68
|
+
if (!fs.existsSync(projectionPath))
|
|
69
|
+
return { sources: [], diagnostics: [] };
|
|
70
|
+
try {
|
|
71
|
+
const projection = inspectExperimentIdentities(objectiveId, loadYamlMapping(fs.readFileSync(projectionPath, "utf8")));
|
|
72
|
+
return {
|
|
73
|
+
sources: projection.entries.map((entry) => ({
|
|
74
|
+
path: projectionPath,
|
|
75
|
+
collection: entry.provenance.collection,
|
|
76
|
+
index: entry.provenance.index,
|
|
77
|
+
record: entry.data,
|
|
78
|
+
addressable: entry.addressable,
|
|
79
|
+
compatibility: entry.compatibility,
|
|
80
|
+
caveats: entry.caveats,
|
|
81
|
+
})),
|
|
82
|
+
diagnostics: projection.caveats.map((message) => ({ class: "compatibility", path: projectionPath, message })),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw fail(1, "corrupt", `experiment projection '${projectionPath}' cannot be read safely`, "list", {
|
|
87
|
+
recovery: "Repair the selected objective's experiments.yaml, then retry.",
|
|
88
|
+
details: { path: projectionPath, message: error.message },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function archiveNumber(filename) {
|
|
93
|
+
if (!/^(0|[1-9][0-9]*)\.yaml$/.test(filename))
|
|
94
|
+
return undefined;
|
|
95
|
+
const number = Number(filename.slice(0, -5));
|
|
96
|
+
return Number.isSafeInteger(number) ? number : undefined;
|
|
97
|
+
}
|
|
98
|
+
function readArchives(objectiveId, objectivePath) {
|
|
99
|
+
const directory = path.join(path.dirname(objectivePath), "archive", "experiments");
|
|
100
|
+
let names;
|
|
101
|
+
try {
|
|
102
|
+
names = fs.readdirSync(directory).sort();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return { sources: [], diagnostics: [] };
|
|
106
|
+
}
|
|
107
|
+
const sources = [];
|
|
108
|
+
const diagnostics = [];
|
|
109
|
+
for (const name of names) {
|
|
110
|
+
const file = path.join(directory, name);
|
|
111
|
+
const number = archiveNumber(name);
|
|
112
|
+
try {
|
|
113
|
+
if (number === undefined || fs.lstatSync(file).isSymbolicLink() || !fs.lstatSync(file).isFile())
|
|
114
|
+
throw new Error("archive filename or file type is invalid");
|
|
115
|
+
const envelope = loadYamlMapping(fs.readFileSync(file, "utf8"));
|
|
116
|
+
const stableId = `${objectiveId}/experiment:${number}`;
|
|
117
|
+
if (envelope.schemaVersion !== "agentera.experimentArchive.v1")
|
|
118
|
+
throw new Error("unsupported experiment archive schemaVersion");
|
|
119
|
+
if (envelope.objective_id !== objectiveId || envelope.experiment_number !== number || envelope.stable_id !== stableId)
|
|
120
|
+
throw new Error("archive identity does not match its objective-scoped path");
|
|
121
|
+
if (!mapping(envelope.record) || envelope.record.number !== number)
|
|
122
|
+
throw new Error("archive record number does not match its envelope");
|
|
123
|
+
const digest = hash(envelope.record);
|
|
124
|
+
if (envelope.record_sha256 !== digest)
|
|
125
|
+
throw new Error("archive record_sha256 does not match its record");
|
|
126
|
+
if (!mapping(envelope.provenance) || envelope.provenance.authority !== AUTHORITY || envelope.provenance.objective_id !== objectiveId || envelope.provenance.experiment_id !== stableId) {
|
|
127
|
+
throw new Error("archive provenance does not match its authority and identity");
|
|
128
|
+
}
|
|
129
|
+
sources.push({ path: file, record: envelope.record, recordSha256: digest, provenance: envelope.provenance });
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
diagnostics.push({ class: "corrupt", path: file, message: error.message, experiment_number: number ?? null });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { sources, diagnostics };
|
|
136
|
+
}
|
|
137
|
+
function logicalExperiment(objectiveId, number, projection, archives) {
|
|
138
|
+
const stableId = `${objectiveId}/experiment:${number}`;
|
|
139
|
+
const projectionPaths = new Map();
|
|
140
|
+
for (const source of projection)
|
|
141
|
+
projectionPaths.set(source.path, [...(projectionPaths.get(source.path) ?? []), source]);
|
|
142
|
+
const duplicateProjection = [...projectionPaths.values()].some((sources) => sources.length > 1);
|
|
143
|
+
const projectionHashes = new Set(projection.map((source) => hash(source.record)));
|
|
144
|
+
const archiveHashes = new Set(archives.map((source) => source.recordSha256));
|
|
145
|
+
const fullProjection = projection.filter((source) => source.collection === "experiments");
|
|
146
|
+
const summaryProjection = projection.filter((source) => source.collection !== "experiments");
|
|
147
|
+
const summaryDetail = summaryProjection.some((source) => Object.keys(source.record).some((field) => field !== "number"));
|
|
148
|
+
const immutableConflict = archiveHashes.size > 1 || (archives.length > 0 && fullProjection.some((source) => !archiveHashes.has(hash(source.record))));
|
|
149
|
+
const duplicate = duplicateProjection || projectionHashes.size > 1 && projection.length > 1;
|
|
150
|
+
const detailAvailability = archives.length > 0 || fullProjection.length > 0 ? "full" : summaryDetail ? "summary" : "unavailable";
|
|
151
|
+
const compatibility = immutableConflict
|
|
152
|
+
? "immutable_conflict"
|
|
153
|
+
: duplicate
|
|
154
|
+
? "legacy_duplicate_identity"
|
|
155
|
+
: archives.length > 0
|
|
156
|
+
? "canonical_archive"
|
|
157
|
+
: fullProjection.length > 0
|
|
158
|
+
? "legacy_full_without_archive"
|
|
159
|
+
: summaryDetail ? "legacy_summary_only" : "legacy_detail_unavailable";
|
|
160
|
+
const source = archives.length > 0
|
|
161
|
+
? projection.length > 0 ? "archive_and_projection" : "immutable_archive"
|
|
162
|
+
: fullProjection.length > 0 ? "retained_projection" : "legacy_summary_projection";
|
|
163
|
+
const fingerprint = hash(archives.length > 0
|
|
164
|
+
? {
|
|
165
|
+
stable_id: stableId,
|
|
166
|
+
evidence: "immutable_archive",
|
|
167
|
+
record_hashes: [...archiveHashes].sort(),
|
|
168
|
+
compatibility,
|
|
169
|
+
}
|
|
170
|
+
: {
|
|
171
|
+
stable_id: stableId,
|
|
172
|
+
evidence: fullProjection.length > 0 ? "retained_full" : summaryDetail ? "legacy_summary" : "unavailable",
|
|
173
|
+
record_hashes: [...projectionHashes].sort(),
|
|
174
|
+
compatibility,
|
|
175
|
+
});
|
|
176
|
+
return { key: stableId, stableId, number, projection, archives, addressable: !immutableConflict && !duplicate, compatibility, detailAvailability, source, fingerprint };
|
|
177
|
+
}
|
|
178
|
+
function loadObjective(projectRoot, objectiveId, verb) {
|
|
179
|
+
const objective = selectedObjective(projectRoot, objectiveId, verb);
|
|
180
|
+
const projections = [];
|
|
181
|
+
const archives = [];
|
|
182
|
+
const diagnostics = [];
|
|
183
|
+
for (const objectivePath of objective.paths) {
|
|
184
|
+
const projection = readProjection(objectiveId, objectivePath);
|
|
185
|
+
projections.push(...projection.sources);
|
|
186
|
+
diagnostics.push(...projection.diagnostics);
|
|
187
|
+
const archive = readArchives(objectiveId, objectivePath);
|
|
188
|
+
archives.push(...archive.sources);
|
|
189
|
+
diagnostics.push(...archive.diagnostics);
|
|
190
|
+
}
|
|
191
|
+
const numbers = [...new Set([
|
|
192
|
+
...projections.map((source) => Number(source.record.number)).filter((number) => Number.isSafeInteger(number) && number >= 0),
|
|
193
|
+
...archives.map((source) => Number(source.record.number)),
|
|
194
|
+
])].sort((left, right) => right - left);
|
|
195
|
+
const experiments = numbers.map((number) => logicalExperiment(objectiveId, number, projections.filter((source) => source.record.number === number), archives.filter((source) => source.record.number === number)));
|
|
196
|
+
for (const source of projections.filter((item) => !Number.isSafeInteger(item.record.number) || Number(item.record.number) < 0)) {
|
|
197
|
+
const fingerprint = hash({ path: source.path, collection: source.collection, index: source.index, record: source.record });
|
|
198
|
+
experiments.push({
|
|
199
|
+
key: `unaddressable:${fingerprint}`,
|
|
200
|
+
stableId: null,
|
|
201
|
+
number: null,
|
|
202
|
+
projection: [source],
|
|
203
|
+
archives: [],
|
|
204
|
+
addressable: false,
|
|
205
|
+
compatibility: source.compatibility,
|
|
206
|
+
detailAvailability: source.collection === "experiments" ? "full" : "summary",
|
|
207
|
+
source: "legacy_unaddressable_projection",
|
|
208
|
+
fingerprint,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return { objective, experiments, diagnostics };
|
|
212
|
+
}
|
|
213
|
+
function provenance(experiment, objective) {
|
|
214
|
+
return {
|
|
215
|
+
objective: {
|
|
216
|
+
stable_id: objective.stableId,
|
|
217
|
+
compatibility: objective.compatibility,
|
|
218
|
+
paths: objective.paths,
|
|
219
|
+
roots: objective.roots,
|
|
220
|
+
slugs: objective.slugs,
|
|
221
|
+
},
|
|
222
|
+
projection: experiment.projection.map((source) => ({ path: source.path, collection: source.collection, index: source.index })),
|
|
223
|
+
archive: experiment.archives.map((source) => ({ path: source.path, record_sha256: source.recordSha256, provenance: source.provenance })),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function summaryRecord(experiment) {
|
|
227
|
+
const source = experiment.archives[0]?.record ?? experiment.projection[0]?.record;
|
|
228
|
+
if (!source)
|
|
229
|
+
return undefined;
|
|
230
|
+
const summary = {};
|
|
231
|
+
for (const field of ["date", "label", "status", "summary", "conclusion"])
|
|
232
|
+
if (source[field] !== undefined)
|
|
233
|
+
summary[field] = source[field];
|
|
234
|
+
return Object.keys(summary).length > 0 ? summary : undefined;
|
|
235
|
+
}
|
|
236
|
+
function listEntry(experiment, objective) {
|
|
237
|
+
return {
|
|
238
|
+
stable_id: experiment.stableId,
|
|
239
|
+
artifact_id: "experiments",
|
|
240
|
+
experiment_number: experiment.number,
|
|
241
|
+
addressable: experiment.addressable,
|
|
242
|
+
detail_availability: experiment.detailAvailability,
|
|
243
|
+
compatibility: experiment.compatibility,
|
|
244
|
+
source: experiment.source,
|
|
245
|
+
provenance: provenance(experiment, objective),
|
|
246
|
+
retrieval: experiment.addressable
|
|
247
|
+
? { get: `agentera state experiments get --objective ${objective.stableId} --number ${experiment.number} --format json` }
|
|
248
|
+
: { get: null, recovery: "Repair the legacy identity or immutable conflict before exact retrieval." },
|
|
249
|
+
...(summaryRecord(experiment) ? { summary: summaryRecord(experiment) } : {}),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function snapshotId(experiments) {
|
|
253
|
+
return hash({ collection: "experiments.records", order: ORDER, candidates: experiments.map(({ key, fingerprint }) => ({ key, fingerprint })) });
|
|
254
|
+
}
|
|
255
|
+
function cursorKey(projectRoot) {
|
|
256
|
+
return createHash("sha256").update(`agentera-experiment-cursor\0${path.resolve(projectRoot)}`, "utf8").digest();
|
|
257
|
+
}
|
|
258
|
+
function sign(payload, projectRoot) {
|
|
259
|
+
return createHmac("sha256", cursorKey(projectRoot)).update(canonicalRecordJson(payload), "utf8").digest("hex");
|
|
260
|
+
}
|
|
261
|
+
function encodeCursor(payload, projectRoot) {
|
|
262
|
+
return deflateRawSync(Buffer.from(JSON.stringify({ ...payload, signature: sign(payload, projectRoot) }), "utf8")).toString("base64url");
|
|
263
|
+
}
|
|
264
|
+
function parseCursor(token, projectRoot, objectiveId) {
|
|
265
|
+
const invalid = (message) => {
|
|
266
|
+
throw fail(2, "cursor_invalid", message, "list", {
|
|
267
|
+
recovery: "Copy response.next_cursor exactly for the same objective, or omit --cursor to establish a new snapshot.",
|
|
268
|
+
details: { cursor: "opaque; do not parse or construct cursor tokens" },
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
if (!token || token.length > 100_000 || !/^[A-Za-z0-9_-]+$/.test(token))
|
|
272
|
+
invalid("cursor is not a valid opaque token");
|
|
273
|
+
let decoded;
|
|
274
|
+
try {
|
|
275
|
+
const compressed = Buffer.from(token, "base64url");
|
|
276
|
+
if (compressed.toString("base64url") !== token)
|
|
277
|
+
invalid("cursor is not a canonical opaque token");
|
|
278
|
+
decoded = JSON.parse(inflateRawSync(compressed, { maxOutputLength: 1_000_000 }).toString("utf8"));
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
invalid("cursor is not a valid opaque token");
|
|
282
|
+
}
|
|
283
|
+
if (!mapping(decoded))
|
|
284
|
+
invalid("cursor payload is invalid");
|
|
285
|
+
const { signature, ...unsigned } = decoded;
|
|
286
|
+
if (typeof signature !== "string" || !/^[0-9a-f]{64}$/.test(signature))
|
|
287
|
+
invalid("cursor signature is invalid");
|
|
288
|
+
const expected = sign(unsigned, projectRoot);
|
|
289
|
+
if (!timingSafeEqual(Buffer.from(signature), Buffer.from(expected)))
|
|
290
|
+
invalid("cursor signature is invalid");
|
|
291
|
+
if (unsigned.version !== CURSOR_VERSION || unsigned.collection !== "experiments.records" || unsigned.order !== ORDER || unsigned.objective_id !== objectiveId)
|
|
292
|
+
invalid("cursor is bound to a different collection, objective, or order");
|
|
293
|
+
if (!Number.isSafeInteger(unsigned.after) || Number(unsigned.after) < 1 || !Array.isArray(unsigned.candidate_keys) || unsigned.candidate_keys.some((key) => typeof key !== "string"))
|
|
294
|
+
invalid("cursor payload is invalid");
|
|
295
|
+
if (typeof unsigned.snapshot_id !== "string" || !/^[0-9a-f]{64}$/.test(unsigned.snapshot_id) || typeof unsigned.diagnostic_hash !== "string" || !/^[0-9a-f]{64}$/.test(unsigned.diagnostic_hash))
|
|
296
|
+
invalid("cursor snapshot is invalid");
|
|
297
|
+
return unsigned;
|
|
298
|
+
}
|
|
299
|
+
function snapshotExperiments(current, cursor) {
|
|
300
|
+
const byKey = new Map(current.experiments.map((experiment) => [experiment.key, experiment]));
|
|
301
|
+
const experiments = cursor.candidate_keys.map((key) => byKey.get(key));
|
|
302
|
+
if (experiments.some((experiment) => !experiment) || snapshotId(experiments) !== cursor.snapshot_id || hash(current.diagnostics) !== cursor.diagnostic_hash) {
|
|
303
|
+
throw fail(1, "cursor_snapshot_unavailable", "the objective experiment snapshot changed and cannot be resumed exactly", "list", {
|
|
304
|
+
recovery: "Start a new experiment listing without --cursor to establish a current objective snapshot.",
|
|
305
|
+
details: { snapshot_id: cursor.snapshot_id },
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
return experiments;
|
|
309
|
+
}
|
|
310
|
+
function withPage(loaded, experiments, start, retained, projectRoot, reason) {
|
|
311
|
+
const selected = experiments.slice(start, start + retained);
|
|
312
|
+
const remaining = experiments.length - start - selected.length;
|
|
313
|
+
const omitted = remaining > 0;
|
|
314
|
+
const snapshot = snapshotId(experiments);
|
|
315
|
+
const response = {
|
|
316
|
+
schemaVersion: "agentera.stateRetrieval.v1",
|
|
317
|
+
command: "state experiments list",
|
|
318
|
+
status: loaded.diagnostics.length > 0 || loaded.objective.compatibility !== "canonical" || experiments.some((entry) => !entry.addressable || entry.detailAvailability !== "full") ? "degraded" : "ok",
|
|
319
|
+
entries: selected.map((entry) => listEntry(entry, loaded.objective)),
|
|
320
|
+
counts: { total: experiments.length, returned: selected.length, remaining, omitted: remaining, diagnostics: loaded.diagnostics.length },
|
|
321
|
+
order: ORDER,
|
|
322
|
+
filters: { objective: loaded.objective.stableId },
|
|
323
|
+
snapshot: { id: snapshot, candidate_count: experiments.length, has_more: omitted },
|
|
324
|
+
source: {
|
|
325
|
+
artifact: "experiments",
|
|
326
|
+
storage: "objective_projection_and_immutable_objective_archive",
|
|
327
|
+
objective_paths: loaded.objective.paths,
|
|
328
|
+
compatibility_diagnostics: loaded.diagnostics,
|
|
329
|
+
},
|
|
330
|
+
source_contract: {
|
|
331
|
+
authority: AUTHORITY,
|
|
332
|
+
complete_for_experiment_list_retrieval: true,
|
|
333
|
+
storage_ownership: "objective_scoped_durable_records_and_bounded_10_40_50_projection",
|
|
334
|
+
},
|
|
335
|
+
retrieval: { get: `agentera state experiments get --objective ${loaded.objective.stableId} --number N --format json` },
|
|
336
|
+
omitted,
|
|
337
|
+
omitted_count: remaining,
|
|
338
|
+
omission_reason: omitted ? reason : null,
|
|
339
|
+
};
|
|
340
|
+
if (omitted) {
|
|
341
|
+
response.next_cursor = encodeCursor({
|
|
342
|
+
version: CURSOR_VERSION,
|
|
343
|
+
collection: "experiments.records",
|
|
344
|
+
objective_id: loaded.objective.stableId,
|
|
345
|
+
order: ORDER,
|
|
346
|
+
snapshot_id: snapshot,
|
|
347
|
+
candidate_keys: experiments.map((entry) => entry.key),
|
|
348
|
+
diagnostic_hash: hash(loaded.diagnostics),
|
|
349
|
+
after: start + selected.length,
|
|
350
|
+
}, projectRoot);
|
|
351
|
+
response.retrieval.continue = `agentera state experiments list --objective ${loaded.objective.stableId} --limit 20 --cursor ${response.next_cursor} --format json`;
|
|
352
|
+
}
|
|
353
|
+
return response;
|
|
354
|
+
}
|
|
355
|
+
function serializedBytes(response, format) {
|
|
356
|
+
const bytes = format === "yaml" ? YAML.stringify(response) : JSON.stringify(response, null, 2) + "\n";
|
|
357
|
+
return Buffer.byteLength(bytes, "utf8");
|
|
358
|
+
}
|
|
359
|
+
export function listExperiments(projectRoot, objectiveId, options) {
|
|
360
|
+
if (!Number.isSafeInteger(options.limit) || options.limit < 1 || options.limit > 100)
|
|
361
|
+
throw fail(2, "invalid_request", "experiment list limit must be an integer from 1 through 100", "list", { valid_values: ["1..100"] });
|
|
362
|
+
const loaded = loadObjective(projectRoot, objectiveId, "list");
|
|
363
|
+
const parsed = options.cursor ? parseCursor(options.cursor, projectRoot, objectiveId) : undefined;
|
|
364
|
+
const experiments = parsed ? snapshotExperiments(loaded, parsed) : loaded.experiments;
|
|
365
|
+
const start = parsed?.after ?? 0;
|
|
366
|
+
if (start > experiments.length)
|
|
367
|
+
throw fail(2, "cursor_invalid", "cursor position is outside its experiment snapshot", "list");
|
|
368
|
+
const requested = Math.min(options.limit, experiments.length - start);
|
|
369
|
+
let response = withPage(loaded, experiments, start, requested, projectRoot, "page_limit");
|
|
370
|
+
if (options.format !== "text") {
|
|
371
|
+
for (let retained = requested; retained > 0 && serializedBytes(response, options.format) > MAX_LIST_BYTES; retained -= 1)
|
|
372
|
+
response = withPage(loaded, experiments, start, retained - 1, projectRoot, "serialized_output_byte_budget");
|
|
373
|
+
if (serializedBytes(response, options.format) > MAX_LIST_BYTES || (experiments.length > start && response.entries.length === 0)) {
|
|
374
|
+
throw fail(1, "unsupported_state", `one experiment identity cannot fit within the ${MAX_LIST_BYTES}-byte ${options.format.toUpperCase()} list budget`, "list", {
|
|
375
|
+
recovery: `Fetch one known identity with agentera state experiments get --objective ${objectiveId} --number N --format json.`,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return response;
|
|
380
|
+
}
|
|
381
|
+
export function getExperiment(projectRoot, objectiveId, number) {
|
|
382
|
+
if (!Number.isSafeInteger(number) || number < 0)
|
|
383
|
+
throw fail(2, "invalid_request", "--number must be a non-negative integer without leading zeros", "get", { valid_values: ["0", "1", "2", "..."] });
|
|
384
|
+
const loaded = loadObjective(projectRoot, objectiveId, "get");
|
|
385
|
+
const corruptArchive = loaded.diagnostics.find((diagnostic) => diagnostic.class === "corrupt" && diagnostic.experiment_number === number);
|
|
386
|
+
if (corruptArchive)
|
|
387
|
+
throw fail(1, "corrupt", `experiment archive for '${objectiveId}/experiment:${number}' cannot be verified`, "get", {
|
|
388
|
+
stable_id: `${objectiveId}/experiment:${number}`,
|
|
389
|
+
entry_number: number,
|
|
390
|
+
recovery: "Preserve and repair the immutable archive envelope before retrying exact retrieval.",
|
|
391
|
+
details: { diagnostic: corruptArchive },
|
|
392
|
+
});
|
|
393
|
+
const experiment = loaded.experiments.find((candidate) => candidate.number === number);
|
|
394
|
+
if (!experiment)
|
|
395
|
+
throw fail(1, "not_found", `experiment '${objectiveId}/experiment:${number}' was not found`, "get", {
|
|
396
|
+
stable_id: `${objectiveId}/experiment:${number}`,
|
|
397
|
+
entry_number: number,
|
|
398
|
+
recovery: `List known identities with agentera state experiments list --objective ${objectiveId} --format json, then retry.`,
|
|
399
|
+
});
|
|
400
|
+
if (experiment.compatibility === "immutable_conflict")
|
|
401
|
+
throw fail(1, "immutable_conflict", `experiment '${experiment.stableId}' differs between immutable archive and retained projection`, "get", {
|
|
402
|
+
stable_id: experiment.stableId,
|
|
403
|
+
entry_number: number,
|
|
404
|
+
recovery: "Preserve the immutable archive and reconcile the conflicting projection before retrying.",
|
|
405
|
+
details: { provenance: provenance(experiment, loaded.objective) },
|
|
406
|
+
});
|
|
407
|
+
if (!experiment.addressable)
|
|
408
|
+
throw fail(1, "ambiguous", `experiment '${experiment.stableId}' has duplicate retained identities`, "get", {
|
|
409
|
+
stable_id: experiment.stableId,
|
|
410
|
+
entry_number: number,
|
|
411
|
+
recovery: "Repair duplicate projection identities; Agentera will not choose by array order.",
|
|
412
|
+
details: { provenance: provenance(experiment, loaded.objective) },
|
|
413
|
+
});
|
|
414
|
+
const archive = experiment.archives[0];
|
|
415
|
+
const retainedFull = experiment.projection.find((source) => source.collection === "experiments");
|
|
416
|
+
const summary = experiment.projection.find((source) => source.collection !== "experiments");
|
|
417
|
+
const record = archive?.record ?? retainedFull?.record ?? summary?.record;
|
|
418
|
+
if (!record || experiment.detailAvailability === "unavailable")
|
|
419
|
+
throw fail(1, "incomplete", `experiment '${experiment.stableId}' exists but detail is unavailable`, "get", {
|
|
420
|
+
stable_id: experiment.stableId, entry_number: number,
|
|
421
|
+
recovery: "Restore a retained or immutable experiment record; Agentera will not reconstruct dropped legacy detail.",
|
|
422
|
+
});
|
|
423
|
+
return {
|
|
424
|
+
schemaVersion: "agentera.stateRetrieval.v1",
|
|
425
|
+
command: "state experiments get",
|
|
426
|
+
status: experiment.detailAvailability === "full" ? "ok" : "degraded",
|
|
427
|
+
entry: listEntry(experiment, loaded.objective),
|
|
428
|
+
record,
|
|
429
|
+
source: {
|
|
430
|
+
artifact: "experiments",
|
|
431
|
+
objective_id: objectiveId,
|
|
432
|
+
experiment_number: number,
|
|
433
|
+
selected: archive ? "immutable_archive" : retainedFull ? "retained_projection" : "legacy_summary_projection",
|
|
434
|
+
archive_verified: Boolean(archive),
|
|
435
|
+
projection_verified_against_archive: Boolean(archive && retainedFull),
|
|
436
|
+
provenance: provenance(experiment, loaded.objective),
|
|
437
|
+
},
|
|
438
|
+
source_contract: {
|
|
439
|
+
authority: AUTHORITY,
|
|
440
|
+
complete_for_experiment_retrieval: true,
|
|
441
|
+
detail_availability: experiment.detailAvailability,
|
|
442
|
+
compatibility_truth: experiment.detailAvailability === "summary" ? "summary_only_legacy_detail_is_not_reconstructed" : "full_detail_available",
|
|
443
|
+
storage_ownership: archive ? "immutable_objective_archive" : "bounded_objective_projection",
|
|
444
|
+
},
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
//# sourceMappingURL=experimentRetrieval.js.map
|