agentera 3.0.0-dev.41 → 3.0.0-dev.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -4
- package/bundle/CHANGELOG.md +91 -1
- package/bundle/README.md +26 -19
- package/bundle/UPGRADE.md +50 -15
- package/bundle/references/adapters/package-publication.json +408 -14
- package/bundle/references/adapters/package-registry.yaml +414 -1
- package/bundle/references/adapters/package-surface-characterization.md +20 -0
- package/bundle/references/adapters/runtime-retired-resources.yaml +237 -1
- package/bundle/references/analysis/evidence-tier-authority.yaml +3 -3
- package/bundle/references/analysis/verification-policy.yaml +48 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +1 -1
- package/bundle/references/artifacts/glossary-entry-contract.yaml +11 -11
- package/bundle/references/artifacts/state-storage-authority.yaml +170 -118
- package/bundle/references/cli/capability-instruction-contract.yaml +4 -4
- package/bundle/references/cli/hybrid-route-contract.yaml +27 -5
- package/bundle/references/cli/routing-model.md +20 -4
- package/bundle/references/cli/trigger-schema-enrichment.md +7 -0
- package/bundle/references/cli/vocabulary-index.yaml +1 -3
- package/bundle/references/cli/vocabulary.md +18 -60
- package/bundle/references/meta/retained-reference-authority.yaml +151 -0
- package/bundle/skills/agentera/SKILL.md +32 -16
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +3 -3
- package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +1 -1
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +5 -5
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +3 -3
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +3 -3
- package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +1 -1
- package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +1 -1
- package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +1 -1
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +5 -5
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +1 -1
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +1 -1
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +1 -1
- package/bundle/skills/agentera/capability_schema_contract.yaml +2 -2
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +3 -3
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +3 -3
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +1 -1
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +3 -3
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +12 -10
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +3 -3
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +6 -4
- package/dist/analytics/extractCorpus/cli.js +0 -1
- package/dist/analytics/extractCorpus/copilotSessions.js +0 -1
- package/dist/analytics/extractCorpus/core.js +0 -1
- package/dist/analytics/extractCorpus/corpus.js +0 -1
- package/dist/analytics/extractCorpus/coverageAudit.js +0 -1
- package/dist/analytics/extractCorpus/cursorSessions.js +0 -1
- package/dist/analytics/extractCorpus/evidenceTiers.js +0 -1
- package/dist/analytics/extractCorpus/extractCorpusParity.js +0 -1
- package/dist/analytics/extractCorpus/filesystemSources.js +0 -1
- package/dist/analytics/extractCorpus/index.js +0 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js +0 -1
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +0 -1
- package/dist/analytics/extractCorpus/tierReader.js +0 -1
- package/dist/analytics/extractCorpus.js +0 -1
- package/dist/analytics/glossaryAdviceResolution.js +0 -1
- package/dist/analytics/glossaryInputAcquisition.js +0 -1
- package/dist/analytics/personalGlossaryAdmission.js +0 -1
- package/dist/analytics/personalGlossaryProfile.js +0 -1
- package/dist/analytics/profileSignals.js +0 -1
- package/dist/analytics/usageStats.js +0 -1
- package/dist/audit/terminologyDrift.js +0 -1
- package/dist/bin/agentera.js +0 -1
- package/dist/capabilities/audit/instructions.js +3 -4
- package/dist/capabilities/build/instructions.js +2 -3
- package/dist/capabilities/design/instructions.js +1 -2
- package/dist/capabilities/discuss/instructions.js +2 -3
- package/dist/capabilities/document/instructions.js +2 -3
- package/dist/capabilities/index.js +5 -4
- package/dist/capabilities/optimize/instructions.js +1 -2
- package/dist/capabilities/orchestrate/instructions.js +3 -4
- package/dist/capabilities/plan/instructions.js +1 -2
- package/dist/capabilities/profile/instructions.js +1 -2
- package/dist/capabilities/research/instructions.js +1 -2
- package/dist/capabilities/status/instructions.js +1 -2
- package/dist/capabilities/status/startupInstructions.js +0 -5
- package/dist/capabilities/vision/instructions.js +1 -2
- package/dist/cli/appContext.js +0 -1
- package/dist/cli/argvalidate.js +0 -1
- package/dist/cli/capabilityContext/benchmark.js +4 -4
- package/dist/cli/capabilityContext/bespoke.js +0 -1
- package/dist/cli/capabilityContext/build.js +8 -10
- package/dist/cli/capabilityContext/closeout.js +8 -10
- package/dist/cli/capabilityContext/contract.js +7 -42
- package/dist/cli/capabilityContext/evidence.js +12 -14
- package/dist/cli/capabilityContext/index.js +0 -1
- package/dist/cli/capabilityContext/orchestration.js +6 -8
- package/dist/cli/capabilityContext/planState.js +0 -1
- package/dist/cli/capabilityContext/progress.js +0 -1
- package/dist/cli/capabilityContext/projectVerification.js +0 -1
- package/dist/cli/capabilityContext/shared.js +2 -19
- package/dist/cli/capabilityContext/slim.js +0 -1
- package/dist/cli/capabilityContext/startup.js +24 -152
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +4 -4
- package/dist/cli/capabilityContext.js +0 -1
- package/dist/cli/commands/appHome.js +0 -1
- package/dist/cli/commands/capability.js +2 -2
- package/dist/cli/commands/compact.js +0 -1
- package/dist/cli/commands/doctor.js +104 -9
- package/dist/cli/commands/durability.js +0 -1
- package/dist/cli/commands/glossaryAdvice.js +0 -1
- package/dist/cli/commands/lint.js +0 -1
- package/dist/cli/commands/personalGlossary.js +0 -1
- package/dist/cli/commands/prime/briefOrientation.js +24 -85
- package/dist/cli/commands/prime/buildExecutionRequest.js +2 -2
- package/dist/cli/commands/prime/bundleStatus.js +0 -1
- package/dist/cli/commands/prime/collectEntityOrientation.js +47 -27
- package/dist/cli/commands/prime/collectOrientationState.js +36 -2
- package/dist/cli/commands/prime/orientationOutput.js +104 -84
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime/v1Migration.js +0 -1
- package/dist/cli/commands/prime.js +18 -36
- package/dist/cli/commands/profileGrounding.js +0 -1
- package/dist/cli/commands/query.js +2 -2
- package/dist/cli/commands/report.js +0 -1
- package/dist/cli/commands/route.js +3 -3
- package/dist/cli/commands/schema.js +62 -92
- package/dist/cli/commands/state/decisions.js +0 -1
- package/dist/cli/commands/state/docs.js +0 -1
- package/dist/cli/commands/state/experimentRecords.js +0 -1
- package/dist/cli/commands/state/experiments.js +0 -1
- package/dist/cli/commands/state/get.js +0 -1
- package/dist/cli/commands/state/health.js +0 -1
- package/dist/cli/commands/state/index.js +0 -1
- package/dist/cli/commands/state/list.js +0 -1
- package/dist/cli/commands/state/objective.js +0 -1
- package/dist/cli/commands/state/plan.js +0 -1
- package/dist/cli/commands/state/planTasks.js +0 -1
- package/dist/cli/commands/state/plans.js +0 -1
- package/dist/cli/commands/state/progress.js +0 -1
- package/dist/cli/commands/state/shared.js +0 -1
- package/dist/cli/commands/state/todo.js +0 -1
- package/dist/cli/commands/state/write.js +10 -1
- package/dist/cli/commands/upgrade.js +0 -1
- package/dist/cli/commands/upgradeVerify.js +0 -1
- package/dist/cli/commands/validate.js +106 -10
- package/dist/cli/commands/verify.js +0 -1
- package/dist/cli/contracts/bundleStatus.js +0 -1
- package/dist/cli/contracts/orientationState.js +0 -1
- package/dist/cli/dispatch/argvParser.js +0 -1
- package/dist/cli/dispatch/check.js +6 -24
- package/dist/cli/dispatch/commands.js +3 -3
- package/dist/cli/dispatch/index.js +9 -36
- package/dist/cli/dispatch/lifecycle.js +11 -57
- package/dist/cli/dispatch/prime.js +0 -1
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +0 -1
- package/dist/cli/dispatch/state.js +0 -1
- package/dist/cli/dispatch.js +0 -1
- package/dist/cli/errors.js +0 -1
- package/dist/cli/help.js +51 -30
- package/dist/cli/migrationRequired.js +3 -5
- package/dist/cli/orientation/attention.js +4 -17
- package/dist/cli/orientation/corpusCoverage.js +0 -1
- package/dist/cli/orientation.js +5 -5
- package/dist/cli/planArtifacts.js +0 -1
- package/dist/cli/planEvidence.js +0 -1
- package/dist/cli/planLifecycleState.js +2 -2
- package/dist/cli/planTaskIndex.js +0 -1
- package/dist/cli/preCutoverCommand.js +32 -0
- package/dist/cli/prime-blob.js +6 -6
- package/dist/cli/profileAcquisition.js +0 -1
- package/dist/cli/startupCompletenessContract.js +0 -1
- package/dist/cli/stateQuery.js +17 -21
- package/dist/cli/structured.js +0 -1
- package/dist/cli/todoMarkdown.js +0 -1
- package/dist/cli/todoReadinessSelection.js +2 -2
- package/dist/cli/todoSeverity.js +0 -1
- package/dist/core/atomicWriter.js +0 -1
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +374 -0
- package/dist/core/difflib.js +0 -1
- package/dist/core/envPaths.js +0 -1
- package/dist/core/jsonValue.js +0 -1
- package/dist/core/paths.js +0 -1
- package/dist/core/pyjson.js +0 -1
- package/dist/core/shell.js +0 -1
- package/dist/core/skillIdentity.js +0 -1
- package/dist/core/sourceRoot.js +9 -12
- package/dist/core/text.js +0 -1
- package/dist/core/toml.js +0 -1
- package/dist/core/yaml.js +0 -1
- package/dist/eval/evalSkills.js +0 -1
- package/dist/eval/hybridRouteEvaluation.js +0 -1
- package/dist/eval/semanticEval.js +0 -1
- package/dist/eval/semanticFixtures.js +0 -1
- package/dist/hooks/common.js +1 -54
- package/dist/hooks/compaction/apply.js +0 -1
- package/dist/hooks/compaction/dryRun.js +0 -1
- package/dist/hooks/compaction/index.js +1 -2
- package/dist/hooks/compaction/parse.js +0 -1
- package/dist/hooks/compaction/retention.js +0 -1
- package/dist/hooks/compaction/status.js +0 -1
- package/dist/hooks/compaction/types.js +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js +0 -1
- package/dist/hooks/validateArtifact/index.js +6 -65
- package/dist/hooks/validateArtifact/markdown.js +0 -1
- package/dist/hooks/validateArtifact/schema.js +0 -1
- package/dist/hooks/validateArtifact/traversal.js +0 -1
- package/dist/hooks/validateArtifact/violations.js +0 -1
- package/dist/migrate/v2HandoffManifest.js +0 -3
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +106 -0
- package/dist/registries/artifactProtocolIds.js +0 -1
- package/dist/registries/artifactRegistry.js +0 -1
- package/dist/registries/artifactSchemaProjection.js +0 -1
- package/dist/registries/capabilityContract.js +0 -1
- package/dist/registries/evaluatorHandoffContract.js +0 -1
- package/dist/registries/evidenceTierContract.js +0 -1
- package/dist/registries/glossaryAdviceContract.js +2 -2
- package/dist/registries/glossaryCaveatContract.js +0 -1
- package/dist/registries/glossaryConsumerContractValidation.js +5 -6
- package/dist/registries/glossaryEntryContract.js +8 -8
- package/dist/registries/glossaryTermIdentity.js +0 -1
- package/dist/registries/glossaryTermOccurrence.js +0 -1
- package/dist/registries/hybridRoute.js +73 -2
- package/dist/registries/hybridRouteReceipt.js +2 -2
- package/dist/registries/packagePublication.js +229 -0
- package/dist/registries/packageRegistry.js +118 -2
- package/dist/registries/todoReadinessContract.js +0 -1
- package/dist/registries/triggerLoader.js +0 -1
- package/dist/registries/verbosityBudgetContract.js +0 -1
- package/dist/release/releaseMetadata.js +69 -3
- package/dist/runtime/lifecycleAdapterContract.js +0 -1
- package/dist/runtime/lifecycleAdapters.js +0 -1
- package/dist/runtime/lifecycleAuthority.js +0 -1
- package/dist/runtime/lifecycleOperationContract.js +12 -3
- package/dist/runtime/lifecycleOperations.js +0 -1
- package/dist/runtime/lifecycleOwnershipJournal.js +0 -1
- package/dist/runtime/lifecyclePublication.js +0 -1
- package/dist/runtime/lifecycleSnapshot.js +0 -1
- package/dist/runtime/nativeResourceCleanup.js +191 -6
- package/dist/setup/opencode.js +0 -1
- package/dist/setup/opencodeConstants.js +0 -1
- package/dist/setup/sharedSkill.js +0 -1
- package/dist/setup/smokeChecks.js +1 -33
- package/dist/state/archiveDiscovery.js +0 -1
- package/dist/state/archivePublication.js +0 -1
- package/dist/state/archiveRecovery.js +0 -1
- package/dist/state/archiveReplay.js +0 -1
- package/dist/state/canonicalMigrationRecord.js +0 -1
- package/dist/state/changelog.js +0 -1
- package/dist/state/decisionEntities.js +0 -1
- package/dist/state/decisionLegacyValidation.js +0 -1
- package/dist/state/decisionMigrationProvenance.js +0 -1
- package/dist/state/decisionOverlay.js +0 -1
- package/dist/state/decisionRevision.js +0 -1
- package/dist/state/decisionRevisionMigration.js +0 -1
- package/dist/state/directRetrieval.js +0 -1
- package/dist/state/durability.js +0 -1
- package/dist/state/entityCutover.js +174 -9
- package/dist/state/entityCutoverGit.js +0 -1
- package/dist/state/entityGlossaryAuthority.js +0 -1
- package/dist/state/entityListProjection.js +0 -1
- package/dist/state/entityListRuntimeRegistry.js +46 -11
- package/dist/state/entityMigrationCausality.js +3 -5
- package/dist/state/entityMigrationIdentity.js +0 -1
- package/dist/state/entityMigrationPreview.js +35 -73
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +0 -1
- package/dist/state/entityRetrievalHelp.js +53 -23
- package/dist/state/entityStorage.js +0 -1
- package/dist/state/exactReplacementRecovery.js +0 -1
- package/dist/state/experimentArchive.js +0 -1
- package/dist/state/experimentIdentity.js +0 -1
- package/dist/state/healthEntities.js +0 -1
- package/dist/state/healthEntityValidation.js +0 -1
- package/dist/state/healthRepair.js +0 -1
- package/dist/state/installRoot.js +0 -1
- package/dist/state/legacyEntityCutoverEvidence.js +0 -1
- package/dist/state/legacyIdentity.js +0 -1
- package/dist/state/legacySummaryRecord.js +0 -1
- package/dist/state/listAccounting.js +0 -1
- package/dist/state/listClassification.js +0 -1
- package/dist/state/listCursor.js +0 -1
- package/dist/state/listRetrieval.js +0 -1
- package/dist/state/migrationSourceBinding.js +0 -1
- package/dist/state/objectiveExperimentEntities.js +0 -1
- package/dist/state/planEntities.js +0 -1
- package/dist/state/planIdentity.js +0 -1
- package/dist/state/planRetrieval.js +0 -1
- package/dist/state/planTaskRetrieval.js +0 -1
- package/dist/state/progressEntities.js +0 -1
- package/dist/state/progressGlossaryCaveat.js +0 -1
- package/dist/state/progressPublicationOrder.js +0 -1
- package/dist/state/projectRoot.js +0 -1
- package/dist/state/projectionPolicy.js +0 -1
- package/dist/state/retrievalAuthority.js +0 -1
- package/dist/state/safeProjectFile.js +0 -1
- package/dist/state/startupAnalysis/benchmark.js +0 -1
- package/dist/state/startupAnalysis/contract.js +44 -10
- package/dist/state/startupAnalysis/helpers.js +0 -1
- package/dist/state/startupAnalysis/index.js +0 -1
- package/dist/state/startupAnalysis/metrics.js +0 -1
- package/dist/state/startupAnalysis/records.js +0 -1
- package/dist/state/startupAnalysis/report.js +0 -1
- package/dist/state/startupAnalysis/threshold.js +0 -1
- package/dist/state/startupAnalysis.js +0 -1
- package/dist/state/startupProjection.js +2 -2
- package/dist/state/stateMode.js +0 -1
- package/dist/state/stateStorageAuthority.js +0 -1
- package/dist/state/summaryEntityRead.js +0 -1
- package/dist/state/summaryMigrationProvenance.js +0 -1
- package/dist/state/summarySourceRowAuthority.js +0 -1
- package/dist/state/todoDocsEntities.js +161 -83
- package/dist/state/todoDocsEntityValidation.js +0 -1
- package/dist/state/todoMarkdownProjection.js +51 -0
- package/dist/state/todoReconciliationActivation.js +73 -4
- package/dist/state/todoReconciliationInspection.js +173 -0
- package/dist/state/todoReconciliationRepair.js +170 -0
- package/dist/state/todoReconciliationTransaction.js +41 -13
- package/dist/state/write/assign.js +0 -1
- package/dist/state/write/candidateMutation.js +0 -1
- package/dist/state/write/errors.js +0 -1
- package/dist/state/write/experimentPublication.js +0 -1
- package/dist/state/write/explain.js +0 -1
- package/dist/state/write/fields.js +0 -1
- package/dist/state/write/glossaryPublication.js +0 -1
- package/dist/state/write/grammar.js +13 -4
- package/dist/state/write/helpers.js +0 -1
- package/dist/state/write/index.js +0 -1
- package/dist/state/write/input.js +0 -1
- package/dist/state/write/lock.js +0 -1
- package/dist/state/write/mutation.js +0 -1
- package/dist/state/write/operations.js +0 -1
- package/dist/state/write/planEvaluation.js +0 -1
- package/dist/state/write/planPublication.js +0 -1
- package/dist/state/write/runtimeOperations.js +83 -6
- package/dist/state/write/serialize.js +0 -1
- package/dist/state/write/transaction.js +0 -1
- package/dist/state/write/validate.js +0 -1
- package/dist/upgrade/appContentRefresh.js +0 -1
- package/dist/upgrade/appModel.js +0 -1
- package/dist/upgrade/atomicWriter.js +0 -1
- package/dist/upgrade/bundleEvidence.js +0 -1
- package/dist/upgrade/channels.js +0 -1
- package/dist/upgrade/compatibility.js +0 -1
- package/dist/upgrade/doctor.js +0 -1
- package/dist/upgrade/doctorClassifier.js +0 -1
- package/dist/upgrade/installedHooksRetirement.js +0 -1
- package/dist/upgrade/legacyAgentCleanup.js +0 -1
- package/dist/upgrade/lifecycleUpgrade.js +0 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.js +7 -15
- package/dist/upgrade/migrationPublication.js +0 -1
- package/dist/upgrade/nextMajorDoctor.js +0 -1
- package/dist/upgrade/npxPlatformStatus.js +0 -1
- package/dist/upgrade/projectIntegration.js +4 -17
- package/dist/upgrade/projectIntegrationDecision.js +0 -1
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +61 -190
- package/dist/upgrade/upgradeCommands.js +5 -1
- package/dist/upgrade/upgradeLock.js +0 -1
- package/dist/upgrade/upgradeOrchestrator.js +52 -9
- package/dist/upgrade/v3CapabilitySurface.js +0 -1
- package/dist/upgrade/versionResolution.js +0 -1
- package/dist/validate/activationArtifactEvidence.js +844 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +515 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +0 -2
- package/dist/validate/bootstrapAuthority.js +44 -0
- package/dist/validate/capability.js +0 -1
- package/dist/validate/crossCapability.js +0 -1
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +0 -1
- package/dist/validate/v1LegacyCruft.js +0 -10
- package/dist/validate/vocabularyAuthority.js +6 -8
- package/package.json +12 -5
- package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -127
- package/bundle/references/analysis/benchmark.md +0 -271
- package/bundle/references/analysis/startup-measurement-contract.yaml +0 -435
- package/bundle/references/cli/agent-ready-state-contract.yaml +0 -1015
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -395
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -241
- package/bundle/references/cli/capability-instruction-structure.md +0 -144
- package/bundle/references/cli/capability-tool-classification.yaml +0 -53
- package/bundle/references/cli/coexistence-probe.yaml +0 -13
- package/bundle/references/cli/parity-expected-actual-template.md +0 -30
- package/bundle/references/cli/prime-consumer-compatibility.yaml +0 -701
- package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -259
- package/bundle/references/cli/single-name-protocol.yaml +0 -42
- package/bundle/references/cli/upgrade-repair-wording.md +0 -25
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -97
- package/bundle/references/meta/documentation-inventory.md +0 -50
- package/bundle/skills/agentera/references/contract.md +0 -1097
- package/dist/analytics/extractCorpus/cli.js.map +0 -1
- package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/core.js.map +0 -1
- package/dist/analytics/extractCorpus/corpus.js.map +0 -1
- package/dist/analytics/extractCorpus/coverageAudit.js.map +0 -1
- package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/evidenceTiers.js.map +0 -1
- package/dist/analytics/extractCorpus/extractCorpusParity.js.map +0 -1
- package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
- package/dist/analytics/extractCorpus/index.js.map +0 -1
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteCaps.js.map +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
- package/dist/analytics/extractCorpus/tierReader.js.map +0 -1
- package/dist/analytics/extractCorpus.js.map +0 -1
- package/dist/analytics/glossaryAdviceResolution.js.map +0 -1
- package/dist/analytics/glossaryInputAcquisition.js.map +0 -1
- package/dist/analytics/personalGlossaryAdmission.js.map +0 -1
- package/dist/analytics/personalGlossaryProfile.js.map +0 -1
- package/dist/analytics/profileSignals.js.map +0 -1
- package/dist/analytics/usageStats.js.map +0 -1
- package/dist/audit/terminologyDrift.js.map +0 -1
- package/dist/bin/agentera.js.map +0 -1
- package/dist/capabilities/audit/instructions.js.map +0 -1
- package/dist/capabilities/build/instructions.js.map +0 -1
- package/dist/capabilities/design/instructions.js.map +0 -1
- package/dist/capabilities/discuss/instructions.js.map +0 -1
- package/dist/capabilities/document/instructions.js.map +0 -1
- package/dist/capabilities/index.js.map +0 -1
- package/dist/capabilities/optimize/instructions.js.map +0 -1
- package/dist/capabilities/orchestrate/instructions.js.map +0 -1
- package/dist/capabilities/plan/instructions.js.map +0 -1
- package/dist/capabilities/profile/instructions.js.map +0 -1
- package/dist/capabilities/research/instructions.js.map +0 -1
- package/dist/capabilities/status/instructions.js.map +0 -1
- package/dist/capabilities/status/startupInstructions.js.map +0 -1
- package/dist/capabilities/vision/instructions.js.map +0 -1
- package/dist/cli/appContext.js.map +0 -1
- package/dist/cli/argvalidate.js.map +0 -1
- package/dist/cli/capabilityContext/benchmark.js.map +0 -1
- package/dist/cli/capabilityContext/bespoke.js.map +0 -1
- package/dist/cli/capabilityContext/build.js.map +0 -1
- package/dist/cli/capabilityContext/closeout.js.map +0 -1
- package/dist/cli/capabilityContext/contract.js.map +0 -1
- package/dist/cli/capabilityContext/evidence.js.map +0 -1
- package/dist/cli/capabilityContext/index.js.map +0 -1
- package/dist/cli/capabilityContext/orchestration.js.map +0 -1
- package/dist/cli/capabilityContext/planState.js.map +0 -1
- package/dist/cli/capabilityContext/progress.js.map +0 -1
- package/dist/cli/capabilityContext/projectVerification.js.map +0 -1
- package/dist/cli/capabilityContext/shared.js.map +0 -1
- package/dist/cli/capabilityContext/slim.js.map +0 -1
- package/dist/cli/capabilityContext/startup.js.map +0 -1
- package/dist/cli/capabilityContext/types.js.map +0 -1
- package/dist/cli/capabilityContext.js.map +0 -1
- package/dist/cli/commands/appHome.js.map +0 -1
- package/dist/cli/commands/capability.js.map +0 -1
- package/dist/cli/commands/compact.js.map +0 -1
- package/dist/cli/commands/doctor.js.map +0 -1
- package/dist/cli/commands/durability.js.map +0 -1
- package/dist/cli/commands/entityMigrate.js +0 -132
- package/dist/cli/commands/entityMigrate.js.map +0 -1
- package/dist/cli/commands/glossaryAdvice.js.map +0 -1
- package/dist/cli/commands/lint.js.map +0 -1
- package/dist/cli/commands/personalGlossary.js.map +0 -1
- package/dist/cli/commands/prime/briefOrientation.js.map +0 -1
- package/dist/cli/commands/prime/buildExecutionRequest.js.map +0 -1
- package/dist/cli/commands/prime/bundleStatus.js.map +0 -1
- package/dist/cli/commands/prime/collectEntityOrientation.js.map +0 -1
- package/dist/cli/commands/prime/collectOrientationState.js.map +0 -1
- package/dist/cli/commands/prime/orientationOutput.js.map +0 -1
- package/dist/cli/commands/prime/types.js.map +0 -1
- package/dist/cli/commands/prime/v1Migration.js.map +0 -1
- package/dist/cli/commands/prime.js.map +0 -1
- package/dist/cli/commands/profileGrounding.js.map +0 -1
- package/dist/cli/commands/query.js.map +0 -1
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/route.js.map +0 -1
- package/dist/cli/commands/schema.js.map +0 -1
- package/dist/cli/commands/state/decisions.js.map +0 -1
- package/dist/cli/commands/state/docs.js.map +0 -1
- package/dist/cli/commands/state/experimentRecords.js.map +0 -1
- package/dist/cli/commands/state/experiments.js.map +0 -1
- package/dist/cli/commands/state/get.js.map +0 -1
- package/dist/cli/commands/state/health.js.map +0 -1
- package/dist/cli/commands/state/index.js.map +0 -1
- package/dist/cli/commands/state/list.js.map +0 -1
- package/dist/cli/commands/state/objective.js.map +0 -1
- package/dist/cli/commands/state/plan.js.map +0 -1
- package/dist/cli/commands/state/planTasks.js.map +0 -1
- package/dist/cli/commands/state/plans.js.map +0 -1
- package/dist/cli/commands/state/progress.js.map +0 -1
- package/dist/cli/commands/state/shared.js.map +0 -1
- package/dist/cli/commands/state/todo.js.map +0 -1
- package/dist/cli/commands/state/write.js.map +0 -1
- package/dist/cli/commands/upgrade.js.map +0 -1
- package/dist/cli/commands/upgradeVerify.js.map +0 -1
- package/dist/cli/commands/validate.js.map +0 -1
- package/dist/cli/commands/verify.js.map +0 -1
- package/dist/cli/contracts/bundleStatus.js.map +0 -1
- package/dist/cli/contracts/orientationState.js.map +0 -1
- package/dist/cli/dispatch/argvParser.js.map +0 -1
- package/dist/cli/dispatch/check.js.map +0 -1
- package/dist/cli/dispatch/commands.js.map +0 -1
- package/dist/cli/dispatch/index.js.map +0 -1
- package/dist/cli/dispatch/lifecycle.js.map +0 -1
- package/dist/cli/dispatch/prime.js.map +0 -1
- package/dist/cli/dispatch/shared.js.map +0 -1
- package/dist/cli/dispatch/state.js.map +0 -1
- package/dist/cli/dispatch.js.map +0 -1
- package/dist/cli/errors.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/migrationRequired.js.map +0 -1
- package/dist/cli/orientation/attention.js.map +0 -1
- package/dist/cli/orientation/corpusCoverage.js.map +0 -1
- package/dist/cli/orientation.js.map +0 -1
- package/dist/cli/planArtifacts.js.map +0 -1
- package/dist/cli/planEvidence.js.map +0 -1
- package/dist/cli/planLifecycleState.js.map +0 -1
- package/dist/cli/planTaskIndex.js.map +0 -1
- package/dist/cli/prime-blob.js.map +0 -1
- package/dist/cli/profileAcquisition.js.map +0 -1
- package/dist/cli/startupCompletenessContract.js.map +0 -1
- package/dist/cli/stateQuery.js.map +0 -1
- package/dist/cli/structured.js.map +0 -1
- package/dist/cli/todoMarkdown.js.map +0 -1
- package/dist/cli/todoReadinessSelection.js.map +0 -1
- package/dist/cli/todoSeverity.js.map +0 -1
- package/dist/core/atomicWriter.js.map +0 -1
- package/dist/core/difflib.js.map +0 -1
- package/dist/core/envPaths.js.map +0 -1
- package/dist/core/jsonValue.js.map +0 -1
- package/dist/core/paths.js.map +0 -1
- package/dist/core/pyjson.js.map +0 -1
- package/dist/core/shell.js.map +0 -1
- package/dist/core/skillIdentity.js.map +0 -1
- package/dist/core/sourceRoot.js.map +0 -1
- package/dist/core/text.js.map +0 -1
- package/dist/core/toml.js.map +0 -1
- package/dist/core/yaml.js.map +0 -1
- package/dist/eval/evalSkills.js.map +0 -1
- package/dist/eval/hybridRouteEvaluation.js.map +0 -1
- package/dist/eval/semanticEval.js.map +0 -1
- package/dist/eval/semanticFixtures.js.map +0 -1
- package/dist/hooks/common.js.map +0 -1
- package/dist/hooks/compaction/apply.js.map +0 -1
- package/dist/hooks/compaction/dryRun.js.map +0 -1
- package/dist/hooks/compaction/index.js.map +0 -1
- package/dist/hooks/compaction/parse.js.map +0 -1
- package/dist/hooks/compaction/retention.js.map +0 -1
- package/dist/hooks/compaction/status.js.map +0 -1
- package/dist/hooks/compaction/types.js.map +0 -1
- package/dist/hooks/cursorPreToolUse.js +0 -19
- package/dist/hooks/cursorPreToolUse.js.map +0 -1
- package/dist/hooks/cursorSessionStart.js +0 -64
- package/dist/hooks/cursorSessionStart.js.map +0 -1
- package/dist/hooks/projectHookInput.js +0 -26
- package/dist/hooks/projectHookInput.js.map +0 -1
- package/dist/hooks/sessionStart.js +0 -94
- package/dist/hooks/sessionStart.js.map +0 -1
- package/dist/hooks/sessionStop.js +0 -198
- package/dist/hooks/sessionStop.js.map +0 -1
- package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
- package/dist/hooks/validateArtifact/index.js.map +0 -1
- package/dist/hooks/validateArtifact/markdown.js.map +0 -1
- package/dist/hooks/validateArtifact/runtime.js +0 -86
- package/dist/hooks/validateArtifact/runtime.js.map +0 -1
- package/dist/hooks/validateArtifact/schema.js.map +0 -1
- package/dist/hooks/validateArtifact/traversal.js.map +0 -1
- package/dist/hooks/validateArtifact/violations.js.map +0 -1
- package/dist/migrate/v2HandoffManifest.js.map +0 -1
- package/dist/registries/artifactProtocolIds.js.map +0 -1
- package/dist/registries/artifactRegistry.js.map +0 -1
- package/dist/registries/artifactSchemaProjection.js.map +0 -1
- package/dist/registries/capabilityContract.js.map +0 -1
- package/dist/registries/evaluatorHandoffContract.js.map +0 -1
- package/dist/registries/evidenceTierContract.js.map +0 -1
- package/dist/registries/glossaryAdviceContract.js.map +0 -1
- package/dist/registries/glossaryCaveatContract.js.map +0 -1
- package/dist/registries/glossaryConsumerContractValidation.js.map +0 -1
- package/dist/registries/glossaryEntryContract.js.map +0 -1
- package/dist/registries/glossaryTermIdentity.js.map +0 -1
- package/dist/registries/glossaryTermOccurrence.js.map +0 -1
- package/dist/registries/hybridRoute.js.map +0 -1
- package/dist/registries/hybridRouteReceipt.js.map +0 -1
- package/dist/registries/packageRegistry.js.map +0 -1
- package/dist/registries/todoReadinessContract.js.map +0 -1
- package/dist/registries/triggerLoader.js.map +0 -1
- package/dist/registries/verbosityBudgetContract.js.map +0 -1
- package/dist/release/releaseMetadata.js.map +0 -1
- package/dist/runtime/lifecycleAdapterContract.js.map +0 -1
- package/dist/runtime/lifecycleAdapters.js.map +0 -1
- package/dist/runtime/lifecycleAuthority.js.map +0 -1
- package/dist/runtime/lifecycleOperationContract.js.map +0 -1
- package/dist/runtime/lifecycleOperations.js.map +0 -1
- package/dist/runtime/lifecycleOwnershipJournal.js.map +0 -1
- package/dist/runtime/lifecyclePublication.js.map +0 -1
- package/dist/runtime/lifecycleSnapshot.js.map +0 -1
- package/dist/runtime/nativeResourceCleanup.js.map +0 -1
- package/dist/setup/codex/cli.js +0 -130
- package/dist/setup/codex/cli.js.map +0 -1
- package/dist/setup/codex/configToml.js +0 -558
- package/dist/setup/codex/configToml.js.map +0 -1
- package/dist/setup/codex/constants.js +0 -14
- package/dist/setup/codex/constants.js.map +0 -1
- package/dist/setup/codex/installRoot.js +0 -64
- package/dist/setup/codex/installRoot.js.map +0 -1
- package/dist/setup/codex/state.js +0 -252
- package/dist/setup/codex/state.js.map +0 -1
- package/dist/setup/codex.js +0 -10
- package/dist/setup/codex.js.map +0 -1
- package/dist/setup/opencode.js.map +0 -1
- package/dist/setup/opencodeConstants.js.map +0 -1
- package/dist/setup/sharedSkill.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/archiveDiscovery.js.map +0 -1
- package/dist/state/archivePublication.js.map +0 -1
- package/dist/state/archiveRecovery.js.map +0 -1
- package/dist/state/archiveReplay.js.map +0 -1
- package/dist/state/canonicalMigrationRecord.js.map +0 -1
- package/dist/state/changelog.js.map +0 -1
- package/dist/state/decisionEntities.js.map +0 -1
- package/dist/state/decisionLegacyValidation.js.map +0 -1
- package/dist/state/decisionMigrationProvenance.js.map +0 -1
- package/dist/state/decisionOverlay.js.map +0 -1
- package/dist/state/decisionRevision.js.map +0 -1
- package/dist/state/decisionRevisionMigration.js.map +0 -1
- package/dist/state/directRetrieval.js.map +0 -1
- package/dist/state/durability.js.map +0 -1
- package/dist/state/entityCutover.js.map +0 -1
- package/dist/state/entityCutoverGit.js.map +0 -1
- package/dist/state/entityGlossaryAuthority.js.map +0 -1
- package/dist/state/entityListProjection.js.map +0 -1
- package/dist/state/entityListRuntimeRegistry.js.map +0 -1
- package/dist/state/entityMigrationCausality.js.map +0 -1
- package/dist/state/entityMigrationIdentity.js.map +0 -1
- package/dist/state/entityMigrationPreview.js.map +0 -1
- package/dist/state/entityPublicationContext.js.map +0 -1
- package/dist/state/entityRetrievalHelp.js.map +0 -1
- package/dist/state/entityStorage.js.map +0 -1
- package/dist/state/exactReplacementRecovery.js.map +0 -1
- package/dist/state/experimentArchive.js.map +0 -1
- package/dist/state/experimentIdentity.js.map +0 -1
- package/dist/state/healthEntities.js.map +0 -1
- package/dist/state/healthEntityValidation.js.map +0 -1
- package/dist/state/healthRepair.js.map +0 -1
- package/dist/state/installRoot.js.map +0 -1
- package/dist/state/legacyEntityCutoverEvidence.js.map +0 -1
- package/dist/state/legacyIdentity.js.map +0 -1
- package/dist/state/legacySummaryRecord.js.map +0 -1
- package/dist/state/listAccounting.js.map +0 -1
- package/dist/state/listClassification.js.map +0 -1
- package/dist/state/listCursor.js.map +0 -1
- package/dist/state/listRetrieval.js.map +0 -1
- package/dist/state/migrationSourceBinding.js.map +0 -1
- package/dist/state/objectiveExperimentEntities.js.map +0 -1
- package/dist/state/planEntities.js.map +0 -1
- package/dist/state/planIdentity.js.map +0 -1
- package/dist/state/planRetrieval.js.map +0 -1
- package/dist/state/planTaskRetrieval.js.map +0 -1
- package/dist/state/progressEntities.js.map +0 -1
- package/dist/state/progressGlossaryCaveat.js.map +0 -1
- package/dist/state/progressPublicationOrder.js.map +0 -1
- package/dist/state/projectRoot.js.map +0 -1
- package/dist/state/projectionPolicy.js.map +0 -1
- package/dist/state/retrievalAuthority.js.map +0 -1
- package/dist/state/safeProjectFile.js.map +0 -1
- package/dist/state/startupAnalysis/benchmark.js.map +0 -1
- package/dist/state/startupAnalysis/contract.js.map +0 -1
- package/dist/state/startupAnalysis/helpers.js.map +0 -1
- package/dist/state/startupAnalysis/index.js.map +0 -1
- package/dist/state/startupAnalysis/metrics.js.map +0 -1
- package/dist/state/startupAnalysis/records.js.map +0 -1
- package/dist/state/startupAnalysis/report.js.map +0 -1
- package/dist/state/startupAnalysis/threshold.js.map +0 -1
- package/dist/state/startupAnalysis.js.map +0 -1
- package/dist/state/startupProjection.js.map +0 -1
- package/dist/state/stateMode.js.map +0 -1
- package/dist/state/stateStorageAuthority.js.map +0 -1
- package/dist/state/summaryEntityRead.js.map +0 -1
- package/dist/state/summaryMigrationProvenance.js.map +0 -1
- package/dist/state/summarySourceRowAuthority.js.map +0 -1
- package/dist/state/todoDocsEntities.js.map +0 -1
- package/dist/state/todoDocsEntityValidation.js.map +0 -1
- package/dist/state/todoReconciliationActivation.js.map +0 -1
- package/dist/state/todoReconciliationTransaction.js.map +0 -1
- package/dist/state/write/assign.js.map +0 -1
- package/dist/state/write/candidateMutation.js.map +0 -1
- package/dist/state/write/errors.js.map +0 -1
- package/dist/state/write/experimentPublication.js.map +0 -1
- package/dist/state/write/explain.js.map +0 -1
- package/dist/state/write/fields.js.map +0 -1
- package/dist/state/write/glossaryPublication.js.map +0 -1
- package/dist/state/write/grammar.js.map +0 -1
- package/dist/state/write/helpers.js.map +0 -1
- package/dist/state/write/index.js.map +0 -1
- package/dist/state/write/input.js.map +0 -1
- package/dist/state/write/lock.js.map +0 -1
- package/dist/state/write/mutation.js.map +0 -1
- package/dist/state/write/operations.js.map +0 -1
- package/dist/state/write/planEvaluation.js.map +0 -1
- package/dist/state/write/planPublication.js.map +0 -1
- package/dist/state/write/runtimeOperations.js.map +0 -1
- package/dist/state/write/serialize.js.map +0 -1
- package/dist/state/write/transaction.js.map +0 -1
- package/dist/state/write/validate.js.map +0 -1
- package/dist/upgrade/appContentRefresh.js.map +0 -1
- package/dist/upgrade/appModel.js.map +0 -1
- package/dist/upgrade/atomicWriter.js.map +0 -1
- package/dist/upgrade/bundleEvidence.js.map +0 -1
- package/dist/upgrade/channels.js.map +0 -1
- package/dist/upgrade/coexistenceProbe.js +0 -105
- package/dist/upgrade/coexistenceProbe.js.map +0 -1
- package/dist/upgrade/compatibility.js.map +0 -1
- package/dist/upgrade/doctor.js.map +0 -1
- package/dist/upgrade/doctorClassifier.js.map +0 -1
- package/dist/upgrade/installedHooksRetirement.js.map +0 -1
- package/dist/upgrade/legacyAgentCleanup.js.map +0 -1
- package/dist/upgrade/lifecycleUpgrade.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +0 -1
- package/dist/upgrade/migrationPublication.js.map +0 -1
- package/dist/upgrade/nextMajorDoctor.js.map +0 -1
- package/dist/upgrade/npxPlatformStatus.js.map +0 -1
- package/dist/upgrade/projectIntegration.js.map +0 -1
- package/dist/upgrade/projectIntegrationDecision.js.map +0 -1
- package/dist/upgrade/runtimeMigration.js.map +0 -1
- package/dist/upgrade/upgradeCommands.js.map +0 -1
- package/dist/upgrade/upgradeLock.js.map +0 -1
- package/dist/upgrade/upgradeOrchestrator.js.map +0 -1
- package/dist/upgrade/v3CapabilitySurface.js.map +0 -1
- package/dist/upgrade/versionResolution.js.map +0 -1
- package/dist/validate/appHomeContract.js.map +0 -1
- package/dist/validate/capability.js.map +0 -1
- package/dist/validate/crossCapability.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- package/dist/validate/v1LegacyCruft.js.map +0 -1
- package/dist/validate/vocabularyAuthority.js.map +0 -1
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveSourceRoot } from "../core/sourceRoot.js";
|
|
4
|
+
import { renderTodoPublicRecord } from "../cli/todoMarkdown.js";
|
|
5
|
+
import { canonicalRecordJson } from "./archiveDiscovery.js";
|
|
6
|
+
import { detectStateMode } from "./stateMode.js";
|
|
7
|
+
import { StateWriteInputError } from "./write/errors.js";
|
|
8
|
+
import { TODO_ACTIVATION_APPLY_COMMAND, TODO_ACTIVATION_PREVIEW_COMMAND, TODO_RECONCILIATION_ACTIVATION_PATH, TODO_REPAIR_APPLY_COMMAND, TODO_REPAIR_PREVIEW_COMMAND, loadTodoReconciliationActivation, todoReconciliationActivationBytes, } from "./todoReconciliationActivation.js";
|
|
9
|
+
import { planTodoRepair } from "./todoReconciliationRepair.js";
|
|
10
|
+
import { readTodoMarkdown } from "./todoMarkdownProjection.js";
|
|
11
|
+
import { managedRows, relevant, todoPublicPath } from "./todoDocsEntities.js";
|
|
12
|
+
const DIAGNOSTIC_LIMIT = 20;
|
|
13
|
+
function mapping(value) {
|
|
14
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function numberValue(value) {
|
|
17
|
+
return Number.isSafeInteger(value) && Number(value) >= 0 ? Number(value) : 0;
|
|
18
|
+
}
|
|
19
|
+
function boundedCounts(value) {
|
|
20
|
+
const raw = {
|
|
21
|
+
matched: numberValue(value.matched),
|
|
22
|
+
converted: numberValue(value.converted),
|
|
23
|
+
retained: numberValue(value.retained),
|
|
24
|
+
duplicate: numberValue(value.duplicate),
|
|
25
|
+
stale: numberValue(value.stale),
|
|
26
|
+
conflicting: numberValue(value.conflicting),
|
|
27
|
+
};
|
|
28
|
+
const counts = Object.fromEntries(Object.entries(raw).map(([key, count]) => [key, Math.min(count, DIAGNOSTIC_LIMIT)]));
|
|
29
|
+
const omitted = Object.values(raw).reduce((total, count) => total + Math.max(0, count - DIAGNOSTIC_LIMIT), numberValue(value.omitted_count));
|
|
30
|
+
return { ...counts, omitted: Math.min(DIAGNOSTIC_LIMIT, omitted) };
|
|
31
|
+
}
|
|
32
|
+
function recovery(preview, apply) {
|
|
33
|
+
return `Run exactly '${preview}', review its bounded read-only effect, then run exactly the preview's exact apply_command (the supported form is '${apply}'); no state was changed.`;
|
|
34
|
+
}
|
|
35
|
+
function invalidLifecycle() {
|
|
36
|
+
return {
|
|
37
|
+
state: "invalid_lifecycle",
|
|
38
|
+
status: "action_required",
|
|
39
|
+
counts: { matched: 0, converted: 0, retained: 0, duplicate: 0, stale: 0, conflicting: 0 },
|
|
40
|
+
omitted_count: 0,
|
|
41
|
+
preview_command: null,
|
|
42
|
+
apply_command: null,
|
|
43
|
+
recovery_command: "Restore the valid committed TODO reconciliation lifecycle metadata, then rerun `npx -y agentera@next check validate state --format json`; no state was changed.",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function inspection(state, rawCounts) {
|
|
47
|
+
const bounded = boundedCounts(rawCounts);
|
|
48
|
+
const active = state === "healthy_active" || state === "unsafe_active";
|
|
49
|
+
const preview = state === "inactive" ? TODO_ACTIVATION_PREVIEW_COMMAND : active ? TODO_REPAIR_PREVIEW_COMMAND : null;
|
|
50
|
+
const apply = state === "inactive" ? TODO_ACTIVATION_APPLY_COMMAND : active ? TODO_REPAIR_APPLY_COMMAND : null;
|
|
51
|
+
return {
|
|
52
|
+
state,
|
|
53
|
+
status: state === "healthy_active" ? "operable" : "action_required",
|
|
54
|
+
counts: {
|
|
55
|
+
matched: bounded.matched,
|
|
56
|
+
converted: bounded.converted,
|
|
57
|
+
retained: bounded.retained,
|
|
58
|
+
duplicate: bounded.duplicate,
|
|
59
|
+
stale: bounded.stale,
|
|
60
|
+
conflicting: bounded.conflicting,
|
|
61
|
+
},
|
|
62
|
+
omitted_count: bounded.omitted,
|
|
63
|
+
preview_command: preview,
|
|
64
|
+
apply_command: apply,
|
|
65
|
+
recovery_command: preview && apply ? recovery(preview, apply) : "",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function errorCounts(error) {
|
|
69
|
+
if (!(error instanceof StateWriteInputError) || !mapping(error.body.diagnosis))
|
|
70
|
+
return { conflicting: 1 };
|
|
71
|
+
const diagnosis = error.body.diagnosis;
|
|
72
|
+
return {
|
|
73
|
+
...(mapping(diagnosis.counts) ? diagnosis.counts : { conflicting: 1 }),
|
|
74
|
+
...(diagnosis.omitted_count !== undefined ? { omitted_count: diagnosis.omitted_count } : {}),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Read-only classification shared by prime, doctor, and whole-state validation. */
|
|
78
|
+
export function inspectTodoReconciliationState(root, sourceRoot = resolveSourceRoot(), discovery) {
|
|
79
|
+
try {
|
|
80
|
+
if (detectStateMode(root, sourceRoot) !== "entities")
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return invalidLifecycle();
|
|
85
|
+
}
|
|
86
|
+
const activationPath = path.join(root, TODO_RECONCILIATION_ACTIVATION_PATH);
|
|
87
|
+
if (!fs.existsSync(activationPath)) {
|
|
88
|
+
try {
|
|
89
|
+
if (!fs.existsSync(todoPublicPath(root, sourceRoot)))
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const entities = relevant(root, sourceRoot, "todo", discovery).filter(({ boundary }) => boundary === "todo_item");
|
|
97
|
+
let activation;
|
|
98
|
+
try {
|
|
99
|
+
activation = loadTodoReconciliationActivation(root);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return invalidLifecycle();
|
|
103
|
+
}
|
|
104
|
+
if (!activation) {
|
|
105
|
+
try {
|
|
106
|
+
const scan = managedRows(readTodoMarkdown(todoPublicPath(root, sourceRoot)).text, null, entities);
|
|
107
|
+
const entityIds = new Set(entities.map(({ id }) => id));
|
|
108
|
+
const orphaned = [...scan.rows.keys()].filter((id) => !entityIds.has(id)).length;
|
|
109
|
+
return inspection("inactive", {
|
|
110
|
+
matched: scan.matchedRows,
|
|
111
|
+
converted: scan.convertedRows,
|
|
112
|
+
retained: scan.retainedLegacyRows.length,
|
|
113
|
+
conflicting: orphaned,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return inspection("inactive", errorCounts(error));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const plan = planTodoRepair(readTodoMarkdown(todoPublicPath(root, sourceRoot)).text, activation.record, entities);
|
|
122
|
+
const counts = mapping(plan.diagnosis.counts) ? plan.diagnosis.counts : {};
|
|
123
|
+
const unsafe = numberValue(counts.duplicate) > 0 || numberValue(counts.stale) > 0 || numberValue(counts.conflicting) > 0;
|
|
124
|
+
return inspection(unsafe ? "unsafe_active" : "healthy_active", counts);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return inspection("unsafe_active", errorCounts(error));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function publicSnapshot(record, order) {
|
|
131
|
+
return { present: true, description: renderTodoPublicRecord(record), severity: String(record.severity), status: String(record.status), ...(order === undefined ? {} : { order }) };
|
|
132
|
+
}
|
|
133
|
+
function baseline(record) {
|
|
134
|
+
const reconciliation = record.reconciliation;
|
|
135
|
+
if (!mapping(reconciliation) || reconciliation.schema_version !== "agentera.todoReconciliation.v1" || !mapping(reconciliation.public))
|
|
136
|
+
return null;
|
|
137
|
+
return structuredClone(reconciliation.public);
|
|
138
|
+
}
|
|
139
|
+
function rowSnapshot(row, record) {
|
|
140
|
+
return { ...row.snapshot, severity: row.section === "resolved" ? String(record.severity) : row.snapshot.severity };
|
|
141
|
+
}
|
|
142
|
+
function samePublic(left, right, includeOrder = true) {
|
|
143
|
+
const fields = includeOrder ? ["present", "description", "severity", "status", "order"] : ["present", "description", "severity", "status"];
|
|
144
|
+
return fields.every((field) => left[field] === right[field]);
|
|
145
|
+
}
|
|
146
|
+
export function todoCutoverPublicProjectionViolations(markdown, targets) {
|
|
147
|
+
let rows;
|
|
148
|
+
try {
|
|
149
|
+
const activation = JSON.parse(todoReconciliationActivationBytes([]));
|
|
150
|
+
rows = managedRows(markdown, activation, targets.map(({ id, record }) => ({ boundary: "todo_item", id, record }))).rows;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
return [error instanceof StateWriteInputError ? error.body.message : error.message];
|
|
154
|
+
}
|
|
155
|
+
const targetIds = new Set(targets.map(({ id }) => id));
|
|
156
|
+
if (targetIds.size !== targets.length)
|
|
157
|
+
return ["pending TODO cutover target IDs are not unique"];
|
|
158
|
+
const unexpected = [...rows.keys()].find((id) => !targetIds.has(id));
|
|
159
|
+
if (unexpected)
|
|
160
|
+
return [`final managed TODO Markdown ID '${unexpected}' has no journal entity target`];
|
|
161
|
+
for (const { id, record } of targets) {
|
|
162
|
+
const row = rows.get(id);
|
|
163
|
+
if (!row)
|
|
164
|
+
return [`journal TODO entity '${id}' has no final managed Markdown row`];
|
|
165
|
+
const projected = rowSnapshot(row, record);
|
|
166
|
+
const prior = baseline(record);
|
|
167
|
+
if (!prior || canonicalRecordJson(prior) !== canonicalRecordJson(projected))
|
|
168
|
+
return [`journal TODO entity '${id}' has no exact final public baseline`];
|
|
169
|
+
if (!samePublic(publicSnapshot(record), projected, false))
|
|
170
|
+
return [`journal TODO entity '${id}' public values do not match its final managed Markdown row`];
|
|
171
|
+
}
|
|
172
|
+
return rows.size === targets.length ? [] : ["final managed TODO Markdown rows do not match the journal entity target set"];
|
|
173
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { parseTodoMarkdownListItem, renderTodoPublicRecord } from "../cli/todoMarkdown.js";
|
|
2
|
+
import { reject } from "./write/errors.js";
|
|
3
|
+
import { todoLegacyRowFingerprint, TODO_REPAIR_PREVIEW_COMMAND } from "./todoReconciliationActivation.js";
|
|
4
|
+
const RECONCILIATION_VERSION = "agentera.todoReconciliation.v1";
|
|
5
|
+
const DIAGNOSTIC_LIMIT = 20;
|
|
6
|
+
function mapping(value) { return value !== null && typeof value === "object" && !Array.isArray(value); }
|
|
7
|
+
function severity(section) { return ["critical", "degraded", "normal", "annoying"].includes(section) ? section : null; }
|
|
8
|
+
function baseline(record) {
|
|
9
|
+
const reconciliation = mapping(record.reconciliation) ? record.reconciliation : null;
|
|
10
|
+
const value = reconciliation?.schema_version === RECONCILIATION_VERSION && mapping(reconciliation.public) ? reconciliation.public : null;
|
|
11
|
+
return value && typeof value.present === "boolean" ? structuredClone(value) : null;
|
|
12
|
+
}
|
|
13
|
+
function publicSnapshot(record) { return { present: true, description: renderTodoPublicRecord(record), severity: String(record.severity), status: String(record.status) }; }
|
|
14
|
+
function rowSnapshot(row, record) { return { ...row.snapshot, severity: row.section === "resolved" ? String(record.severity) : row.snapshot.severity }; }
|
|
15
|
+
function samePublic(left, right) { return ["present", "description", "severity", "status"].every((field) => left[field] === right[field]); }
|
|
16
|
+
function withBaseline(record, value) { return { ...record, reconciliation: { schema_version: RECONCILIATION_VERSION, public: Object.fromEntries(Object.entries(value).filter(([, field]) => field !== undefined)) } }; }
|
|
17
|
+
function importMarkdown(record, row) {
|
|
18
|
+
const result = structuredClone(record);
|
|
19
|
+
const description = row.item.public_description ?? row.item.description;
|
|
20
|
+
if (result.title !== undefined) {
|
|
21
|
+
result.kind = row.item.kind ?? result.kind;
|
|
22
|
+
result.target_version = row.item.target_version ?? null;
|
|
23
|
+
result.title = row.item.title ?? description;
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
result.description = description;
|
|
27
|
+
if (row.section !== "resolved")
|
|
28
|
+
result.severity = row.snapshot.severity;
|
|
29
|
+
result.status = row.item.status;
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function rowFor(id, record) { return `- [${record.status === "resolved" ? "x" : " "}] [id:${id}] ${renderTodoPublicRecord(record)}`; }
|
|
33
|
+
function scanRows(markdown) {
|
|
34
|
+
const managed = new Map();
|
|
35
|
+
const legacy = [];
|
|
36
|
+
const order = new Map();
|
|
37
|
+
let section = null;
|
|
38
|
+
markdown.split(/\r?\n/).forEach((line, index) => {
|
|
39
|
+
const heading = line.trim().match(/^##\s+(.+)$/)?.[1]?.toLowerCase();
|
|
40
|
+
if (heading)
|
|
41
|
+
section = heading.includes("critical") ? "critical" : heading.includes("degraded") ? "degraded" : heading.includes("annoying") ? "annoying" : heading.includes("resolved") ? "resolved" : heading.includes("normal") ? "normal" : heading === "notes" ? null : section;
|
|
42
|
+
const item = parseTodoMarkdownListItem(line.trim());
|
|
43
|
+
if (!item)
|
|
44
|
+
return;
|
|
45
|
+
const rowSeverity = section ? severity(section) : null;
|
|
46
|
+
if (item.id && !rowSeverity && section !== "resolved")
|
|
47
|
+
reject({ class: "conflict", message: `TODO repair found managed ID '${item.id}' outside a managed section`, recovery: `Move '${item.id}' under one declared TODO severity or the resolved section, then preview repair again; no state was changed.` });
|
|
48
|
+
if (!section)
|
|
49
|
+
return;
|
|
50
|
+
const key = section === "resolved" ? "resolved" : rowSeverity;
|
|
51
|
+
const publicOrder = (order.get(key) ?? 0) + 1;
|
|
52
|
+
order.set(key, publicOrder);
|
|
53
|
+
const row = { line: index, section: key, sourceLine: line, item, snapshot: { present: true, description: item.public_description ?? item.description, ...(section === "resolved" ? {} : { severity: rowSeverity }), status: item.status, order: publicOrder } };
|
|
54
|
+
if (item.id) {
|
|
55
|
+
const rows = managed.get(item.id) ?? [];
|
|
56
|
+
rows.push({ ...row, id: item.id });
|
|
57
|
+
managed.set(item.id, rows);
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
legacy.push(row);
|
|
61
|
+
});
|
|
62
|
+
return { managed, legacy };
|
|
63
|
+
}
|
|
64
|
+
export function planTodoRepair(markdown, activation, entities) {
|
|
65
|
+
const { managed, legacy } = scanRows(markdown);
|
|
66
|
+
const retained = new Set(activation.retained_legacy_rows);
|
|
67
|
+
const retainedRows = [];
|
|
68
|
+
const conflicts = [];
|
|
69
|
+
for (const row of legacy) {
|
|
70
|
+
const fingerprint = todoLegacyRowFingerprint(row.section, row.sourceLine);
|
|
71
|
+
if (retained.has(fingerprint))
|
|
72
|
+
retainedRows.push(row);
|
|
73
|
+
else
|
|
74
|
+
conflicts.push(`line ${row.line + 1}: ID-less managed row has no activation provenance`);
|
|
75
|
+
}
|
|
76
|
+
for (const [id, rows] of managed) {
|
|
77
|
+
if (rows.length > 1)
|
|
78
|
+
conflicts.push(`ID '${id}' occurs at lines ${rows.map((row) => row.line + 1).join(", ")}`);
|
|
79
|
+
if (!entities.some((entity) => entity.id === id))
|
|
80
|
+
conflicts.push(`ID '${id}' has no canonical entity`);
|
|
81
|
+
}
|
|
82
|
+
const identityKey = (description, rowSeverity) => `${String(description)}\0${String(rowSeverity)}`;
|
|
83
|
+
const rowKey = (row, record) => identityKey(row.snapshot.description, row.section === "resolved" ? baseline(record)?.severity ?? record.severity : row.snapshot.severity);
|
|
84
|
+
const entityKeys = (record) => { const current = publicSnapshot(record); const keys = new Set([identityKey(current.description, current.severity)]); const prior = baseline(record); if (prior?.present)
|
|
85
|
+
keys.add(identityKey(prior.description, prior.severity)); return keys; };
|
|
86
|
+
const legacyCandidates = new Map();
|
|
87
|
+
const items = [];
|
|
88
|
+
for (const row of retainedRows) {
|
|
89
|
+
const matches = entities.filter((entity) => entity.id && entity.record && managed.get(entity.id)?.length === 1 && rowKey(managed.get(entity.id)[0], entity.record) === rowKey(row, entity.record));
|
|
90
|
+
const unproven = entities.filter((entity) => entity.id && entity.record && !managed.has(entity.id) && entityKeys(entity.record).has(rowKey(row, entity.record)));
|
|
91
|
+
legacyCandidates.set(row.line, matches);
|
|
92
|
+
if (matches.length > 1)
|
|
93
|
+
conflicts.push(`line ${row.line + 1}: retained row matches multiple canonical managed IDs`);
|
|
94
|
+
else if (matches.length === 0 && unproven.length) {
|
|
95
|
+
conflicts.push(`line ${row.line + 1}: decision legacy_without_managed_identity cannot assign canonical ID '${unproven[0].id}'`);
|
|
96
|
+
if (items.length < DIAGNOSTIC_LIMIT)
|
|
97
|
+
items.push({ decision: "legacy_without_managed_identity", id: unproven.length === 1 ? unproven[0].id : null, source_line: row.line + 1 });
|
|
98
|
+
}
|
|
99
|
+
else if (matches.length === 0 && items.length < DIAGNOSTIC_LIMIT)
|
|
100
|
+
items.push({ decision: "retained_unrelated", source_line: row.line + 1 });
|
|
101
|
+
}
|
|
102
|
+
const records = new Map();
|
|
103
|
+
const selected = new Map();
|
|
104
|
+
const remove = new Set();
|
|
105
|
+
const claimedLegacy = new Set();
|
|
106
|
+
let duplicate = 0;
|
|
107
|
+
let stale = 0;
|
|
108
|
+
let matched = 0;
|
|
109
|
+
for (const entity of entities) {
|
|
110
|
+
if (!entity.id || !entity.record)
|
|
111
|
+
continue;
|
|
112
|
+
const managedRows = managed.get(entity.id) ?? [];
|
|
113
|
+
if (managedRows.length > 1)
|
|
114
|
+
continue;
|
|
115
|
+
const managedRow = managedRows[0];
|
|
116
|
+
const candidates = retainedRows.filter((row) => legacyCandidates.get(row.line)?.length === 1 && legacyCandidates.get(row.line)?.[0]?.id === entity.id);
|
|
117
|
+
if (candidates.length > 1) {
|
|
118
|
+
conflicts.push(`ID '${entity.id}' matches retained rows at lines ${candidates.map((row) => row.line + 1).join(", ")}`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const legacyRow = candidates[0];
|
|
122
|
+
let chosen;
|
|
123
|
+
let decision;
|
|
124
|
+
if (managedRow && legacyRow) {
|
|
125
|
+
duplicate += 1;
|
|
126
|
+
decision = "duplicate_collapsed";
|
|
127
|
+
chosen = legacyRow;
|
|
128
|
+
remove.add(managedRow.line);
|
|
129
|
+
claimedLegacy.add(legacyRow.line);
|
|
130
|
+
}
|
|
131
|
+
else if (managedRow) {
|
|
132
|
+
matched += 1;
|
|
133
|
+
decision = "managed_matched";
|
|
134
|
+
chosen = managedRow;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
const prior = baseline(entity.record);
|
|
138
|
+
if (entity.record.status === "open" || prior?.present)
|
|
139
|
+
conflicts.push(`ID '${entity.id}' has no one-to-one public row`);
|
|
140
|
+
records.set(entity.id, withBaseline(entity.record, { present: false }));
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const projected = rowSnapshot(chosen, entity.record);
|
|
144
|
+
const stalePublic = !samePublic(publicSnapshot(entity.record), projected);
|
|
145
|
+
const imported = importMarkdown(entity.record, chosen);
|
|
146
|
+
if (stalePublic)
|
|
147
|
+
stale += 1;
|
|
148
|
+
records.set(entity.id, imported);
|
|
149
|
+
selected.set(entity.id, chosen);
|
|
150
|
+
if (items.length < DIAGNOSTIC_LIMIT)
|
|
151
|
+
items.push({ id: entity.id, decision, source_line: chosen.line + 1, stale_public: stalePublic });
|
|
152
|
+
}
|
|
153
|
+
for (const row of retainedRows)
|
|
154
|
+
if ((legacyCandidates.get(row.line) ?? []).length === 1 && !claimedLegacy.has(row.line))
|
|
155
|
+
conflicts.push(`line ${row.line + 1}: retained row was not claimed by its canonical entity`);
|
|
156
|
+
const retainedCount = retainedRows.filter((row) => !claimedLegacy.has(row.line)).length;
|
|
157
|
+
if (conflicts.length)
|
|
158
|
+
reject({ class: "conflict", message: `TODO repair requires complete one-to-one evidence; found ${conflicts.length} conflicting decision${conflicts.length === 1 ? "" : "s"}`, violations: [...conflicts.slice(0, DIAGNOSTIC_LIMIT), ...(conflicts.length > DIAGNOSTIC_LIMIT ? [`${conflicts.length - DIAGNOSTIC_LIMIT} additional conflicts omitted`] : [])], diagnosis: { counts: { duplicate, stale, matched, retained: retainedCount, conflicting: conflicts.length }, items, omitted_count: Math.max(0, duplicate + matched + retainedCount - items.length), conflicts_omitted_count: Math.max(0, conflicts.length - DIAGNOSTIC_LIMIT) }, recovery: `Resolve every reported identity or provenance conflict, then rerun exactly '${TODO_REPAIR_PREVIEW_COMMAND}'; no state was changed.` });
|
|
159
|
+
const replacements = new Map();
|
|
160
|
+
for (const [id, row] of selected)
|
|
161
|
+
replacements.set(row.line, rowFor(id, records.get(id)));
|
|
162
|
+
const rendered = `${markdown.split(/\r?\n/).flatMap((line, index) => remove.has(index) ? [] : [replacements.get(index) ?? line]).join("\n").replace(/\n*$/, "")}\n`;
|
|
163
|
+
const final = scanRows(rendered).managed;
|
|
164
|
+
for (const [id, record] of records) {
|
|
165
|
+
const row = final.get(id)?.[0];
|
|
166
|
+
records.set(id, withBaseline(record, row ? rowSnapshot(row, record) : { present: false }));
|
|
167
|
+
}
|
|
168
|
+
const retainedLegacyRows = retainedRows.filter((row) => !claimedLegacy.has(row.line)).map((row) => todoLegacyRowFingerprint(row.section, row.sourceLine)).sort();
|
|
169
|
+
return { records, retainedLegacyRows, rendered, diagnosis: { counts: { duplicate, stale, matched, retained: retainedLegacyRows.length, conflicting: 0 }, items, omitted_count: Math.max(0, duplicate + matched + retainedLegacyRows.length - items.length) } };
|
|
170
|
+
}
|
|
@@ -6,13 +6,14 @@ import { canonicalRecordJson } from "./archiveDiscovery.js";
|
|
|
6
6
|
import { entityExactGetMaxBytes } from "./entityStorage.js";
|
|
7
7
|
import { FILE_REPLACEMENT_METADATA_NAME, FILE_REPLACEMENT_RECOVERY_VERSION, validateEntityRecoveryDirectory, } from "./entityPublicationContext.js";
|
|
8
8
|
import { ExactReplacementConflictError, FileReplacementError } from "./exactReplacementRecovery.js";
|
|
9
|
-
import { TODO_RECONCILIATION_ACTIVATION_PATH
|
|
9
|
+
import { TODO_RECONCILIATION_ACTIVATION_PATH } from "./todoReconciliationActivation.js";
|
|
10
10
|
import { reject } from "./write/errors.js";
|
|
11
11
|
const VERSION = "agentera.todoReconciliationTransaction.v1";
|
|
12
12
|
const DIRECTORY = ".agentera/.todo-reconciliation";
|
|
13
13
|
const MAX_JOURNAL_BYTES = 4 * 1024 * 1024;
|
|
14
14
|
const MAX_TARGET_BYTES = 1024 * 1024;
|
|
15
|
-
const MAX_TARGETS =
|
|
15
|
+
const MAX_TARGETS = Math.floor(MAX_JOURNAL_BYTES / 32);
|
|
16
|
+
const ENTITY_MODE_MARKER = ".agentera/state-mode.yaml";
|
|
16
17
|
export class InjectedTodoReconciliationInterruption extends Error {
|
|
17
18
|
publishedTargets;
|
|
18
19
|
constructor(publishedTargets) {
|
|
@@ -53,7 +54,8 @@ function same(left, right) {
|
|
|
53
54
|
function validTarget(relative, publicPath) {
|
|
54
55
|
return relative === publicPath
|
|
55
56
|
|| relative === TODO_RECONCILIATION_ACTIVATION_PATH
|
|
56
|
-
||
|
|
57
|
+
|| relative === ENTITY_MODE_MARKER
|
|
58
|
+
|| /^\.agentera\/entities\/[a-z][a-z0-9_]*\/[a-z][a-z0-9_]*\/[a-z]{10}\.yaml$/.test(relative);
|
|
57
59
|
}
|
|
58
60
|
function createReceiptFromTargets(targets) {
|
|
59
61
|
const created = targets.filter((target) => target.before === null && /^\.agentera\/entities\/todo\/todo_item\/[a-z]{10}\.yaml$/.test(target.path));
|
|
@@ -97,9 +99,7 @@ function parseJournal(bytes, fileName) {
|
|
|
97
99
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
98
100
|
invalidJournal("TODO reconciliation journal is not a mapping");
|
|
99
101
|
const value = parsed;
|
|
100
|
-
const expectedKeys = value.create === undefined
|
|
101
|
-
? "id,mapping_sha256,public_path,schema_version,targets"
|
|
102
|
-
: "create,id,mapping_sha256,public_path,schema_version,targets";
|
|
102
|
+
const expectedKeys = ["schema_version", "id", "public_path", "mapping_sha256", "targets", ...(value.create === undefined ? [] : ["create"]), ...(value.activation_effect_sha256 === undefined ? [] : ["activation_effect_sha256"])].sort().join(",");
|
|
103
103
|
if (Object.keys(value).sort().join(",") !== expectedKeys
|
|
104
104
|
|| value.schema_version !== VERSION
|
|
105
105
|
|| typeof value.id !== "string"
|
|
@@ -111,6 +111,8 @@ function parseJournal(bytes, fileName) {
|
|
|
111
111
|
|| value.targets.length < 1
|
|
112
112
|
|| value.targets.length > MAX_TARGETS)
|
|
113
113
|
invalidJournal("TODO reconciliation journal is malformed");
|
|
114
|
+
if (value.activation_effect_sha256 !== undefined && !/^[a-f0-9]{64}$/.test(value.activation_effect_sha256))
|
|
115
|
+
invalidJournal("TODO reconciliation journal has an invalid activation effect authorization");
|
|
114
116
|
if (value.create !== undefined && (!value.create
|
|
115
117
|
|| typeof value.create !== "object"
|
|
116
118
|
|| Array.isArray(value.create)
|
|
@@ -137,12 +139,17 @@ function parseJournal(bytes, fileName) {
|
|
|
137
139
|
paths.add(target.path);
|
|
138
140
|
}
|
|
139
141
|
const body = value.targets;
|
|
142
|
+
const activates = body.some((target) => target.path === TODO_RECONCILIATION_ACTIVATION_PATH);
|
|
143
|
+
if (!activates && value.activation_effect_sha256 !== undefined)
|
|
144
|
+
invalidJournal("TODO reconciliation journal effect authorization has no activation target");
|
|
140
145
|
const inferredCreate = createReceiptFromTargets(body);
|
|
141
146
|
if (value.create && (!inferredCreate
|
|
142
147
|
|| value.create.created_id !== inferredCreate.created_id
|
|
143
148
|
|| value.create.request_sha256 !== inferredCreate.request_sha256))
|
|
144
149
|
invalidJournal("TODO reconciliation create receipt does not match its canonical entity target");
|
|
145
|
-
const identity = value.create
|
|
150
|
+
const identity = value.create || value.activation_effect_sha256
|
|
151
|
+
? { ...(value.create ? { create: value.create } : {}), ...(value.activation_effect_sha256 ? { activation_effect_sha256: value.activation_effect_sha256 } : {}), targets: body }
|
|
152
|
+
: body;
|
|
146
153
|
const expectedId = createHash("sha256").update(canonicalRecordJson(identity)).digest("hex").slice(0, 24);
|
|
147
154
|
if (value.id !== expectedId || (fileName !== undefined && fileName !== `${value.id}.json`)) {
|
|
148
155
|
invalidJournal("TODO reconciliation journal identity does not match its canonical targets");
|
|
@@ -151,7 +158,7 @@ function parseJournal(bytes, fileName) {
|
|
|
151
158
|
return { ...value, ...(create ? { create } : {}) };
|
|
152
159
|
}
|
|
153
160
|
function targetLimit(target, sourceRoot) {
|
|
154
|
-
return target.path.startsWith(".agentera/entities/
|
|
161
|
+
return target.path.startsWith(".agentera/entities/") ? entityExactGetMaxBytes(sourceRoot) : MAX_TARGET_BYTES;
|
|
155
162
|
}
|
|
156
163
|
function assertBinding(journal, binding) {
|
|
157
164
|
if (journal.public_path !== binding.publicPath || journal.mapping_sha256 !== binding.mappingSha256)
|
|
@@ -441,9 +448,22 @@ export function recoverTodoReconciliation(context, sourceRoot, binding, options
|
|
|
441
448
|
message: `pending TODO create for '${journal.create.created_id}' does not match this request`,
|
|
442
449
|
recovery: `Retry the exact original TODO create input to recover '${journal.create.created_id}'; no transaction target bytes were changed.`,
|
|
443
450
|
});
|
|
451
|
+
if (journal.activation_effect_sha256 && options.activationEffectSha256 !== journal.activation_effect_sha256)
|
|
452
|
+
reject({
|
|
453
|
+
class: "conflict",
|
|
454
|
+
message: "pending TODO activation does not match the authorized preview effect",
|
|
455
|
+
recovery: "Retry the exact activation apply command returned by the original preview; no transaction target bytes were changed.",
|
|
456
|
+
});
|
|
457
|
+
options.beforeRecovery?.(journal.targets.map((target) => ({
|
|
458
|
+
path: target.path,
|
|
459
|
+
before: target.before === null ? null : decode(target.before),
|
|
460
|
+
after: decode(target.after),
|
|
461
|
+
})));
|
|
444
462
|
const applied = [];
|
|
445
463
|
try {
|
|
446
464
|
for (const target of journal.targets) {
|
|
465
|
+
if (target.path === ENTITY_MODE_MARKER)
|
|
466
|
+
options.beforeActivation?.();
|
|
447
467
|
const identity = applyTarget(context, root, target, sourceRoot, journal.public_path);
|
|
448
468
|
if (identity)
|
|
449
469
|
applied.push({ target, identity });
|
|
@@ -473,10 +493,16 @@ export function recoverTodoReconciliation(context, sourceRoot, binding, options
|
|
|
473
493
|
}
|
|
474
494
|
export function publishTodoReconciliation(context, sourceRoot, binding, targets, options = {}) {
|
|
475
495
|
const normalized = targets
|
|
476
|
-
.filter((target) => !same(target.before, Buffer.from(target.after)))
|
|
477
|
-
.sort((left, right) => Number(left.path ===
|
|
496
|
+
.filter((target) => options.retainUnchangedTargets || !same(target.before, Buffer.from(target.after)))
|
|
497
|
+
.sort((left, right) => Number(left.path === ENTITY_MODE_MARKER) - Number(right.path === ENTITY_MODE_MARKER)
|
|
498
|
+
|| Number(left.path === binding.publicPath) - Number(right.path === binding.publicPath)
|
|
499
|
+
|| left.path.localeCompare(right.path));
|
|
478
500
|
const body = normalized.map((target) => ({ path: target.path, before: target.before === null ? null : encode(target.before), after: encode(target.after) }));
|
|
479
|
-
|
|
501
|
+
if (options.activationEffectSha256 && !normalized.some((target) => target.path === TODO_RECONCILIATION_ACTIVATION_PATH))
|
|
502
|
+
reject({ class: "schema_violation", message: "TODO activation authorization requires its activation target", recovery: "Recompute the complete activation target set from a fresh dry-run; no state was changed." });
|
|
503
|
+
const identity = options.create || options.activationEffectSha256
|
|
504
|
+
? { ...(options.create ? { create: options.create } : {}), ...(options.activationEffectSha256 ? { activation_effect_sha256: options.activationEffectSha256 } : {}), targets: body }
|
|
505
|
+
: body;
|
|
480
506
|
const id = createHash("sha256").update(canonicalRecordJson(identity)).digest("hex").slice(0, 24);
|
|
481
507
|
if (!normalized.length)
|
|
482
508
|
return { id, targetCount: 0 };
|
|
@@ -486,7 +512,7 @@ export function publishTodoReconciliation(context, sourceRoot, binding, targets,
|
|
|
486
512
|
reject({
|
|
487
513
|
class: "schema_violation",
|
|
488
514
|
message: "TODO reconciliation transaction has invalid or duplicate bounded targets",
|
|
489
|
-
recovery:
|
|
515
|
+
recovery: "Reduce the managed TODO working set or cutover entity inventory below the declared journal bounds and retry; no state was changed.",
|
|
490
516
|
});
|
|
491
517
|
const publicTarget = normalized.find((target) => target.path === binding.publicPath && target.before !== null);
|
|
492
518
|
if (publicTarget) {
|
|
@@ -506,6 +532,7 @@ export function publishTodoReconciliation(context, sourceRoot, binding, targets,
|
|
|
506
532
|
public_path: binding.publicPath,
|
|
507
533
|
mapping_sha256: binding.mappingSha256,
|
|
508
534
|
...(options.create ? { create: options.create } : {}),
|
|
535
|
+
...(options.activationEffectSha256 ? { activation_effect_sha256: options.activationEffectSha256 } : {}),
|
|
509
536
|
targets: body,
|
|
510
537
|
};
|
|
511
538
|
const bytes = `${JSON.stringify(journal)}\n`;
|
|
@@ -524,6 +551,8 @@ export function publishTodoReconciliation(context, sourceRoot, binding, targets,
|
|
|
524
551
|
const applied = [];
|
|
525
552
|
try {
|
|
526
553
|
for (const target of journal.targets) {
|
|
554
|
+
if (target.path === ENTITY_MODE_MARKER)
|
|
555
|
+
options.beforeActivation?.();
|
|
527
556
|
const identity = applyTarget(context, context.pinnedPath(), target, sourceRoot, journal.public_path);
|
|
528
557
|
if (identity)
|
|
529
558
|
applied.push({ target, identity });
|
|
@@ -551,4 +580,3 @@ export function publishTodoReconciliation(context, sourceRoot, binding, targets,
|
|
|
551
580
|
throw error;
|
|
552
581
|
}
|
|
553
582
|
}
|
|
554
|
-
//# sourceMappingURL=todoReconciliationTransaction.js.map
|
|
@@ -330,4 +330,3 @@ export function renderExplainText(explain) {
|
|
|
330
330
|
lines.push("", "Recovery:", ` ${String(explain.recovery ?? "Correct the input and retry; no state was changed.")}`, "", "Example:", ` ${String(explain.example ?? "")}`);
|
|
331
331
|
return lines.join("\n") + "\n";
|
|
332
332
|
}
|
|
333
|
-
//# sourceMappingURL=explain.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
+
import { projectRuntimeOperationExamples, projectRuntimeOperationRecovery, } from "../../core/developmentInvocation.js";
|
|
2
3
|
import { resolveSourceRoot } from "../../core/sourceRoot.js";
|
|
3
4
|
import { loadStateStorageAuthority } from "../stateStorageAuthority.js";
|
|
4
|
-
import { runtimeOperationSpecs } from "./runtimeOperations.js";
|
|
5
|
+
import { runtimeOperationSpec, runtimeOperationSpecs } from "./runtimeOperations.js";
|
|
5
6
|
export const MUTATION_CLASSES = [
|
|
6
7
|
"record_payload",
|
|
7
8
|
"simple_transition",
|
|
@@ -84,6 +85,9 @@ function parseOperation(raw, index) {
|
|
|
84
85
|
throw new Error(`invalid mutation grammar: ${p} must be a mapping`);
|
|
85
86
|
const artifact = requiredString(raw.artifact, `${p}.artifact`);
|
|
86
87
|
const verb = requiredString(raw.verb, `${p}.verb`);
|
|
88
|
+
const runtime = runtimeOperationSpec(artifact, verb);
|
|
89
|
+
if (!runtime)
|
|
90
|
+
throw new Error(`invalid mutation grammar: ${p} operation '${artifact}.${verb}' is not code-owned`);
|
|
87
91
|
const mutationClass = requiredString(raw.class, `${p}.class`);
|
|
88
92
|
if (!MUTATION_CLASSES.includes(mutationClass))
|
|
89
93
|
throw new Error(`invalid mutation grammar: ${p}.class '${mutationClass}' is unsupported`);
|
|
@@ -113,8 +117,8 @@ function parseOperation(raw, index) {
|
|
|
113
117
|
preconditions: strings(raw.preconditions, `${p}.preconditions`),
|
|
114
118
|
ownedFields: strings(raw.owned_fields, `${p}.owned_fields`),
|
|
115
119
|
input,
|
|
116
|
-
recovery:
|
|
117
|
-
examples:
|
|
120
|
+
recovery: projectRuntimeOperationRecovery(raw.recovery, artifact, verb),
|
|
121
|
+
examples: projectRuntimeOperationExamples(raw.examples, artifact, verb),
|
|
118
122
|
bounds: mapping(raw.bounds) ? clonePlain(raw.bounds) : (() => { throw new Error(`invalid mutation grammar: ${p}.bounds must be a mapping`); })(),
|
|
119
123
|
fields: fields(raw.fields, `${p}.fields`),
|
|
120
124
|
allowForce: raw.allow_force === true,
|
|
@@ -160,6 +164,9 @@ function operationParityProjection(operation) {
|
|
|
160
164
|
cli_owned_fields: operation.input.cliOwnedFields,
|
|
161
165
|
},
|
|
162
166
|
fields: operation.fields.map(declaredFieldProjection),
|
|
167
|
+
recovery: operation.recovery,
|
|
168
|
+
examples: operation.examples,
|
|
169
|
+
projection: { format_values: runtimeOperationSpec(operation.artifact, operation.verb)?.projection.formatValues ?? [] },
|
|
163
170
|
allow_force: operation.allowForce,
|
|
164
171
|
compacts: operation.compacts,
|
|
165
172
|
bounds: operation.input.mode === "structured"
|
|
@@ -181,6 +188,9 @@ function runtimeParityProjection(operation) {
|
|
|
181
188
|
cli_owned_fields: operation.cliOwnedFields,
|
|
182
189
|
},
|
|
183
190
|
fields: operation.fields.map(runtimeFieldProjection),
|
|
191
|
+
recovery: operation.projection.recovery.runtime,
|
|
192
|
+
examples: operation.projection.examples.map(({ runtime }) => runtime),
|
|
193
|
+
projection: { format_values: operation.projection.formatValues },
|
|
184
194
|
allow_force: operation.allowForce,
|
|
185
195
|
compacts: operation.compacts,
|
|
186
196
|
bounds: { max_input_utf8_bytes: operation.inputMaxBytes },
|
|
@@ -268,4 +278,3 @@ export function mutationGrammarPayload(sourceRoot = resolveSourceRoot()) {
|
|
|
268
278
|
operations: grammar.operations,
|
|
269
279
|
};
|
|
270
280
|
}
|
|
271
|
-
//# sourceMappingURL=grammar.js.map
|
package/dist/state/write/lock.js
CHANGED