agentera 3.0.0-dev.3 → 3.0.0-dev.31
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/LICENSE +201 -0
- package/README.md +96 -6
- package/bundle/.agentera-npx-bundle.json +1 -1
- package/bundle/CHANGELOG.md +1144 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +136 -0
- package/bundle/UPGRADE.md +201 -0
- package/bundle/extract-corpus-parity.json +21 -0
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-manifest-interface-model.yaml +42 -252
- package/bundle/references/adapters/package-registry.yaml +20 -188
- package/bundle/references/adapters/package-surface-characterization.md +36 -37
- package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
- package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
- package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +97 -0
- package/bundle/references/analysis/benchmark.md +10 -6
- package/bundle/references/analysis/evidence-tier-authority.yaml +516 -0
- package/bundle/references/analysis/startup-measurement-contract.yaml +37 -26
- package/bundle/references/analysis/verification-policy.yaml +142 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +9 -8
- package/bundle/references/artifacts/state-storage-authority.yaml +2167 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/agent-ready-state-contract.yaml +64 -81
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +7 -8
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +58 -29
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +12 -49
- package/bundle/references/cli/capability-instruction-contract.yaml +96 -58
- package/bundle/references/cli/capability-instruction-structure.md +144 -0
- package/bundle/references/cli/capability-tool-classification.yaml +14 -14
- package/bundle/references/cli/coexistence-probe.yaml +13 -0
- package/bundle/references/cli/hybrid-route-contract.yaml +416 -0
- package/bundle/references/cli/parity-expected-actual-template.md +30 -0
- package/bundle/references/cli/prime-consumer-compatibility.yaml +651 -0
- package/bundle/references/cli/routing-execution-vocabulary.yaml +16 -38
- package/bundle/references/cli/routing-model.md +139 -0
- package/bundle/references/cli/single-name-protocol.yaml +42 -0
- package/bundle/references/cli/trigger-schema-enrichment.md +140 -0
- package/bundle/references/cli/update-channels.yaml +45 -7
- package/bundle/references/cli/upgrade-repair-wording.md +25 -0
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +97 -0
- package/bundle/references/cli/vocabulary-index.yaml +23 -18
- package/bundle/references/cli/vocabulary.md +346 -331
- package/bundle/references/meta/documentation-inventory.md +10 -3
- package/bundle/registry.json +14 -14
- package/bundle/skills/agentera/SKILL.md +182 -407
- 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/audit/schemas/triggers.yaml +25 -0
- package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +20 -19
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +85 -0
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +27 -0
- package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/validation.yaml +16 -16
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +12 -12
- package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +16 -0
- 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/discuss/schemas/triggers.yaml +20 -0
- package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/validation.yaml +9 -8
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +80 -0
- package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +18 -18
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +17 -17
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +76 -0
- package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +9 -7
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +121 -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/plan/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +89 -0
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/artifacts.yaml +4 -4
- package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +3 -3
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +20 -0
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +85 -0
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
- package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +16 -0
- package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +72 -0
- package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +22 -0
- package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +16 -16
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +23 -0
- package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
- package/bundle/skills/agentera/capability_schema_contract.yaml +200 -37
- package/bundle/skills/agentera/protocol.yaml +31 -31
- package/bundle/skills/agentera/references/contract.md +387 -329
- package/bundle/skills/agentera/route-phrases.yaml +81 -0
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +5 -4
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +40 -22
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +5 -4
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +15 -19
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +145 -14
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +58 -21
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +22 -8
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +327 -15
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +51 -53
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +257 -28
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
- package/dist/analytics/extractCorpus/cli.js +191 -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/evidenceTiers.js +561 -0
- package/dist/analytics/extractCorpus/evidenceTiers.js.map +1 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +106 -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 +15 -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/tierReader.js +109 -0
- package/dist/analytics/extractCorpus/tierReader.js.map +1 -0
- package/dist/analytics/extractCorpus.js +2 -1790
- package/dist/analytics/extractCorpus.js.map +1 -1
- package/dist/analytics/profileSignals.js +212 -0
- package/dist/analytics/profileSignals.js.map +1 -0
- package/dist/analytics/usageStats.js +191 -41
- 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 +16 -0
- package/dist/capabilities/audit/instructions.js.map +1 -0
- package/dist/capabilities/build/instructions.js +18 -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 +16 -0
- package/dist/capabilities/discuss/instructions.js.map +1 -0
- package/dist/capabilities/document/instructions.js +12 -0
- package/dist/capabilities/document/instructions.js.map +1 -0
- package/dist/capabilities/index.js +39 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/optimize/instructions.js +14 -0
- package/dist/capabilities/optimize/instructions.js.map +1 -0
- package/dist/capabilities/orchestrate/instructions.js +41 -0
- package/dist/capabilities/orchestrate/instructions.js.map +1 -0
- package/dist/capabilities/plan/instructions.js +15 -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/status/startupInstructions.js +39 -0
- package/dist/capabilities/status/startupInstructions.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/argvalidate.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 +44 -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 +214 -0
- package/dist/cli/capabilityContext/contract.js.map +1 -0
- package/dist/cli/capabilityContext/evidence.js +469 -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 +128 -0
- package/dist/cli/capabilityContext/orchestration.js.map +1 -0
- package/dist/cli/capabilityContext/planState.js +280 -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 +100 -0
- package/dist/cli/capabilityContext/shared.js.map +1 -0
- package/dist/cli/capabilityContext/slim.js +153 -0
- package/dist/cli/capabilityContext/slim.js.map +1 -0
- package/dist/cli/capabilityContext/startup.js +257 -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/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 +59 -97
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/durability.js +82 -0
- package/dist/cli/commands/durability.js.map +1 -0
- package/dist/cli/commands/entityMigrate.js +132 -0
- package/dist/cli/commands/entityMigrate.js.map +1 -0
- package/dist/cli/commands/lint.js +26 -43
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/prime/briefOrientation.js +592 -0
- package/dist/cli/commands/prime/briefOrientation.js.map +1 -0
- package/dist/cli/commands/prime/bundleStatus.js +191 -0
- package/dist/cli/commands/prime/bundleStatus.js.map +1 -0
- package/dist/cli/commands/prime/collectEntityOrientation.js +266 -0
- package/dist/cli/commands/prime/collectEntityOrientation.js.map +1 -0
- package/dist/cli/commands/prime/collectOrientationState.js +180 -0
- package/dist/cli/commands/prime/collectOrientationState.js.map +1 -0
- package/dist/cli/commands/prime/orientationOutput.js +360 -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 +61 -556
- package/dist/cli/commands/prime.js.map +1 -1
- package/dist/cli/commands/query.js +66 -51
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/report.js +100 -24
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/route.js.map +1 -0
- package/dist/cli/commands/schema.js +260 -78
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/state/decisions.js +388 -0
- package/dist/cli/commands/state/decisions.js.map +1 -0
- package/dist/cli/commands/state/docs.js +71 -0
- package/dist/cli/commands/state/docs.js.map +1 -0
- package/dist/cli/commands/state/experimentRecords.js +139 -0
- package/dist/cli/commands/state/experimentRecords.js.map +1 -0
- package/dist/cli/commands/state/experiments.js +15 -0
- package/dist/cli/commands/state/experiments.js.map +1 -0
- package/dist/cli/commands/state/get.js +127 -0
- package/dist/cli/commands/state/get.js.map +1 -0
- package/dist/cli/commands/state/health.js +15 -0
- package/dist/cli/commands/state/health.js.map +1 -0
- package/dist/cli/commands/state/index.js +60 -0
- package/dist/cli/commands/state/index.js.map +1 -0
- package/dist/cli/commands/state/list.js +176 -0
- package/dist/cli/commands/state/list.js.map +1 -0
- package/dist/cli/commands/state/objective.js +26 -0
- package/dist/cli/commands/state/objective.js.map +1 -0
- package/dist/cli/commands/state/plan.js +15 -0
- package/dist/cli/commands/state/plan.js.map +1 -0
- package/dist/cli/commands/state/planTasks.js +142 -0
- package/dist/cli/commands/state/planTasks.js.map +1 -0
- package/dist/cli/commands/state/plans.js +143 -0
- package/dist/cli/commands/state/plans.js.map +1 -0
- package/dist/cli/commands/state/progress.js +14 -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 +42 -0
- package/dist/cli/commands/state/todo.js.map +1 -0
- package/dist/cli/commands/state/write.js +418 -0
- package/dist/cli/commands/state/write.js.map +1 -0
- package/dist/cli/commands/upgrade.js +146 -4
- package/dist/cli/commands/upgrade.js.map +1 -1
- package/dist/cli/commands/upgradeVerify.js +119 -0
- package/dist/cli/commands/upgradeVerify.js.map +1 -0
- package/dist/cli/commands/validate.js +133 -210
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/commands/verify.js +30 -8
- 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 +390 -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 +226 -0
- package/dist/cli/dispatch/index.js.map +1 -0
- package/dist/cli/dispatch/lifecycle.js +653 -0
- package/dist/cli/dispatch/lifecycle.js.map +1 -0
- package/dist/cli/dispatch/prime.js +119 -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 +174 -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 +419 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/migrationRequired.js +87 -0
- package/dist/cli/migrationRequired.js.map +1 -0
- package/dist/cli/orientation/attention.js +67 -0
- package/dist/cli/orientation/attention.js.map +1 -0
- package/dist/cli/orientation/corpusCoverage.js +103 -0
- package/dist/cli/orientation/corpusCoverage.js.map +1 -0
- package/dist/cli/orientation.js +407 -159
- package/dist/cli/orientation.js.map +1 -1
- package/dist/cli/planArtifacts.js +351 -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/planTaskIndex.js +12 -0
- package/dist/cli/planTaskIndex.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 +63 -10
- package/dist/cli/stateQuery.js.map +1 -1
- package/dist/cli/structured.js.map +1 -1
- package/dist/cli/todoMarkdown.js +33 -0
- package/dist/cli/todoMarkdown.js.map +1 -0
- package/dist/cli/todoReadinessSelection.js +157 -0
- package/dist/cli/todoReadinessSelection.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/difflib.js.map +1 -1
- 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/paths.js.map +1 -1
- package/dist/core/pyjson.js +67 -2
- package/dist/core/pyjson.js.map +1 -1
- package/dist/core/skillIdentity.js +24 -0
- package/dist/core/skillIdentity.js.map +1 -0
- package/dist/core/sourceRoot.js.map +1 -1
- package/dist/core/text.js +11 -0
- package/dist/core/text.js.map +1 -0
- package/dist/core/toml.js.map +1 -1
- 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/hybridRouteEvaluation.js +156 -0
- package/dist/eval/hybridRouteEvaluation.js.map +1 -0
- 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 +10 -27
- 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 +361 -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 +14 -21
- package/dist/hooks/cursorSessionStart.js.map +1 -1
- package/dist/hooks/projectHookInput.js +26 -0
- package/dist/hooks/projectHookInput.js.map +1 -0
- package/dist/hooks/sessionStart.js +55 -170
- package/dist/hooks/sessionStart.js.map +1 -1
- package/dist/hooks/sessionStop.js +12 -26
- 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 +222 -62
- package/dist/registries/artifactRegistry.js.map +1 -1
- package/dist/registries/capabilityContract.js +141 -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/evidenceTierContract.js +362 -0
- package/dist/registries/evidenceTierContract.js.map +1 -0
- package/dist/registries/hybridRoute.js +203 -0
- package/dist/registries/hybridRoute.js.map +1 -0
- package/dist/registries/hybridRouteReceipt.js +221 -0
- package/dist/registries/hybridRouteReceipt.js.map +1 -0
- package/dist/registries/packageRegistry.js +90 -230
- package/dist/registries/packageRegistry.js.map +1 -1
- package/dist/registries/todoReadinessContract.js +406 -0
- package/dist/registries/todoReadinessContract.js.map +1 -0
- package/dist/registries/triggerLoader.js +175 -0
- package/dist/registries/triggerLoader.js.map +1 -0
- package/dist/registries/verbosityBudgetContract.js +206 -0
- package/dist/registries/verbosityBudgetContract.js.map +1 -0
- package/dist/release/releaseMetadata.js +319 -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 +778 -0
- package/dist/runtime/lifecycleAdapters.js.map +1 -0
- package/dist/runtime/lifecycleAuthority.js +454 -0
- package/dist/runtime/lifecycleAuthority.js.map +1 -0
- package/dist/runtime/lifecycleOperationContract.js +114 -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 +416 -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/nativeResourceCleanup.js +317 -0
- package/dist/runtime/nativeResourceCleanup.js.map +1 -0
- package/dist/setup/codex/cli.js +130 -0
- package/dist/setup/codex/cli.js.map +1 -0
- package/dist/setup/codex/configToml.js +558 -0
- package/dist/setup/codex/configToml.js.map +1 -0
- package/dist/setup/codex/constants.js +14 -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 +252 -0
- package/dist/setup/codex/state.js.map +1 -0
- package/dist/setup/codex.js +9 -1055
- package/dist/setup/codex.js.map +1 -1
- package/dist/setup/opencode.js +21 -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/sharedSkill.js +46 -0
- package/dist/setup/sharedSkill.js.map +1 -0
- package/dist/setup/smokeChecks.js +82 -0
- package/dist/setup/smokeChecks.js.map +1 -0
- package/dist/state/archiveDiscovery.js +578 -0
- package/dist/state/archiveDiscovery.js.map +1 -0
- package/dist/state/archivePublication.js +226 -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/canonicalMigrationRecord.js +37 -0
- package/dist/state/canonicalMigrationRecord.js.map +1 -0
- package/dist/state/decisionEntities.js +322 -0
- package/dist/state/decisionEntities.js.map +1 -0
- package/dist/state/decisionLegacyValidation.js +216 -0
- package/dist/state/decisionLegacyValidation.js.map +1 -0
- package/dist/state/decisionMigrationProvenance.js +117 -0
- package/dist/state/decisionMigrationProvenance.js.map +1 -0
- package/dist/state/decisionOverlay.js +278 -0
- package/dist/state/decisionOverlay.js.map +1 -0
- package/dist/state/decisionRevision.js +632 -0
- package/dist/state/decisionRevision.js.map +1 -0
- package/dist/state/decisionRevisionPublication.js +532 -0
- package/dist/state/decisionRevisionPublication.js.map +1 -0
- package/dist/state/directRetrieval.js +373 -0
- package/dist/state/directRetrieval.js.map +1 -0
- package/dist/state/durability.js +325 -0
- package/dist/state/durability.js.map +1 -0
- package/dist/state/entityCutover.js +294 -0
- package/dist/state/entityCutover.js.map +1 -0
- package/dist/state/entityCutoverGit.js +128 -0
- package/dist/state/entityCutoverGit.js.map +1 -0
- package/dist/state/entityMigrationCausality.js +99 -0
- package/dist/state/entityMigrationCausality.js.map +1 -0
- package/dist/state/entityMigrationPreview.js +864 -0
- package/dist/state/entityMigrationPreview.js.map +1 -0
- package/dist/state/entityPublicationContext.js +662 -0
- package/dist/state/entityPublicationContext.js.map +1 -0
- package/dist/state/entityStorage.js +881 -0
- package/dist/state/entityStorage.js.map +1 -0
- package/dist/state/experimentArchive.js +64 -0
- package/dist/state/experimentArchive.js.map +1 -0
- package/dist/state/experimentIdentity.js +203 -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/healthEntities.js +266 -0
- package/dist/state/healthEntities.js.map +1 -0
- package/dist/state/healthEntityValidation.js +19 -0
- package/dist/state/healthEntityValidation.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/legacyEntityCutoverEvidence.js +66 -0
- package/dist/state/legacyEntityCutoverEvidence.js.map +1 -0
- package/dist/state/legacyIdentity.js +48 -0
- package/dist/state/legacyIdentity.js.map +1 -0
- package/dist/state/legacySummaryRecord.js +7 -0
- package/dist/state/legacySummaryRecord.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/listCursor.js +43 -0
- package/dist/state/listCursor.js.map +1 -0
- package/dist/state/listRetrieval.js +813 -0
- package/dist/state/listRetrieval.js.map +1 -0
- package/dist/state/migrationSourceBinding.js +31 -0
- package/dist/state/migrationSourceBinding.js.map +1 -0
- package/dist/state/objectiveExperimentEntities.js +323 -0
- package/dist/state/objectiveExperimentEntities.js.map +1 -0
- package/dist/state/planEntities.js +444 -0
- package/dist/state/planEntities.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/progressEntities.js +360 -0
- package/dist/state/progressEntities.js.map +1 -0
- package/dist/state/projectRoot.js +63 -0
- package/dist/state/projectRoot.js.map +1 -0
- package/dist/state/projectionPolicy.js +184 -0
- package/dist/state/projectionPolicy.js.map +1 -0
- package/dist/state/retrievalAuthority.js +343 -0
- package/dist/state/retrievalAuthority.js.map +1 -0
- package/dist/state/safeProjectFile.js +153 -0
- package/dist/state/safeProjectFile.js.map +1 -0
- package/dist/state/startupAnalysis/benchmark.js +433 -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 +513 -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 +567 -0
- package/dist/state/startupProjection.js.map +1 -0
- package/dist/state/stateMode.js +83 -0
- package/dist/state/stateMode.js.map +1 -0
- package/dist/state/summaryEntityRead.js +26 -0
- package/dist/state/summaryEntityRead.js.map +1 -0
- package/dist/state/summaryMigrationProvenance.js +67 -0
- package/dist/state/summaryMigrationProvenance.js.map +1 -0
- package/dist/state/summarySourceRowAuthority.js +37 -0
- package/dist/state/summarySourceRowAuthority.js.map +1 -0
- package/dist/state/todoDocsEntities.js +267 -0
- package/dist/state/todoDocsEntities.js.map +1 -0
- package/dist/state/todoDocsEntityValidation.js +34 -0
- package/dist/state/todoDocsEntityValidation.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/candidateMutation.js +281 -0
- package/dist/state/write/candidateMutation.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 +303 -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 +30 -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 +838 -0
- package/dist/state/write/lock.js.map +1 -0
- package/dist/state/write/mutation.js +235 -0
- package/dist/state/write/mutation.js.map +1 -0
- package/dist/state/write/operations.js +375 -0
- package/dist/state/write/operations.js.map +1 -0
- package/dist/state/write/planEvaluation.js +121 -0
- package/dist/state/write/planEvaluation.js.map +1 -0
- package/dist/state/write/planPublication.js +135 -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 +44 -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 +384 -0
- package/dist/upgrade/appContentRefresh.js.map +1 -0
- package/dist/upgrade/appModel.js +8 -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 +21 -10
- 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 +56 -20
- package/dist/upgrade/compatibility.js.map +1 -1
- package/dist/upgrade/doctor.js +197 -191
- 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 +197 -0
- package/dist/upgrade/installedHooksRetirement.js.map +1 -0
- package/dist/upgrade/legacyAgentCleanup.js +283 -0
- package/dist/upgrade/legacyAgentCleanup.js.map +1 -0
- package/dist/upgrade/lifecycleUpgrade.js +114 -0
- package/dist/upgrade/lifecycleUpgrade.js.map +1 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +363 -137
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
- package/dist/upgrade/migrationPublication.js +123 -0
- package/dist/upgrade/migrationPublication.js.map +1 -0
- 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 +142 -171
- package/dist/upgrade/projectIntegration.js.map +1 -1
- package/dist/upgrade/projectIntegrationDecision.js +51 -0
- package/dist/upgrade/projectIntegrationDecision.js.map +1 -0
- package/dist/upgrade/runtimeMigration.js +336 -281
- package/dist/upgrade/runtimeMigration.js.map +1 -1
- package/dist/upgrade/upgradeCommands.js +9 -0
- package/dist/upgrade/upgradeCommands.js.map +1 -1
- package/dist/upgrade/upgradeLock.js +86 -0
- package/dist/upgrade/upgradeLock.js.map +1 -0
- package/dist/upgrade/upgradeOrchestrator.js +212 -56
- package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
- 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 -9
- package/dist/validate/appHomeContract.js.map +1 -1
- package/dist/validate/capability.js +144 -14
- package/dist/validate/capability.js.map +1 -1
- package/dist/validate/crossCapability.js +12 -9
- package/dist/validate/crossCapability.js.map +1 -1
- package/dist/validate/selfAudit.js +73 -36
- 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 +45 -27
- package/bundle/references/adapters/cursor.md +0 -213
- package/bundle/references/adapters/opencode.md +0 -530
- package/bundle/references/adapters/runtime-adapter-characterization.md +0 -79
- package/bundle/references/adapters/runtime-adapter-interface-model.yaml +0 -200
- package/bundle/references/adapters/runtime-adapter-registry.yaml +0 -548
- package/bundle/references/adapters/runtime-feature-parity.md +0 -189
- 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/dokumentera/schemas/artifacts.yaml +0 -73
- package/bundle/skills/agentera/capabilities/dokumentera/schemas/triggers.yaml +0 -35
- package/bundle/skills/agentera/capabilities/hej/instructions.md +0 -331
- package/bundle/skills/agentera/capabilities/hej/schemas/artifacts.yaml +0 -69
- package/bundle/skills/agentera/capabilities/hej/schemas/triggers.yaml +0 -58
- 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/inspektera/schemas/triggers.yaml +0 -38
- 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/inspirera/schemas/triggers.yaml +0 -34
- package/bundle/skills/agentera/capabilities/optimera/instructions.md +0 -437
- package/bundle/skills/agentera/capabilities/optimera/schemas/triggers.yaml +0 -39
- 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/triggers.yaml +0 -42
- 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/triggers.yaml +0 -34
- 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/profilera/schemas/triggers.yaml +0 -45
- package/bundle/skills/agentera/capabilities/profilera/schemas/validation.yaml +0 -57
- package/bundle/skills/agentera/capabilities/realisera/instructions.md +0 -403
- package/bundle/skills/agentera/capabilities/realisera/schemas/artifacts.yaml +0 -80
- package/bundle/skills/agentera/capabilities/realisera/schemas/triggers.yaml +0 -39
- 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/resonera/schemas/triggers.yaml +0 -46
- package/bundle/skills/agentera/capabilities/visionera/instructions.md +0 -309
- package/bundle/skills/agentera/capabilities/visionera/schemas/triggers.yaml +0 -41
- package/bundle/skills/agentera/capabilities/visualisera/instructions.md +0 -400
- package/bundle/skills/agentera/capabilities/visualisera/schemas/triggers.yaml +0 -33
- 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/backfill.js +0 -84
- package/dist/cli/commands/backfill.js.map +0 -1
- 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/registries/runtimeAdapterRegistry.js +0 -315
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/setup/copilot.js +0 -227
- package/dist/setup/copilot.js.map +0 -1
- package/dist/setup/cursor.js +0 -127
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/doctor.js +0 -1276
- package/dist/setup/doctor.js.map +0 -1
- package/dist/state/progressCommit.js +0 -289
- package/dist/state/progressCommit.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV1ToV2.js +0 -571
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
- package/dist/validate/lifecycleAdapters.js +0 -772
- package/dist/validate/lifecycleAdapters.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,864 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
import { resolveSourceRoot } from "../core/sourceRoot.js";
|
|
6
|
+
import { loadYamlMapping } from "../core/yaml.js";
|
|
7
|
+
import { discoverPlanArtifacts, planDocumentParts } from "../cli/planArtifacts.js";
|
|
8
|
+
import { parseTodoMarkdownListItem } from "../cli/todoMarkdown.js";
|
|
9
|
+
import { assertRealpathBoundary, docsPathOverridesFromBytes, loadArtifactRecord, resolveArtifactPath } from "../registries/artifactRegistry.js";
|
|
10
|
+
import { canonicalRecordJson, validateStateRecord } from "./archiveDiscovery.js";
|
|
11
|
+
import { canonicalEntityEnvelopeBytes, entityForbiddenCanonicalAliases, entityPreservedAggregateCollections, validateCanonicalEntityTargets } from "./entityStorage.js";
|
|
12
|
+
import { discoverObjectiveArtifacts, inspectExperimentIdentities } from "./experimentIdentity.js";
|
|
13
|
+
import { decisionRevisionContract, decisionRevisionViolations } from "./decisionRevision.js";
|
|
14
|
+
import { classifyCompleteDecisionConfidence, decisionLegacyCoexistence } from "./decisionLegacyValidation.js";
|
|
15
|
+
import { assertValidatedProjectRoot, validateRealProjectRoot } from "./projectRoot.js";
|
|
16
|
+
import { todoDocsRecordViolations } from "./todoDocsEntityValidation.js";
|
|
17
|
+
import { yamlArchiveEntry } from "../hooks/compaction/retention.js";
|
|
18
|
+
import { truncateWords } from "../hooks/compaction/dryRun.js";
|
|
19
|
+
import { legacyIdentity } from "./legacyIdentity.js";
|
|
20
|
+
import { canonicalMigrationRecord } from "./canonicalMigrationRecord.js";
|
|
21
|
+
import { legacySummaryRecord } from "./legacySummaryRecord.js";
|
|
22
|
+
import { applyCausalBlockers } from "./entityMigrationCausality.js";
|
|
23
|
+
import { projectPathIsStable as migrationPathIsStable, readProjectFileSnapshot, resolveProjectDescriptorPath, snapshotProjectPath as snapshotMigrationPath, } from "./safeProjectFile.js";
|
|
24
|
+
export const ENTITY_MIGRATION_PREVIEW_MAX_OUTPUT_BYTES = 32_768;
|
|
25
|
+
const DEFAULT_LIMIT = 100;
|
|
26
|
+
const MAX_LIMIT = 1000;
|
|
27
|
+
const NUMBERED = {
|
|
28
|
+
progress: { file: ".agentera/progress.yaml", collection: "cycles", boundary: "progress_cycle" },
|
|
29
|
+
decisions: { file: ".agentera/decisions.yaml", collection: "decisions", boundary: "decision" },
|
|
30
|
+
health: { file: ".agentera/health.yaml", collection: "audits", boundary: "health_audit" },
|
|
31
|
+
};
|
|
32
|
+
const COMPACTED_SUMMARY_ARTIFACTS = new Set(["progress", "decisions", "health"]);
|
|
33
|
+
const BLOCKING = new Set(["duplicate", "conflict", "corrupt", "unsupported"]);
|
|
34
|
+
const INVENTORY_ORDER = "artifact_then_boundary_then_source_identity_then_source_path";
|
|
35
|
+
const INVENTORY_FILTER = "complete_declared_inventory";
|
|
36
|
+
const AUTHORITY_PATH = "references/artifacts/state-storage-authority.yaml";
|
|
37
|
+
const PLAN_ARCHIVE_SOURCE = /^\.agentera\/archive\/PLAN-[^/]+\.ya?ml$/i;
|
|
38
|
+
function mapping(value) {
|
|
39
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
40
|
+
}
|
|
41
|
+
function hash(value) {
|
|
42
|
+
return createHash("sha256").update(value).digest("hex");
|
|
43
|
+
}
|
|
44
|
+
function completeRecordAssessment(sourceRoot, artifact, record, source, sourcePath) {
|
|
45
|
+
if (artifact !== "decisions") {
|
|
46
|
+
const violations = validateStateRecord(sourceRoot, artifact, record);
|
|
47
|
+
return { valid: violations.length === 0, violations };
|
|
48
|
+
}
|
|
49
|
+
const assessment = classifyCompleteDecisionConfidence(record, decisionLegacyCoexistence(sourceRoot), (candidate) => validateStateRecord(sourceRoot, artifact, candidate), source);
|
|
50
|
+
return {
|
|
51
|
+
valid: assessment.status !== "invalid",
|
|
52
|
+
violations: assessment.violations,
|
|
53
|
+
...(assessment.status === "inherited" ? { inheritedConfidenceProvenance: {
|
|
54
|
+
kind: "inherited_decision_confidence",
|
|
55
|
+
source: source === "active" ? "current_projection" : "verified_archive",
|
|
56
|
+
source_path: sourcePath,
|
|
57
|
+
source_record_sha256: hash(canonicalRecordJson(record)),
|
|
58
|
+
confidence: record.confidence,
|
|
59
|
+
} } : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function relative(root, target) {
|
|
63
|
+
return path.relative(root, target).replaceAll(path.sep, "/");
|
|
64
|
+
}
|
|
65
|
+
/** Migration-only source seam: pin one project file to a verified descriptor. */
|
|
66
|
+
function readMigrationSource(root, relativePath, descriptorPathResolver) {
|
|
67
|
+
return { relative: relativePath, ...readProjectFileSnapshot(root, relativePath, descriptorPathResolver) };
|
|
68
|
+
}
|
|
69
|
+
function directoryFiles(root, validatedRoot, relativeRoot, accept, descriptorPathResolver) {
|
|
70
|
+
const absoluteRoot = path.join(root, relativeRoot);
|
|
71
|
+
const inventoryPath = (directory) => `${relative(root, directory).replace(/\/$/, "")}/`;
|
|
72
|
+
const visit = (directory, isRoot = false) => {
|
|
73
|
+
assertValidatedProjectRoot(validatedRoot);
|
|
74
|
+
const directorySnapshot = snapshotMigrationPath(root, relative(root, directory), "directory");
|
|
75
|
+
if (directorySnapshot.kind !== "stable") {
|
|
76
|
+
if (directorySnapshot.kind === "missing")
|
|
77
|
+
return isRoot ? { files: [], changed: null } : { files: [], changed: inventoryPath(directory) };
|
|
78
|
+
if (path.resolve(directorySnapshot.absolute) !== path.resolve(directory))
|
|
79
|
+
return { files: [], changed: inventoryPath(directory) };
|
|
80
|
+
if (directorySnapshot.reason === "symlink")
|
|
81
|
+
throw new Error(`inventory root '${directory}' is a symbolic link; replace it with a real directory inside project '${root}' and retry`);
|
|
82
|
+
if (directorySnapshot.reason === "type")
|
|
83
|
+
throw new Error(`inventory root '${directory}' is not a directory; replace it with a real directory inside project '${root}' and retry`);
|
|
84
|
+
throw new Error(`inventory root '${directory}' cannot be inspected inside project '${root}'; replace it with a readable real directory and retry`);
|
|
85
|
+
}
|
|
86
|
+
let entries;
|
|
87
|
+
try {
|
|
88
|
+
entries = fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new Error(`inventory root '${directory}' cannot be read inside project '${root}'; replace it with a readable real directory and retry`);
|
|
92
|
+
}
|
|
93
|
+
if (!migrationPathIsStable(directorySnapshot))
|
|
94
|
+
return { files: [], changed: inventoryPath(directory) };
|
|
95
|
+
const files = [];
|
|
96
|
+
for (const entry of entries) {
|
|
97
|
+
const absolute = path.join(directory, entry.name);
|
|
98
|
+
const candidate = relative(root, absolute);
|
|
99
|
+
if (accept(candidate)) {
|
|
100
|
+
files.push(readMigrationSource(validatedRoot, candidate, descriptorPathResolver));
|
|
101
|
+
}
|
|
102
|
+
else if (entry.isSymbolicLink()) {
|
|
103
|
+
throw new Error(`inventory root '${absolute}' is a symbolic link; replace it with a real directory or file inside project '${root}' and retry`);
|
|
104
|
+
}
|
|
105
|
+
else if (entry.isDirectory()) {
|
|
106
|
+
const nested = visit(absolute);
|
|
107
|
+
if (nested.changed)
|
|
108
|
+
return nested;
|
|
109
|
+
files.push(...nested.files);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
assertValidatedProjectRoot(validatedRoot);
|
|
113
|
+
if (!migrationPathIsStable(directorySnapshot))
|
|
114
|
+
return { files: [], changed: inventoryPath(directory) };
|
|
115
|
+
return { files, changed: null };
|
|
116
|
+
};
|
|
117
|
+
const enumeration = visit(absoluteRoot, true);
|
|
118
|
+
return enumeration.changed ? [{ relative: enumeration.changed, bytes: null, kind: "unsafe" }] : enumeration.files;
|
|
119
|
+
}
|
|
120
|
+
function collectSources(root, validatedRoot, todoPath, docsSnapshot, descriptorPathResolver) {
|
|
121
|
+
const exact = [
|
|
122
|
+
todoPath, "CHANGELOG.md", "DESIGN.md", ".agentera/vision.yaml", ".agentera/docs.yaml", ".agentera/progress.yaml", ".agentera/decisions.yaml", ".agentera/health.yaml", ".agentera/plan.yaml",
|
|
123
|
+
".agentera/overlays/decisions.yaml", ".agentera/revisions/decisions.yaml", ".agentera/archive/recovery/projection-correlation.yaml",
|
|
124
|
+
].map((candidate) => candidate === docsSnapshot.relative ? docsSnapshot : readMigrationSource(validatedRoot, candidate, descriptorPathResolver));
|
|
125
|
+
const archives = directoryFiles(root, validatedRoot, ".agentera/archive", (candidate) => /^\.agentera\/archive\/(progress|decisions|health)\/.+/.test(candidate)
|
|
126
|
+
|| PLAN_ARCHIVE_SOURCE.test(candidate), descriptorPathResolver);
|
|
127
|
+
const objectives = [".agentera/optimize", ".agentera/optimera"].flatMap((directory) => directoryFiles(root, validatedRoot, directory, (candidate) => /\/(objective|experiments)\.yaml$/.test(candidate), descriptorPathResolver));
|
|
128
|
+
const collected = [...exact, ...archives, ...objectives];
|
|
129
|
+
const missingRoots = [".agentera/archive/", ".agentera/optimize/", ".agentera/optimera/"]
|
|
130
|
+
.filter((directory) => {
|
|
131
|
+
if (collected.some((source) => source.kind === "unsafe" && source.relative === directory))
|
|
132
|
+
return false;
|
|
133
|
+
try {
|
|
134
|
+
return !fs.lstatSync(path.join(root, directory)).isDirectory();
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.map((directory) => ({ relative: directory, bytes: null, kind: "missing" }));
|
|
141
|
+
const byPath = new Map([...collected, ...missingRoots].map((source) => [source.relative, source]));
|
|
142
|
+
return [...byPath.values()].sort((a, b) => a.relative.localeCompare(b.relative));
|
|
143
|
+
}
|
|
144
|
+
function authorityBinding(sourceRoot) {
|
|
145
|
+
const authorityPath = path.join(sourceRoot, AUTHORITY_PATH);
|
|
146
|
+
const bytes = fs.readFileSync(authorityPath);
|
|
147
|
+
const authority = loadYamlMapping(bytes.toString("utf8"));
|
|
148
|
+
if (typeof authority.schema_version !== "string" || !mapping(authority.entity_migration)) {
|
|
149
|
+
throw new Error("active entity migration authority is missing its schema version or entity_migration contract");
|
|
150
|
+
}
|
|
151
|
+
return { authority_schema_version: authority.schema_version, authority_sha256: hash(bytes) };
|
|
152
|
+
}
|
|
153
|
+
export function entityMigrationAuthorityProjection(sourceRoot = resolveSourceRoot()) {
|
|
154
|
+
const authorityPath = path.join(sourceRoot, AUTHORITY_PATH);
|
|
155
|
+
const authority = loadYamlMapping(fs.readFileSync(authorityPath, "utf8"));
|
|
156
|
+
if (!mapping(authority.entity_migration))
|
|
157
|
+
throw new Error(`state storage authority '${authorityPath}' has no entity migration contract`);
|
|
158
|
+
return { authority: AUTHORITY_PATH, ...authority.entity_migration };
|
|
159
|
+
}
|
|
160
|
+
function sourceFingerprint(files) {
|
|
161
|
+
return hash(canonicalRecordJson(files.map((file) => ({
|
|
162
|
+
path: file.relative,
|
|
163
|
+
presence: file.kind,
|
|
164
|
+
size: file.bytes?.byteLength ?? 0,
|
|
165
|
+
sha256: file.bytes ? hash(file.bytes) : null,
|
|
166
|
+
mode: file.kind === "file" ? file.mode : null,
|
|
167
|
+
dev: file.kind === "file" ? String(file.dev) : null,
|
|
168
|
+
ino: file.kind === "file" ? String(file.ino) : null,
|
|
169
|
+
type: file.kind === "file" ? file.type : null,
|
|
170
|
+
}))));
|
|
171
|
+
}
|
|
172
|
+
function parseYaml(source) {
|
|
173
|
+
if (source.kind !== "file" || !source.bytes)
|
|
174
|
+
throw new Error(source.kind === "unsafe" ? "source path is a symbolic link or non-file" : "source is missing");
|
|
175
|
+
return loadYamlMapping(source.bytes.toString("utf8"));
|
|
176
|
+
}
|
|
177
|
+
function recovery(project, pathName) {
|
|
178
|
+
return `Repair '${pathName}', then run agentera state migrate entities --project '${project.replaceAll("'", "'\\''")}' --dry-run --format json.`;
|
|
179
|
+
}
|
|
180
|
+
function unsafeSourceMessage(pathName) {
|
|
181
|
+
return `source path '${pathName}' is a symbolic link, non-file, or unreadable; replace it with a readable regular file inside the project`;
|
|
182
|
+
}
|
|
183
|
+
function inventoryFailureObservations(files, observations) {
|
|
184
|
+
for (const source of files.filter((candidate) => candidate.kind === "unsafe" && candidate.relative.endsWith("/"))) {
|
|
185
|
+
observations.push({
|
|
186
|
+
key: `migration_inventory:${source.relative}`,
|
|
187
|
+
artifact: "state",
|
|
188
|
+
boundary: "migration_inventory",
|
|
189
|
+
path: source.relative,
|
|
190
|
+
provenance: "source_inventory",
|
|
191
|
+
record: null,
|
|
192
|
+
detail: "corrupt",
|
|
193
|
+
relationships: [],
|
|
194
|
+
message: `inventory directory '${source.relative}' changed while it was enumerated; no candidate names were accepted`,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function numberedObservations(root, sourceRoot, files, observations, aggregateCollections) {
|
|
199
|
+
const correlationSource = files.find((source) => source.relative === ".agentera/archive/recovery/projection-correlation.yaml");
|
|
200
|
+
let correlationManifest = null;
|
|
201
|
+
if (correlationSource?.kind === "file") {
|
|
202
|
+
try {
|
|
203
|
+
const manifest = parseYaml(correlationSource);
|
|
204
|
+
const entries = Array.isArray(manifest.entries) ? manifest.entries.map(mapping) : [];
|
|
205
|
+
const validEntries = entries.filter((entry) => Boolean(entry));
|
|
206
|
+
const digest = hash(canonicalRecordJson({ schemaVersion: "agentera.projectionCorrelationSet.v1", entries: validEntries }));
|
|
207
|
+
if (manifest.schemaVersion !== "agentera.projectionCorrelationManifest.v1" || manifest.recovery_set_digest !== digest || validEntries.length !== entries.length)
|
|
208
|
+
throw new Error("projection correlation manifest schema or digest is invalid");
|
|
209
|
+
correlationManifest = new Map(validEntries.map((entry) => [String(entry.identity), entry]));
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
observations.push({ key: "projection_correlation:manifest", artifact: "state", boundary: "migration_inventory", path: correlationSource.relative, provenance: "source_inventory", record: null, detail: "corrupt", relationships: [], message: error.message });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else if (correlationSource?.kind === "unsafe") {
|
|
216
|
+
observations.push({ key: "projection_correlation:manifest", artifact: "state", boundary: "migration_inventory", path: correlationSource.relative, provenance: "source_inventory", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(correlationSource.relative) });
|
|
217
|
+
}
|
|
218
|
+
for (const [artifact, declaration] of Object.entries(NUMBERED)) {
|
|
219
|
+
const current = files.find((source) => source.relative === declaration.file);
|
|
220
|
+
if (current?.kind === "file") {
|
|
221
|
+
try {
|
|
222
|
+
const document = parseYaml(current);
|
|
223
|
+
const allowedCollections = new Set(aggregateCollections[declaration.file] ?? []);
|
|
224
|
+
for (const field of Object.keys(document).filter((field) => Array.isArray(document[field]) && !allowedCollections.has(field)).sort()) {
|
|
225
|
+
observations.push({ key: `${artifact}:undeclared_collection:${field}`, artifact, boundary: "migration_inventory", path: declaration.file, provenance: "source_inventory", record: null, detail: "corrupt", relationships: [], message: `aggregate collection '${field}' is not declared for '${declaration.file}' by the state storage authority` });
|
|
226
|
+
}
|
|
227
|
+
const currentValues = document[declaration.collection];
|
|
228
|
+
if (!Array.isArray(currentValues))
|
|
229
|
+
throw new Error(`field '${declaration.collection}' must be a list`);
|
|
230
|
+
const collections = [[declaration.collection, currentValues]];
|
|
231
|
+
if (Array.isArray(document.archive))
|
|
232
|
+
collections.push(["archive", document.archive]);
|
|
233
|
+
collections.flatMap(([collection, values]) => values.map((value, index) => ({ collection, value, index }))).forEach(({ collection, value, index }) => {
|
|
234
|
+
const record = legacySummaryRecord(value);
|
|
235
|
+
const identity = legacyIdentity(record, artifact, "number");
|
|
236
|
+
const number = identity.number;
|
|
237
|
+
const key = number ? `${artifact}:${number}` : `${artifact}:${collection}[${index}]`;
|
|
238
|
+
const assessment = record && typeof record.number === "number"
|
|
239
|
+
? completeRecordAssessment(sourceRoot, artifact, record, "active", declaration.file)
|
|
240
|
+
: { valid: false, violations: ["record number is required"] };
|
|
241
|
+
const valid = assessment.valid;
|
|
242
|
+
const summary = Boolean(record && (typeof record.summary === "string" || record.detail_availability === "summary_only"));
|
|
243
|
+
const text = typeof record?.summary === "string" ? record.summary : "";
|
|
244
|
+
const decisionRefs = artifact === "decisions" ? [...text.matchAll(/\bD([1-9][0-9]*)\b/g)] : [];
|
|
245
|
+
const residue = artifact === "decisions" && decisionRefs.length > 1 && !number;
|
|
246
|
+
observations.push({ key: residue ? `historical_projection_residue:${declaration.file}:${collection}[${index}]` : key, artifact, boundary: residue ? "historical_projection_residue" : declaration.boundary, path: declaration.file, provenance: residue ? "historical_projection_residue" : "current_projection", record, detail: valid ? "full" : summary ? "summary" : "corrupt", relationships: [], sourceRecordSha256: hash(canonicalRecordJson(value)), message: valid || summary ? undefined : "projection record does not satisfy the declared full-detail schema", ...(assessment.inheritedConfidenceProvenance ? { inheritedConfidenceProvenance: assessment.inheritedConfidenceProvenance } : {}), ...(residue ? { migrationProvenance: { classification: "historical_projection_residue", path: declaration.file, collection, index, content_sha256: hash(canonicalRecordJson(record)), text, inbound_structured_references: 0 } } : {}) });
|
|
247
|
+
if (artifact === "decisions" && valid && mapping(record?.satisfaction)) {
|
|
248
|
+
observations.push({ key: `decision_satisfaction:${key}`, artifact: "decisions", boundary: "decision_satisfaction", path: declaration.file, provenance: "current_projection", record: mapping(record?.satisfaction), detail: "full", relationships: [{ field: "decision", target: key }] });
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
observations.push({ key: `${artifact}:projection`, artifact, boundary: declaration.boundary, path: declaration.file, provenance: "current_projection", record: null, detail: "corrupt", relationships: [], message: error.message });
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
else if (current?.kind === "unsafe") {
|
|
257
|
+
observations.push({ key: `${artifact}:projection`, artifact, boundary: declaration.boundary, path: declaration.file, provenance: "current_projection", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(declaration.file) });
|
|
258
|
+
}
|
|
259
|
+
for (const source of files.filter((candidate) => candidate.relative.startsWith(`.agentera/archive/${artifact}/`))) {
|
|
260
|
+
const match = new RegExp(`^\\.agentera/archive/${artifact}/([1-9][0-9]*)\\.yaml$`).exec(source.relative);
|
|
261
|
+
if (!match) {
|
|
262
|
+
observations.push({ key: `unsupported:${source.relative}`, artifact, boundary: declaration.boundary, path: source.relative, provenance: "archive", record: null, detail: "corrupt", relationships: [], message: "unsupported archive candidate name" });
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
const key = `${artifact}:${match[1]}`;
|
|
266
|
+
try {
|
|
267
|
+
const envelope = parseYaml(source);
|
|
268
|
+
const record = mapping(envelope.record);
|
|
269
|
+
if (!record || envelope.artifact_id !== artifact || envelope.entry_number !== Number(match[1]))
|
|
270
|
+
throw new Error("archive envelope identity does not match its path");
|
|
271
|
+
const expected = hash(canonicalRecordJson(record));
|
|
272
|
+
if (envelope.record_sha256 !== expected)
|
|
273
|
+
throw new Error("archive record_sha256 does not match record bytes");
|
|
274
|
+
if (mapping(envelope.recovery_provenance)) {
|
|
275
|
+
const correlation = correlationManifest?.get(key);
|
|
276
|
+
if (!correlation)
|
|
277
|
+
throw new Error("recovered archive is absent from the immutable projection correlation manifest");
|
|
278
|
+
if (correlation.artifact !== artifact || correlation.identity !== key || correlation.archive_sha256 !== hash(source.bytes)
|
|
279
|
+
|| mapping(correlation.overlay)?.final_record_sha256 !== expected)
|
|
280
|
+
throw new Error("recovered archive does not match its immutable projection correlation manifest entry");
|
|
281
|
+
}
|
|
282
|
+
const assessment = completeRecordAssessment(sourceRoot, artifact, record, "archive", source.relative);
|
|
283
|
+
if (!assessment.valid)
|
|
284
|
+
throw new Error(`archive record is invalid: ${assessment.violations.join("; ")}`);
|
|
285
|
+
observations.push({ key, artifact, boundary: declaration.boundary, path: source.relative, provenance: "verified_archive", record, detail: "full", relationships: [], ...(assessment.inheritedConfidenceProvenance ? { inheritedConfidenceProvenance: assessment.inheritedConfidenceProvenance } : {}), ...(mapping(envelope.recovery_provenance) ? { migrationProvenance: mapping(envelope.recovery_provenance) } : {}) });
|
|
286
|
+
if (artifact === "decisions" && mapping(record.satisfaction)) {
|
|
287
|
+
observations.push({
|
|
288
|
+
key: `decision_satisfaction:${key}`,
|
|
289
|
+
artifact: "decisions",
|
|
290
|
+
boundary: "decision_satisfaction",
|
|
291
|
+
path: source.relative,
|
|
292
|
+
provenance: "verified_archive",
|
|
293
|
+
record: mapping(record.satisfaction),
|
|
294
|
+
detail: "full",
|
|
295
|
+
relationships: [{ field: "decision", target: key }],
|
|
296
|
+
...(mapping(envelope.recovery_provenance) ? { migrationProvenance: { kind: "nested_verified_archive_evidence", source: mapping(envelope.recovery_provenance) } } : {}),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
observations.push({ key, artifact, boundary: declaration.boundary, path: source.relative, provenance: "archive", record: null, detail: "corrupt", relationships: [], message: error.message });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function decisionEvidence(sourceRoot, files, observations) {
|
|
307
|
+
const overlay = files.find((source) => source.relative === ".agentera/overlays/decisions.yaml");
|
|
308
|
+
if (overlay?.kind === "file") {
|
|
309
|
+
try {
|
|
310
|
+
const document = parseYaml(overlay);
|
|
311
|
+
for (const [identity, value] of Object.entries(document).sort(([a], [b]) => a.localeCompare(b))) {
|
|
312
|
+
const record = mapping(value);
|
|
313
|
+
const match = /^decisions:([1-9][0-9]*)$/.exec(identity);
|
|
314
|
+
const satisfaction = mapping(record?.satisfaction);
|
|
315
|
+
observations.push({ key: `decision_satisfaction:${identity}`, artifact: "decisions", boundary: "decision_satisfaction", path: overlay.relative, provenance: "overlay", record: satisfaction, detail: match && satisfaction ? "full" : "corrupt", relationships: [{ field: "decision", target: match ? `decisions:${match[1]}` : null }], message: match && satisfaction ? undefined : "decision satisfaction overlay has an unsupported identity or shape" });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
catch (error) {
|
|
319
|
+
observations.push({ key: "decision_satisfaction:overlay", artifact: "decisions", boundary: "decision_satisfaction", path: overlay.relative, provenance: "overlay", record: null, detail: "corrupt", relationships: [{ field: "decision", target: null }], message: error.message });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (overlay?.kind === "unsafe") {
|
|
323
|
+
observations.push({ key: "decision_satisfaction:overlay", artifact: "decisions", boundary: "decision_satisfaction", path: overlay.relative, provenance: "overlay", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(overlay.relative) });
|
|
324
|
+
}
|
|
325
|
+
const revisions = files.find((source) => source.relative === ".agentera/revisions/decisions.yaml");
|
|
326
|
+
if (revisions?.kind === "file") {
|
|
327
|
+
try {
|
|
328
|
+
const document = parseYaml(revisions);
|
|
329
|
+
const contract = decisionRevisionContract(sourceRoot);
|
|
330
|
+
for (const [identity, value] of Object.entries(document).sort(([left], [right]) => left.localeCompare(right))) {
|
|
331
|
+
const target = new RegExp(`^${contract.identityPrefix}:[1-9][0-9]*$`).test(identity) ? identity : null;
|
|
332
|
+
if (!Array.isArray(value)) {
|
|
333
|
+
observations.push({ key: `decision_revision:${identity}`, artifact: "decisions", boundary: "decision_revision", path: revisions.relative, provenance: "revision", record: null, detail: "corrupt", relationships: [{ field: "decision", target }], message: `${identity} must be an ordered list of revision records` });
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
value.forEach((candidate, index) => {
|
|
337
|
+
const record = mapping(candidate);
|
|
338
|
+
const violations = decisionRevisionViolations({ [identity]: [candidate] }, contract);
|
|
339
|
+
observations.push({ key: `decision_revision:${identity}:${index}`, artifact: "decisions", boundary: "decision_revision", path: revisions.relative, provenance: "revision", record, detail: record && violations.length === 0 ? "full" : "corrupt", relationships: [{ field: "decision", target }], message: violations.length === 0 ? undefined : violations.join("; ") });
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
observations.push({ key: "decision_revision:document", artifact: "decisions", boundary: "decision_revision", path: revisions.relative, provenance: "revision", record: null, detail: "corrupt", relationships: [{ field: "decision", target: null }], message: error.message });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (revisions?.kind === "unsafe") {
|
|
348
|
+
observations.push({ key: "decision_revision:document", artifact: "decisions", boundary: "decision_revision", path: revisions.relative, provenance: "revision", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(revisions.relative) });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function planObservations(root, files, observations) {
|
|
352
|
+
const active = path.join(root, ".agentera", "plan.yaml");
|
|
353
|
+
const activeSource = files.find((source) => source.relative === ".agentera/plan.yaml");
|
|
354
|
+
const archiveBytes = new Map(files.flatMap((source) => source.kind === "file" && PLAN_ARCHIVE_SOURCE.test(source.relative)
|
|
355
|
+
? [[path.join(root, source.relative), source.bytes]]
|
|
356
|
+
: []));
|
|
357
|
+
const discovery = discoverPlanArtifacts(active, {
|
|
358
|
+
activeBytes: activeSource?.kind === "file" ? activeSource.bytes : null,
|
|
359
|
+
archiveBytes,
|
|
360
|
+
});
|
|
361
|
+
const seen = new Set();
|
|
362
|
+
if (activeSource?.kind === "unsafe") {
|
|
363
|
+
observations.push({ key: "plan:document", artifact: "plan", boundary: "plan", path: activeSource.relative, provenance: "current_canonical", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(activeSource.relative) });
|
|
364
|
+
}
|
|
365
|
+
for (const identity of discovery.identities) {
|
|
366
|
+
const marker = `${identity.stableId}\0${identity.artifact.path}`;
|
|
367
|
+
if (seen.has(marker))
|
|
368
|
+
continue;
|
|
369
|
+
seen.add(marker);
|
|
370
|
+
const sourcePath = relative(root, identity.artifact.path);
|
|
371
|
+
const archived = identity.artifact.path !== active;
|
|
372
|
+
const source = files.find((candidate) => candidate.relative === sourcePath);
|
|
373
|
+
let sourceStatus = String((mapping(identity.artifact.data.header) ?? {}).status ?? "");
|
|
374
|
+
if (source?.kind === "file") {
|
|
375
|
+
const sourceDocument = parseYaml(source);
|
|
376
|
+
sourceStatus = String((mapping(sourceDocument.header) ?? {}).status ?? "");
|
|
377
|
+
}
|
|
378
|
+
const planRecord = structuredClone(identity.artifact.data);
|
|
379
|
+
const migratedHeader = mapping(planRecord.header);
|
|
380
|
+
if (archived && migratedHeader)
|
|
381
|
+
migratedHeader.status = "archived";
|
|
382
|
+
const migrationProvenance = archived ? {
|
|
383
|
+
...identity.artifact.migrationProvenance,
|
|
384
|
+
source_path: sourcePath,
|
|
385
|
+
source_lifecycle: "verified_plan_archive",
|
|
386
|
+
source_status: sourceStatus,
|
|
387
|
+
target_status: "archived",
|
|
388
|
+
} : identity.artifact.migrationProvenance ? { ...identity.artifact.migrationProvenance, source_path: sourcePath } : undefined;
|
|
389
|
+
const classificationDetail = identity.ambiguous ? "corrupt" : "full";
|
|
390
|
+
observations.push({ key: identity.stableId, artifact: "plan", boundary: "plan", path: sourcePath, provenance: archived ? "verified_plan_archive" : "current_canonical", record: planRecord, detail: classificationDetail, relationships: [], message: identity.ambiguous ? "plan identity resolves to conflicting documents" : undefined, ...(migrationProvenance ? { migrationProvenance } : {}) });
|
|
391
|
+
const parts = planDocumentParts(identity.artifact.data);
|
|
392
|
+
parts.tasks.forEach((task, index) => {
|
|
393
|
+
const number = task.number;
|
|
394
|
+
const taskKey = typeof number === "number" && Number.isSafeInteger(number) && number > 0 ? `${identity.stableId}/task:${number}` : `${identity.stableId}/task:index:${index}`;
|
|
395
|
+
const depends = Array.isArray(task.depends_on) ? task.depends_on : [];
|
|
396
|
+
observations.push({
|
|
397
|
+
key: taskKey,
|
|
398
|
+
artifact: "plan",
|
|
399
|
+
boundary: "plan_task",
|
|
400
|
+
path: sourcePath,
|
|
401
|
+
provenance: identity.artifact.path === active ? "current_canonical" : "verified_plan_archive",
|
|
402
|
+
record: task,
|
|
403
|
+
detail: typeof number === "number" ? classificationDetail : "corrupt",
|
|
404
|
+
relationships: [
|
|
405
|
+
{ field: "plan", target: identity.stableId },
|
|
406
|
+
...depends.map((dependency) => { const normalized = /^Task ([1-9][0-9]*)$/.exec(String(dependency))?.[1] ?? String(dependency); return { field: "depends_on", target: /^[1-9][0-9]*$/.test(normalized) ? `${identity.stableId}/task:${normalized}` : null }; }),
|
|
407
|
+
],
|
|
408
|
+
message: typeof number === "number" ? undefined : "plan task has no positive structured number",
|
|
409
|
+
...(identity.artifact.migrationProvenance ? { migrationProvenance: { ...identity.artifact.migrationProvenance, source_path: sourcePath, source_task_index: index } } : {}),
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
for (const diagnostic of discovery.diagnostics.filter((item) => !seen.has(`${item.path}\0diagnostic`))) {
|
|
414
|
+
if (discovery.identities.some((identity) => identity.artifact.path === diagnostic.path))
|
|
415
|
+
continue;
|
|
416
|
+
const sourcePath = relative(root, diagnostic.path);
|
|
417
|
+
observations.push({ key: `plan:corrupt:${sourcePath}`, artifact: "plan", boundary: "plan", path: sourcePath, provenance: "plan_candidate", record: null, detail: "corrupt", relationships: [], message: diagnostic.message });
|
|
418
|
+
}
|
|
419
|
+
for (const source of files.filter((candidate) => PLAN_ARCHIVE_SOURCE.test(candidate.relative))) {
|
|
420
|
+
if (!discovery.identities.some((identity) => relative(root, identity.artifact.path) === source.relative) && !observations.some((entry) => entry.path === source.relative)) {
|
|
421
|
+
observations.push({ key: `plan:corrupt:${source.relative}`, artifact: "plan", boundary: "plan", path: source.relative, provenance: "plan_candidate", record: null, detail: "corrupt", relationships: [], message: source.kind === "unsafe" ? unsafeSourceMessage(source.relative) : "plan archive could not be validated" });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function objectiveObservations(root, files, observations) {
|
|
426
|
+
const sourceBytes = new Map(files.flatMap((source) => source.kind === "file" && /^\.agentera\/(optimize|optimera)\/.+\/(objective|experiments)\.yaml$/.test(source.relative)
|
|
427
|
+
? [[path.join(root, source.relative), source.bytes]]
|
|
428
|
+
: []));
|
|
429
|
+
const discovery = discoverObjectiveArtifacts(root, sourceBytes);
|
|
430
|
+
for (const objective of discovery.objectives) {
|
|
431
|
+
for (const objectivePath of objective.paths) {
|
|
432
|
+
const sourcePath = relative(root, objectivePath);
|
|
433
|
+
const source = files.find((candidate) => candidate.relative === sourcePath);
|
|
434
|
+
let document = null;
|
|
435
|
+
try {
|
|
436
|
+
if (source?.kind === "file")
|
|
437
|
+
document = parseYaml(source);
|
|
438
|
+
}
|
|
439
|
+
catch { /* discovery diagnostic accounts for it */ }
|
|
440
|
+
observations.push({ key: objective.stableId, artifact: "objective", boundary: "objective", path: sourcePath, provenance: sourcePath.startsWith(".agentera/optimize/") ? "current_canonical" : "legacy_objective_root", record: document, detail: objective.ambiguous || !document ? "corrupt" : "full", relationships: [], message: objective.ambiguous ? "objective identity is ambiguous" : undefined });
|
|
441
|
+
}
|
|
442
|
+
if (objective.ambiguous)
|
|
443
|
+
continue;
|
|
444
|
+
const objectivePath = objective.paths[0];
|
|
445
|
+
const experimentsRelative = relative(root, path.join(path.dirname(objectivePath), "experiments.yaml"));
|
|
446
|
+
const experiments = files.find((source) => source.relative === experimentsRelative);
|
|
447
|
+
if (experiments?.kind === "file") {
|
|
448
|
+
try {
|
|
449
|
+
const document = parseYaml(experiments);
|
|
450
|
+
for (const experiment of inspectExperimentIdentities(objective.stableId, document).entries) {
|
|
451
|
+
const key = experiment.stableId ?? `${objective.stableId}/experiment:${experiment.provenance.collection}[${experiment.provenance.index}]`;
|
|
452
|
+
observations.push({ key, artifact: "experiments", boundary: "experiment", path: experiments.relative, provenance: "experiment_projection", record: experiment.data, detail: experiment.addressable ? "full" : experiment.compatibility === "legacy_missing_identity" ? "summary" : "corrupt", relationships: [{ field: "objective", target: objective.stableId }], message: experiment.caveats.join("; ") || undefined });
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
observations.push({ key: `${objective.stableId}/experiments`, artifact: "experiments", boundary: "experiment", path: experiments.relative, provenance: "experiment_projection", record: null, detail: "corrupt", relationships: [{ field: "objective", target: objective.stableId }], message: error.message });
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
else if (experiments?.kind === "unsafe") {
|
|
460
|
+
observations.push({ key: `${objective.stableId}/experiments`, artifact: "experiments", boundary: "experiment", path: experiments.relative, provenance: "experiment_projection", record: null, detail: "corrupt", relationships: [{ field: "objective", target: objective.stableId }], message: unsafeSourceMessage(experiments.relative) });
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
for (const diagnostic of discovery.diagnostics) {
|
|
464
|
+
for (const candidate of diagnostic.candidate_paths) {
|
|
465
|
+
if (observations.some((entry) => entry.path === relative(root, candidate)))
|
|
466
|
+
continue;
|
|
467
|
+
observations.push({ key: `objective:corrupt:${relative(root, candidate)}`, artifact: "objective", boundary: "objective", path: relative(root, candidate), provenance: "objective_candidate", record: null, detail: "corrupt", relationships: [], message: diagnostic.message });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
for (const source of files.filter((candidate) => candidate.kind === "unsafe" && /\/(objective|experiments)\.yaml$/.test(candidate.relative))) {
|
|
471
|
+
if (observations.some((entry) => entry.path === source.relative))
|
|
472
|
+
continue;
|
|
473
|
+
const artifact = source.relative.endsWith("/objective.yaml") ? "objective" : "experiments";
|
|
474
|
+
observations.push({ key: `${artifact}:corrupt:${source.relative}`, artifact, boundary: artifact === "objective" ? "objective" : "experiment", path: source.relative, provenance: artifact === "objective" ? "objective_candidate" : "experiment_projection", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(source.relative) });
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function todoAndDocs(root, todoPath, files, observations) {
|
|
478
|
+
const todo = files.find((source) => source.relative === todoPath);
|
|
479
|
+
if (todo?.kind === "file" && todo.bytes) {
|
|
480
|
+
let section = "normal";
|
|
481
|
+
todo.bytes.toString("utf8").split(/\r?\n/).forEach((line, index) => {
|
|
482
|
+
const heading = line.trim().match(/^##\s+(.+)$/)?.[1]?.toLowerCase();
|
|
483
|
+
if (heading)
|
|
484
|
+
section = heading.includes("critical") ? "critical" : heading.includes("degraded") ? "degraded" : heading.includes("annoying") ? "annoying" : heading.includes("resolved") ? "resolved" : heading.includes("normal") ? "normal" : section;
|
|
485
|
+
const item = parseTodoMarkdownListItem(line.trim());
|
|
486
|
+
if (!item)
|
|
487
|
+
return;
|
|
488
|
+
const severity = section === "resolved" ? "normal" : section;
|
|
489
|
+
const record = { severity, status: item.status, description: item.description };
|
|
490
|
+
const violations = todoDocsRecordViolations("todo_item", record);
|
|
491
|
+
observations.push({ key: `${todoPath}:line:${index + 1}`, artifact: "todo", boundary: "todo_item", path: todoPath, provenance: "current_canonical", record, detail: violations.length ? "corrupt" : "full", relationships: [], message: violations.length ? violations.join("; ") : undefined });
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
else if (todo?.kind === "unsafe") {
|
|
495
|
+
observations.push({ key: "todo:document", artifact: "todo", boundary: "todo_item", path: todoPath, provenance: "current_canonical", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(todoPath) });
|
|
496
|
+
}
|
|
497
|
+
const docs = files.find((source) => source.relative === ".agentera/docs.yaml");
|
|
498
|
+
if (docs?.kind === "file") {
|
|
499
|
+
try {
|
|
500
|
+
const document = parseYaml(docs);
|
|
501
|
+
if (document.index !== undefined && !Array.isArray(document.index))
|
|
502
|
+
throw new Error("docs index must be a list");
|
|
503
|
+
(Array.isArray(document.index) ? document.index : []).forEach((value, index) => {
|
|
504
|
+
const sourceRecord = mapping(value);
|
|
505
|
+
const originalStatus = sourceRecord?.status;
|
|
506
|
+
const normalizedStatus = originalStatus === "draft" ? "intent" : originalStatus === "archived" ? "stale" : originalStatus;
|
|
507
|
+
const record = sourceRecord ? { ...structuredClone(sourceRecord), ...(normalizedStatus !== originalStatus ? { status: normalizedStatus } : {}) } : null;
|
|
508
|
+
const identity = typeof record?.path === "string" ? `docs:path:${record.path}` : `docs:index:${index}`;
|
|
509
|
+
const violations = record ? todoDocsRecordViolations("documentation_inventory_entry", record) : ["documentation inventory entry must be a mapping"];
|
|
510
|
+
observations.push({ key: identity, artifact: "docs", boundary: "documentation_inventory_entry", path: docs.relative, provenance: "current_canonical", record, detail: violations.length ? "corrupt" : "full", relationships: [], message: violations.length ? violations.join("; ") : undefined, ...(normalizedStatus !== originalStatus ? { migrationProvenance: { kind: "legacy_docs_status_normalization", source_path: docs.relative, index, ...(sourceRecord?.path !== undefined ? { original_path: sourceRecord.path } : {}), ...(originalStatus !== undefined ? { original_status: originalStatus } : {}), ...(normalizedStatus !== undefined ? { normalized_status: normalizedStatus } : {}) } } : {}) });
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
catch (error) {
|
|
514
|
+
observations.push({ key: "docs:document", artifact: "docs", boundary: "documentation_inventory_entry", path: docs.relative, provenance: "current_canonical", record: null, detail: "corrupt", relationships: [], message: error.message });
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else if (docs?.kind === "unsafe") {
|
|
518
|
+
observations.push({ key: "docs:document", artifact: "docs", boundary: "documentation_inventory_entry", path: docs.relative, provenance: "current_canonical", record: null, detail: "corrupt", relationships: [], message: unsafeSourceMessage(docs.relative) });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function preservedSingletons(files) {
|
|
522
|
+
const declarations = [
|
|
523
|
+
{ boundary: "vision", source_path: ".agentera/vision.yaml" },
|
|
524
|
+
{ boundary: "design", source_path: "DESIGN.md" },
|
|
525
|
+
{ boundary: "changelog", source_path: "CHANGELOG.md" },
|
|
526
|
+
{ boundary: "docs_mapping", source_path: ".agentera/docs.yaml", preserved_sections: ["last_audit", "conventions", "mapping", "coverage", "audit_log"] },
|
|
527
|
+
{ boundary: "profile", source_path: "$AGENTERA_PROFILE_DIR/PROFILE.md" },
|
|
528
|
+
{ boundary: "runtime_local_session_state", source_path: "runtime-local" },
|
|
529
|
+
];
|
|
530
|
+
return declarations.map((declaration) => {
|
|
531
|
+
const source = files.find((candidate) => candidate.relative === declaration.source_path);
|
|
532
|
+
return { ...declaration, presence: source?.kind ?? "missing", content_sha256: source?.bytes ? hash(source.bytes) : null };
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function previewId(fingerprint, key) {
|
|
536
|
+
const bytes = createHash("sha256").update(`agentera.entity-preview.v1\0${fingerprint}\0${key}`, "utf8").digest();
|
|
537
|
+
return Array.from(bytes.subarray(0, 10), (byte) => String.fromCharCode(97 + byte % 26)).join("");
|
|
538
|
+
}
|
|
539
|
+
function summaryBoundary(artifact, fallback) {
|
|
540
|
+
return { progress: "progress_summary", decisions: "decision_summary", health: "health_summary" }[artifact] ?? fallback;
|
|
541
|
+
}
|
|
542
|
+
function canonicalSummaryBodies(group, forbiddenAliases) {
|
|
543
|
+
return new Set(group.flatMap((item) => item.record
|
|
544
|
+
? [canonicalRecordJson(canonicalMigrationRecord(summaryBoundary(item.artifact, item.boundary), item.record, forbiddenAliases))]
|
|
545
|
+
: []));
|
|
546
|
+
}
|
|
547
|
+
function classify(group, forbiddenAliases) {
|
|
548
|
+
if (group.some((item) => item.provenance === "historical_projection_residue"))
|
|
549
|
+
return "historical_projection_residue";
|
|
550
|
+
if (group.some((item) => item.key.startsWith("unsupported:")))
|
|
551
|
+
return "unsupported";
|
|
552
|
+
if (group.some((item) => item.detail === "corrupt"))
|
|
553
|
+
return "corrupt";
|
|
554
|
+
if (group.every((item) => item.detail === "summary")) {
|
|
555
|
+
if (!COMPACTED_SUMMARY_ARTIFACTS.has(group[0]?.artifact ?? ""))
|
|
556
|
+
return "corrupt";
|
|
557
|
+
return canonicalSummaryBodies(group, forbiddenAliases).size === 1 ? "valid_compacted_summary" : "conflict";
|
|
558
|
+
}
|
|
559
|
+
const full = group.filter((item) => item.detail === "full" && item.record);
|
|
560
|
+
const bodies = new Set(full.map((item) => canonicalRecordJson(item.record)));
|
|
561
|
+
if (bodies.size > 1)
|
|
562
|
+
return "duplicate";
|
|
563
|
+
const projections = full.filter((item) => item.provenance === "current_projection");
|
|
564
|
+
const archive = group.find((item) => item.provenance === "verified_archive" && item.record);
|
|
565
|
+
const summaries = group.filter((item) => item.detail === "summary" && item.record);
|
|
566
|
+
if (full.length && summaries.length) {
|
|
567
|
+
const selected = archive ?? full[0];
|
|
568
|
+
const recovery = selected.migrationProvenance;
|
|
569
|
+
const recorded = mapping(recovery?.current_projection)?.record_sha256;
|
|
570
|
+
if (!summaries.every((item) => exactProjectionMirror(item.artifact, selected.record, item.record, recorded)))
|
|
571
|
+
return "conflict";
|
|
572
|
+
}
|
|
573
|
+
if (archive || group.some((item) => item.provenance === "verified_plan_archive"))
|
|
574
|
+
return "verified_full";
|
|
575
|
+
if (group.every((item) => item.provenance === "current_projection" || item.provenance === "experiment_projection"))
|
|
576
|
+
return "recoverable_degraded_full_projection";
|
|
577
|
+
return "verified_full";
|
|
578
|
+
}
|
|
579
|
+
function exactProjectionMirror(artifact, full, summary, recorded) {
|
|
580
|
+
if (recorded === hash(canonicalRecordJson(summary)))
|
|
581
|
+
return true;
|
|
582
|
+
if (artifact === "health" && typeof summary.summary === "string" && typeof full.number === "number" && typeof full.date === "string" && typeof full.trajectory === "string") {
|
|
583
|
+
if (summary.summary === `Audit ${full.number} · ${full.date} (${truncateWords(full.trajectory, 10)})`)
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
if (artifact !== "progress" && artifact !== "decisions" && artifact !== "health")
|
|
587
|
+
return false;
|
|
588
|
+
return canonicalRecordJson(yamlArchiveEntry(artifact, full)) === canonicalRecordJson(summary);
|
|
589
|
+
}
|
|
590
|
+
function buildEntries(project, fingerprint, observations, forbiddenAliases) {
|
|
591
|
+
const groups = new Map();
|
|
592
|
+
for (const observation of observations)
|
|
593
|
+
groups.set(observation.key, [...(groups.get(observation.key) ?? []), observation]);
|
|
594
|
+
const ids = new Map();
|
|
595
|
+
for (const key of [...groups.keys()].sort()) {
|
|
596
|
+
const group = groups.get(key);
|
|
597
|
+
const canonicalSummaries = group.every((item) => item.detail === "summary") && COMPACTED_SUMMARY_ARTIFACTS.has(group[0]?.artifact ?? "")
|
|
598
|
+
? [...canonicalSummaryBodies(group, forbiddenAliases)].sort()
|
|
599
|
+
: [];
|
|
600
|
+
const identityBinding = canonicalSummaries.length === 1 ? hash(canonicalRecordJson(canonicalSummaries)) : fingerprint;
|
|
601
|
+
ids.set(key, previewId(identityBinding, key));
|
|
602
|
+
}
|
|
603
|
+
const collisions = new Set();
|
|
604
|
+
const idOwners = new Map();
|
|
605
|
+
for (const [key, id] of ids) {
|
|
606
|
+
const owner = idOwners.get(id);
|
|
607
|
+
if (owner) {
|
|
608
|
+
collisions.add(owner);
|
|
609
|
+
collisions.add(key);
|
|
610
|
+
}
|
|
611
|
+
else
|
|
612
|
+
idOwners.set(id, key);
|
|
613
|
+
}
|
|
614
|
+
const entries = [...groups.entries()].map(([key, unsortedGroup]) => {
|
|
615
|
+
const group = [...unsortedGroup].sort((left, right) => `${left.path}\0${left.provenance}\0${canonicalRecordJson(left.record)}\0${left.sourceRecordSha256 ?? ""}`.localeCompare(`${right.path}\0${right.provenance}\0${canonicalRecordJson(right.record)}\0${right.sourceRecordSha256 ?? ""}`));
|
|
616
|
+
let classification = classify(group, forbiddenAliases);
|
|
617
|
+
if (collisions.has(key))
|
|
618
|
+
classification = "conflict";
|
|
619
|
+
const primary = group[0];
|
|
620
|
+
const contentObservation = group.find((item) => item.provenance === "verified_archive" && item.detail === "full" && item.record)
|
|
621
|
+
?? group.find((item) => item.detail === "full" && item.record)
|
|
622
|
+
?? group.find((item) => item.detail === "summary" && item.record);
|
|
623
|
+
const content = contentObservation?.record ?? null;
|
|
624
|
+
const contentSha256s = [...new Set(group.flatMap((item) => item.record ? [hash(canonicalRecordJson(item.record))] : []))].sort();
|
|
625
|
+
const mirrored = contentSha256s.length === 1 && group.filter((item) => item.record).length > 1;
|
|
626
|
+
const id = ids.get(key);
|
|
627
|
+
const relationshipSources = new Map(group.flatMap((item) => item.relationships).map((relationship) => [`${relationship.field}\0${relationship.target ?? ""}`, relationship])).values();
|
|
628
|
+
const relationships = [...relationshipSources].map((relationship) => ({
|
|
629
|
+
field: relationship.field,
|
|
630
|
+
target_source_identity: relationship.target,
|
|
631
|
+
target_id: relationship.target ? ids.get(relationship.target) ?? null : null,
|
|
632
|
+
status: relationship.target && groups.has(relationship.target) ? "resolved" : "unresolved",
|
|
633
|
+
}));
|
|
634
|
+
const summary = classification === "valid_compacted_summary";
|
|
635
|
+
const boundary = summary ? summaryBoundary(primary.artifact, primary.boundary) : contentObservation?.boundary ?? primary.boundary;
|
|
636
|
+
const record = content ? canonicalMigrationRecord(boundary, content, forbiddenAliases, summary ? [] : relationships) : {};
|
|
637
|
+
if (summary && contentObservation && content) {
|
|
638
|
+
record.migration_provenance = {
|
|
639
|
+
source_path: contentObservation.path,
|
|
640
|
+
source_record_sha256: contentObservation.sourceRecordSha256 ?? hash(canonicalRecordJson(content)),
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
const residue = classification === "historical_projection_residue";
|
|
644
|
+
const blocked = BLOCKING.has(classification) || relationships.some((relationship) => relationship.status === "unresolved");
|
|
645
|
+
return {
|
|
646
|
+
source_identity: key,
|
|
647
|
+
source_paths: [...new Set(group.map((item) => item.path))].sort(),
|
|
648
|
+
artifact: primary.artifact,
|
|
649
|
+
boundary,
|
|
650
|
+
classification,
|
|
651
|
+
detail_availability: summary ? "summary" : content ? "full" : "unavailable",
|
|
652
|
+
compatibility: summary ? "degraded" : "current",
|
|
653
|
+
provenance: [...new Set([...group.map((item) => item.provenance), ...(mirrored ? ["mirrored"] : [])])].sort(),
|
|
654
|
+
content_sha256: contentSha256s.length === 1 ? contentSha256s[0] : null,
|
|
655
|
+
content_sha256s: contentSha256s,
|
|
656
|
+
physical_record_count: group.length,
|
|
657
|
+
proposed_target: blocked || residue ? null : { id, path: `.agentera/entities/${primary.artifact}/${boundary}/${id}.yaml` },
|
|
658
|
+
target_sha256: null,
|
|
659
|
+
relationships,
|
|
660
|
+
record,
|
|
661
|
+
recovery: blocked ? recovery(project, primary.path) : "none",
|
|
662
|
+
...(contentObservation?.inheritedConfidenceProvenance ? { canonical_migration_provenance: contentObservation.inheritedConfidenceProvenance } : {}),
|
|
663
|
+
...(group.some((item) => item.migrationProvenance) ? { migration_provenance: group.flatMap((item) => item.migrationProvenance ? [item.migrationProvenance] : []) } : {}),
|
|
664
|
+
};
|
|
665
|
+
}).sort((a, b) => `${a.artifact}\0${a.boundary}\0${a.source_identity}\0${a.source_paths[0]}`.localeCompare(`${b.artifact}\0${b.boundary}\0${b.source_identity}\0${b.source_paths[0]}`));
|
|
666
|
+
const decisions = new Map(entries.filter(({ boundary, proposed_target }) => boundary === "decision" && proposed_target).map((entry) => [entry.proposed_target.id, entry.record]));
|
|
667
|
+
const groupedRevisions = new Map();
|
|
668
|
+
for (const entry of entries.filter(({ boundary }) => boundary === "decision_revision")) {
|
|
669
|
+
const decision = entry.relationships.find(({ field }) => field === "decision")?.target_id ?? "";
|
|
670
|
+
groupedRevisions.set(decision, [...(groupedRevisions.get(decision) ?? []), entry]);
|
|
671
|
+
}
|
|
672
|
+
for (const [decision, revisions] of groupedRevisions) {
|
|
673
|
+
let effective = structuredClone(decisions.get(decision) ?? {});
|
|
674
|
+
for (const entry of revisions.sort((left, right) => left.source_identity.localeCompare(right.source_identity, undefined, { numeric: true }))) {
|
|
675
|
+
const source = entry.record;
|
|
676
|
+
const changes = mapping(source.changes) ? structuredClone(source.changes) : Object.fromEntries(Object.entries(source).filter(([field]) => !["decision", "date", "provenance", "base_sha256"].includes(field)));
|
|
677
|
+
entry.record = { decision, date: source.date, provenance: source.provenance, base_sha256: hash(canonicalRecordJson(effective)), changes };
|
|
678
|
+
effective = { ...effective, ...structuredClone(changes) };
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return entries;
|
|
682
|
+
}
|
|
683
|
+
export function validateEntityMigrationTargets(project, entries, sourceRoot) {
|
|
684
|
+
const targets = entries.flatMap((entry) => entry.proposed_target && entry.artifact && entry.boundary ? [{ sourceIdentity: entry.source_identity, path: entry.proposed_target.path, id: entry.proposed_target.id, artifact: entry.artifact, boundary: entry.boundary, record: entry.record, migrationProvenance: entry.canonical_migration_provenance }] : []);
|
|
685
|
+
const diagnostics = validateCanonicalEntityTargets(project, targets, sourceRoot);
|
|
686
|
+
for (const entry of entries) {
|
|
687
|
+
if (!entry.proposed_target || !entry.artifact)
|
|
688
|
+
continue;
|
|
689
|
+
const actual = hash(canonicalEntityEnvelopeBytes({ id: entry.proposed_target.id, artifact: entry.artifact, record: entry.record, migrationProvenance: entry.canonical_migration_provenance }));
|
|
690
|
+
if (entry.target_sha256 !== actual)
|
|
691
|
+
diagnostics.push({ sourceIdentity: entry.source_identity, path: entry.proposed_target.path, message: `canonical target bytes have SHA-256 '${actual}', not manifest binding '${entry.target_sha256 ?? "missing"}'` });
|
|
692
|
+
}
|
|
693
|
+
return diagnostics;
|
|
694
|
+
}
|
|
695
|
+
function migrationInventory(projectRoot, sourceRoot, resolveDescriptorPath) {
|
|
696
|
+
const project = path.resolve(projectRoot);
|
|
697
|
+
const validatedProject = validateRealProjectRoot(project);
|
|
698
|
+
const authority = authorityBinding(sourceRoot);
|
|
699
|
+
const todoRecord = loadArtifactRecord("todo");
|
|
700
|
+
if (!todoRecord)
|
|
701
|
+
throw new Error("artifact registry is missing the canonical 'todo' record");
|
|
702
|
+
const docsSnapshot = { relative: ".agentera/docs.yaml", ...readProjectFileSnapshot(validatedProject, ".agentera/docs.yaml", resolveDescriptorPath) };
|
|
703
|
+
const overrides = docsSnapshot.kind === "file" ? docsPathOverridesFromBytes(docsSnapshot.bytes) : {};
|
|
704
|
+
const todoAbsolute = todoRecord.displayName in overrides ? resolveArtifactPath(todoRecord, project, { docsPathOverrides: overrides }) : path.join(project, todoRecord.defaultPath);
|
|
705
|
+
const todoPath = relative(project, todoAbsolute);
|
|
706
|
+
if (todoPath !== todoRecord.defaultPath)
|
|
707
|
+
assertRealpathBoundary(project, todoAbsolute, todoRecord.artifactId);
|
|
708
|
+
const files = collectSources(project, validatedProject, todoPath, docsSnapshot, resolveDescriptorPath);
|
|
709
|
+
const fingerprint = sourceFingerprint(files);
|
|
710
|
+
const observations = [];
|
|
711
|
+
inventoryFailureObservations(files, observations);
|
|
712
|
+
numberedObservations(project, sourceRoot, files, observations, entityPreservedAggregateCollections(sourceRoot));
|
|
713
|
+
decisionEvidence(sourceRoot, files, observations);
|
|
714
|
+
planObservations(project, files, observations);
|
|
715
|
+
objectiveObservations(project, files, observations);
|
|
716
|
+
todoAndDocs(project, todoPath, files, observations);
|
|
717
|
+
const preserved = preservedSingletons(files);
|
|
718
|
+
const completeInventory = buildEntries(project, fingerprint, observations, entityForbiddenCanonicalAliases(sourceRoot));
|
|
719
|
+
const preservedResidues = completeInventory.filter((entry) => entry.classification === "historical_projection_residue");
|
|
720
|
+
const completeEntries = completeInventory.filter((entry) => entry.classification !== "historical_projection_residue");
|
|
721
|
+
for (const entry of completeEntries) {
|
|
722
|
+
if (entry.proposed_target && entry.artifact)
|
|
723
|
+
entry.target_sha256 = hash(canonicalEntityEnvelopeBytes({ id: entry.proposed_target.id, artifact: entry.artifact, record: entry.record, migrationProvenance: entry.canonical_migration_provenance }));
|
|
724
|
+
}
|
|
725
|
+
let causal = applyCausalBlockers(completeEntries, project, (sourcePath) => recovery(project, sourcePath));
|
|
726
|
+
const targetDiagnostics = validateEntityMigrationTargets(project, completeEntries, sourceRoot);
|
|
727
|
+
for (const diagnostic of targetDiagnostics) {
|
|
728
|
+
const entry = completeEntries.find((candidate) => candidate.source_identity === diagnostic.sourceIdentity);
|
|
729
|
+
if (!entry)
|
|
730
|
+
continue;
|
|
731
|
+
entry.classification = "corrupt";
|
|
732
|
+
entry.proposed_target = null;
|
|
733
|
+
entry.target_sha256 = null;
|
|
734
|
+
entry.recovery = recovery(project, entry.source_paths[0]);
|
|
735
|
+
causal.rootReasons.set(entry.source_identity, `target_invalid: ${diagnostic.message}`);
|
|
736
|
+
}
|
|
737
|
+
causal = applyCausalBlockers(completeEntries, project, (sourcePath) => recovery(project, sourcePath), causal.rootReasons);
|
|
738
|
+
const classes = ["verified_full", "recoverable_degraded_full_projection", "valid_compacted_summary", "duplicate", "conflict", "corrupt", "unsupported", "historical_projection_residue"];
|
|
739
|
+
const counts = Object.fromEntries(classes.map((classification) => [classification, completeInventory.filter((entry) => entry.classification === classification).length]));
|
|
740
|
+
counts.total = completeInventory.length;
|
|
741
|
+
counts.publishable_entities = completeEntries.filter(({ proposed_target }) => proposed_target !== null).length;
|
|
742
|
+
counts.logical_identities = completeInventory.length;
|
|
743
|
+
counts.physical_records = observations.length;
|
|
744
|
+
counts.mirrors = completeInventory.reduce((total, entry) => total + (entry.provenance.includes("mirrored") ? entry.physical_record_count - 1 : 0), 0);
|
|
745
|
+
counts.duplicates = completeInventory.reduce((total, entry) => total + (entry.classification === "duplicate" ? entry.physical_record_count - 1 : 0), 0);
|
|
746
|
+
counts.conflicts = counts.duplicate + counts.conflict;
|
|
747
|
+
counts.relationships = completeEntries.reduce((total, entry) => total + entry.relationships.length, 0);
|
|
748
|
+
counts.unresolved_relationships = completeEntries.reduce((total, entry) => total + entry.relationships.filter((relationship) => relationship.status === "unresolved").length, 0);
|
|
749
|
+
const rootDiagnostics = completeEntries
|
|
750
|
+
.filter((entry) => causal.rootReasons.has(entry.source_identity))
|
|
751
|
+
.map((entry) => {
|
|
752
|
+
const unresolved = entry.relationships.find((relationship) => relationship.status === "unresolved");
|
|
753
|
+
const reason = causal.rootReasons.get(entry.source_identity) ?? `${entry.classification} source requires explicit recovery`;
|
|
754
|
+
const observationMessage = observations.find((item) => item.key === entry.source_identity)?.message;
|
|
755
|
+
return {
|
|
756
|
+
classification: entry.classification,
|
|
757
|
+
path: entry.source_paths[0],
|
|
758
|
+
source_identity: entry.source_identity,
|
|
759
|
+
...(unresolved ? { relationship_field: unresolved.field, target_source_identity: unresolved.target_source_identity } : {}),
|
|
760
|
+
message: reason === `${entry.classification} source requires explicit recovery` && observationMessage ? observationMessage : reason,
|
|
761
|
+
recovery: entry.recovery,
|
|
762
|
+
};
|
|
763
|
+
});
|
|
764
|
+
const dependentDiagnostics = completeEntries.flatMap((entry) => {
|
|
765
|
+
if (causal.rootReasons.has(entry.source_identity))
|
|
766
|
+
return [];
|
|
767
|
+
return entry.relationships.flatMap((relationship) => {
|
|
768
|
+
if (relationship.status !== "resolved" || !relationship.target_source_identity)
|
|
769
|
+
return [];
|
|
770
|
+
return causal.rootsFor(relationship.target_source_identity).map((rootSourceIdentity) => ({
|
|
771
|
+
classification: "dependent_blocker",
|
|
772
|
+
path: entry.source_paths[0],
|
|
773
|
+
source_identity: entry.source_identity,
|
|
774
|
+
relationship_field: relationship.field,
|
|
775
|
+
target_source_identity: relationship.target_source_identity,
|
|
776
|
+
root_source_identity: rootSourceIdentity,
|
|
777
|
+
message: `source '${entry.source_identity}' relationship '${relationship.field}' is blocked by root source '${rootSourceIdentity}'`,
|
|
778
|
+
recovery: recovery(project, entry.source_paths[0]),
|
|
779
|
+
}));
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
const diagnostics = [...rootDiagnostics, ...dependentDiagnostics].sort((left, right) => `${left.source_identity}\0${left.classification}\0${left.relationship_field ?? ""}\0${left.target_source_identity ?? ""}\0${left.root_source_identity ?? ""}`.localeCompare(`${right.source_identity}\0${right.classification}\0${right.relationship_field ?? ""}\0${right.target_source_identity ?? ""}\0${right.root_source_identity ?? ""}`));
|
|
783
|
+
counts.root_blockers = rootDiagnostics.length;
|
|
784
|
+
counts.dependent_blockers = dependentDiagnostics.length;
|
|
785
|
+
counts.blockers = counts.root_blockers + counts.dependent_blockers;
|
|
786
|
+
const digestEntries = completeEntries.map(({ record: _record, ...entry }) => entry);
|
|
787
|
+
const digestResidues = preservedResidues.map(({ record: _record, ...entry }) => entry);
|
|
788
|
+
const digestBody = { source_fingerprint: fingerprint, authority, selectors: { project, filter: INVENTORY_FILTER, order: INVENTORY_ORDER }, entries: digestEntries, preserved_residues: digestResidues, preserved_singletons: preserved, counts, diagnostics };
|
|
789
|
+
const previewDigest = hash(canonicalRecordJson(digestBody));
|
|
790
|
+
const sources = files.map((file) => {
|
|
791
|
+
return { path: file.relative, presence: file.kind === "file" ? "file" : "missing", size: file.bytes?.byteLength ?? 0, sha256: file.bytes ? hash(file.bytes) : null, mode: file.kind === "file" ? file.mode : null, dev: file.kind === "file" ? String(file.dev) : null, ino: file.kind === "file" ? String(file.ino) : null, type: file.kind === "file" ? file.type : null, bytes_base64: file.bytes?.toString("base64") ?? null };
|
|
792
|
+
});
|
|
793
|
+
return { project, source_fingerprint: fingerprint, preview_digest: previewDigest, ...authority, preserved_singletons: preserved, entries: completeEntries, preserved_residues: preservedResidues, sources, counts, diagnostics };
|
|
794
|
+
}
|
|
795
|
+
export function planEntityMigration(projectRoot, sourceRoot, options = {}) {
|
|
796
|
+
return migrationInventory(projectRoot, sourceRoot, options.resolveDescriptorPath ?? resolveProjectDescriptorPath);
|
|
797
|
+
}
|
|
798
|
+
export function previewEntityMigration(projectRoot, sourceRoot, options = {}) {
|
|
799
|
+
const inventory = migrationInventory(projectRoot, sourceRoot, options.resolveDescriptorPath ?? resolveProjectDescriptorPath);
|
|
800
|
+
const { project, source_fingerprint: fingerprint, preview_digest: previewDigest, preserved_singletons: preserved, counts, diagnostics } = inventory;
|
|
801
|
+
const authority = { authority_schema_version: inventory.authority_schema_version, authority_sha256: inventory.authority_sha256 };
|
|
802
|
+
const completeEntries = inventory.entries.map(({ record: _record, ...entry }) => entry);
|
|
803
|
+
const preservedResidues = inventory.preserved_residues.map(({ record: _record, ...entry }) => entry);
|
|
804
|
+
const requestedLimit = Math.max(1, Math.min(options.limit ?? DEFAULT_LIMIT, MAX_LIMIT));
|
|
805
|
+
const restartCommand = `agentera state migrate entities --project '${project.replaceAll("'", "'\\''")}' --limit ${requestedLimit} --dry-run --format json`;
|
|
806
|
+
if (options.after !== undefined && (options.sourceFingerprint !== fingerprint || options.previewDigest !== previewDigest)) {
|
|
807
|
+
throw new EntityMigrationContinuationError(restartCommand);
|
|
808
|
+
}
|
|
809
|
+
const start = options.after === undefined ? 0 : completeEntries.findIndex((entry) => entry.source_identity === options.after) + 1;
|
|
810
|
+
if (options.after !== undefined && start === 0)
|
|
811
|
+
throw new Error(`pagination cursor '${options.after}' is not a source identity in the bound inventory; restart without --after`);
|
|
812
|
+
let entries = completeEntries.slice(start, start + requestedLimit);
|
|
813
|
+
const diagnosticsForEntries = () => {
|
|
814
|
+
const identities = new Set(entries.map((entry) => entry.source_identity));
|
|
815
|
+
return diagnostics.filter((diagnostic) => identities.has(diagnostic.source_identity));
|
|
816
|
+
};
|
|
817
|
+
let omissionReason = start > 0 || start + entries.length < completeEntries.length ? "result_limit" : null;
|
|
818
|
+
const quotedProject = project.replaceAll("'", "'\\''");
|
|
819
|
+
const base = { schemaVersion: "agentera.entityMigrationPreview.v1", command: "state migrate entities", status: counts.blockers > 0 ? "blocked" : "ready", mode: "preview", project, read_only: true, mutation_intent: false, mutation_performed: false, source_fingerprint: fingerprint, preview_digest: previewDigest, preserved_singletons: preserved, preserved_residues: preservedResidues, counts, source_contract: { authority: AUTHORITY_PATH, ...authority, zero_write: true, scalar_truncation: "forbidden", apply_owner: "full development-channel upgrade --yes" } };
|
|
820
|
+
const serializedBytes = () => {
|
|
821
|
+
const pageDiagnostics = diagnosticsForEntries();
|
|
822
|
+
const nextAfter = start + entries.length < completeEntries.length ? entries.at(-1)?.source_identity ?? null : null;
|
|
823
|
+
const command = nextAfter ? `agentera state migrate entities --project '${quotedProject}' --after '${nextAfter.replaceAll("'", "'\\''")}' --source-fingerprint ${fingerprint} --preview-digest ${previewDigest} --limit ${requestedLimit} --dry-run --format json` : restartCommand;
|
|
824
|
+
const body = { ...base, entries, diagnostics: pageDiagnostics, omitted: start > 0 || entries.length < completeEntries.length, omitted_count: completeEntries.length - entries.length, diagnostics_omitted_count: diagnostics.length - pageDiagnostics.length, omission_reason: omissionReason, page_after: options.after ?? null, next_after: nextAfter, retrieval: { command } };
|
|
825
|
+
return Math.max(Buffer.byteLength(JSON.stringify(body, null, 2), "utf8"), Buffer.byteLength(YAML.stringify(body), "utf8"));
|
|
826
|
+
};
|
|
827
|
+
while (entries.length > 0 && serializedBytes() > ENTITY_MIGRATION_PREVIEW_MAX_OUTPUT_BYTES) {
|
|
828
|
+
entries = entries.slice(0, -1);
|
|
829
|
+
omissionReason = "output_byte_budget";
|
|
830
|
+
}
|
|
831
|
+
if (entries.length === 0 && start < completeEntries.length)
|
|
832
|
+
throw new Error(`the next whole migration entry exceeds the ${ENTITY_MIGRATION_PREVIEW_MAX_OUTPUT_BYTES}-byte output budget; repair that source before retrying`);
|
|
833
|
+
const outputDiagnostics = diagnosticsForEntries();
|
|
834
|
+
const nextAfter = start + entries.length < completeEntries.length ? entries.at(-1)?.source_identity ?? null : null;
|
|
835
|
+
const retrieval = { command: nextAfter ? `agentera state migrate entities --project '${quotedProject}' --after '${nextAfter.replaceAll("'", "'\\''")}' --source-fingerprint ${fingerprint} --preview-digest ${previewDigest} --limit ${requestedLimit} --dry-run --format json` : restartCommand };
|
|
836
|
+
return { ...base, status: base.status, mode: "preview", entries, diagnostics: outputDiagnostics, omitted: start > 0 || entries.length < completeEntries.length, omitted_count: completeEntries.length - entries.length, diagnostics_omitted_count: diagnostics.length - outputDiagnostics.length, omission_reason: omissionReason, page_after: options.after ?? null, next_after: nextAfter, retrieval };
|
|
837
|
+
}
|
|
838
|
+
export class EntityMigrationContinuationError extends Error {
|
|
839
|
+
restartCommand;
|
|
840
|
+
classification = "continuation_changed";
|
|
841
|
+
constructor(restartCommand) {
|
|
842
|
+
super(`entity migration continuation no longer matches its source, migration authority, selectors, or order; restart with ${restartCommand}`);
|
|
843
|
+
this.restartCommand = restartCommand;
|
|
844
|
+
this.name = "EntityMigrationContinuationError";
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
export class EntityMigrationBindingError extends Error {
|
|
848
|
+
current;
|
|
849
|
+
classification = "source_changed";
|
|
850
|
+
restartCommand;
|
|
851
|
+
constructor(current) {
|
|
852
|
+
const restartCommand = `agentera state migrate entities --project '${current.project.replaceAll("'", "'\\''")}' --dry-run --format json`;
|
|
853
|
+
super(`entity migration source or migration authority changed after preview; rerun ${restartCommand}`);
|
|
854
|
+
this.current = current;
|
|
855
|
+
this.restartCommand = restartCommand;
|
|
856
|
+
this.name = "EntityMigrationBindingError";
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
export function assertEntityMigrationBinding(expectedSourceFingerprint, expectedPreviewDigest, current, effect) {
|
|
860
|
+
if (current.source_fingerprint !== expectedSourceFingerprint || current.preview_digest !== expectedPreviewDigest)
|
|
861
|
+
throw new EntityMigrationBindingError(current);
|
|
862
|
+
return effect();
|
|
863
|
+
}
|
|
864
|
+
//# sourceMappingURL=entityMigrationPreview.js.map
|