agentera 3.0.0-dev.8 → 3.0.0-dev.81
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 +252 -22
- package/bundle/.agentera-build-source.json +8 -0
- package/bundle/CHANGELOG.md +1389 -0
- package/bundle/DESIGN.md +229 -0
- package/bundle/LICENSE +201 -0
- package/bundle/README.md +142 -0
- package/bundle/UPGRADE.md +275 -0
- package/bundle/extract-corpus-parity.json +2 -4
- package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
- package/bundle/references/adapters/package-publication.json +484 -0
- package/bundle/references/adapters/package-registry.yaml +443 -188
- package/bundle/references/adapters/package-surface-characterization.md +68 -34
- package/bundle/references/adapters/product-v1-reset.yaml +101 -0
- 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 +357 -0
- package/bundle/references/analysis/evidence-tier-authority.yaml +559 -0
- package/bundle/references/analysis/personal-glossary-evaluation-authority.yaml +175 -0
- package/bundle/references/analysis/personal-glossary-evaluation-corpus.yaml +291 -0
- package/bundle/references/analysis/personal-glossary-holdout.yaml +192 -0
- package/bundle/references/analysis/verification-policy.yaml +262 -0
- package/bundle/references/artifacts/artifact-registry-interface-model.yaml +17 -8
- package/bundle/references/artifacts/glossary-entry-contract.yaml +2906 -0
- package/bundle/references/artifacts/state-storage-authority.yaml +3075 -0
- package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
- package/bundle/references/cli/app-lifecycle-vocabulary.yaml +3 -4
- package/bundle/references/cli/capability-instruction-contract.yaml +11 -14
- package/bundle/references/cli/hybrid-route-contract.yaml +438 -0
- package/bundle/references/cli/routing-model.md +152 -93
- package/bundle/references/cli/trigger-schema-enrichment.md +57 -46
- package/bundle/references/cli/update-channels.yaml +7 -5
- package/bundle/references/cli/vocabulary-index.yaml +7 -9
- package/bundle/references/cli/vocabulary.md +54 -97
- package/bundle/references/meta/retained-reference-authority.yaml +171 -0
- package/bundle/skills/agentera/SKILL.md +183 -63
- package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +27 -19
- package/bundle/skills/agentera/capabilities/audit/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +13 -35
- package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +30 -11
- package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +44 -21
- package/bundle/skills/agentera/capabilities/build/schemas/exit.yaml +8 -6
- package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +14 -36
- package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +95 -21
- package/bundle/skills/agentera/capabilities/design/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +5 -5
- package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +5 -34
- package/bundle/skills/agentera/capabilities/design/schemas/validation.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +17 -13
- package/bundle/skills/agentera/capabilities/discuss/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +6 -40
- package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +72 -5
- package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +24 -17
- package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +5 -35
- package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +13 -13
- package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +10 -10
- package/bundle/skills/agentera/capabilities/optimize/schemas/exit.yaml +2 -2
- package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +4 -35
- package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +3 -3
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +34 -22
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/exit.yaml +9 -7
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +5 -37
- package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +38 -37
- package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +20 -16
- package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +8 -31
- package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +66 -6
- package/bundle/skills/agentera/capabilities/profile/schemas/artifacts.yaml +13 -4
- package/bundle/skills/agentera/capabilities/profile/schemas/exit.yaml +8 -5
- package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +8 -37
- package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +67 -3
- package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +6 -6
- package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +5 -29
- package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +13 -12
- package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +7 -49
- package/bundle/skills/agentera/capabilities/vision/schemas/artifacts.yaml +8 -8
- package/bundle/skills/agentera/capabilities/vision/schemas/exit.yaml +7 -6
- package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +7 -39
- package/bundle/skills/agentera/capabilities/vision/schemas/validation.yaml +14 -16
- package/bundle/skills/agentera/capability_schema_contract.yaml +32 -32
- package/bundle/skills/agentera/protocol.yaml +4 -4
- package/bundle/skills/agentera/route-phrases.yaml +81 -0
- package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +29 -30
- package/bundle/skills/agentera/schemas/artifacts/design.yaml +1 -0
- package/bundle/skills/agentera/schemas/artifacts/docs.yaml +7 -43
- package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +140 -34
- package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +87 -0
- package/bundle/skills/agentera/schemas/artifacts/health.yaml +53 -51
- package/bundle/skills/agentera/schemas/artifacts/objective.yaml +18 -35
- package/bundle/skills/agentera/schemas/artifacts/plan.yaml +453 -55
- package/bundle/skills/agentera/schemas/artifacts/progress.yaml +128 -39
- package/bundle/skills/agentera/schemas/artifacts/todo.yaml +305 -7
- package/bundle/skills/agentera/schemas/artifacts/vision.yaml +0 -19
- package/dist/.agentera-build-source.json +8 -0
- package/dist/analytics/extractCorpus/cli.js +52 -11
- package/dist/analytics/extractCorpus/copilotSessions.js +19 -8
- package/dist/analytics/extractCorpus/core.js +262 -14
- package/dist/analytics/extractCorpus/corpus.js +57 -18
- package/dist/analytics/extractCorpus/coverageAudit.js +44 -45
- package/dist/analytics/extractCorpus/cursorSessions.js +28 -8
- package/dist/analytics/extractCorpus/evidenceTiers.js +709 -0
- package/dist/analytics/extractCorpus/extractCorpusParity.js +4 -4
- package/dist/analytics/extractCorpus/filesystemSources.js +5 -5
- package/dist/analytics/extractCorpus/index.js +4 -2
- package/dist/analytics/extractCorpus/jsonlSessions.js +76 -8
- package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
- package/dist/analytics/extractCorpus/sqliteSessions.js +12 -4
- package/dist/analytics/extractCorpus/tierReader.js +108 -0
- package/dist/analytics/extractCorpus.js +0 -1
- package/dist/analytics/glossaryAdviceResolution.js +166 -0
- package/dist/analytics/glossaryInputAcquisition.js +319 -0
- package/dist/analytics/personalGlossaryAdmission.js +113 -0
- package/dist/analytics/personalGlossaryCandidateProjection.js +788 -0
- package/dist/analytics/personalGlossaryCandidateProjectionExcerpts.js +144 -0
- package/dist/analytics/personalGlossaryCandidateProjectionModel.js +1 -0
- package/dist/analytics/personalGlossaryCandidateReadView.js +23 -0
- package/dist/analytics/personalGlossaryCurrentGeneration.js +25 -0
- package/dist/analytics/personalGlossaryDecision.js +203 -0
- package/dist/analytics/personalGlossaryExplicit.js +788 -0
- package/dist/analytics/personalGlossaryExplicitMining.js +285 -0
- package/dist/analytics/personalGlossaryExplicitScope.js +41 -0
- package/dist/analytics/personalGlossaryExplicitSegments.js +418 -0
- package/dist/analytics/personalGlossaryExplicitTypes.js +26 -0
- package/dist/analytics/personalGlossaryLexicalClassifier.js +175 -0
- package/dist/analytics/personalGlossaryProfile.js +229 -0
- package/dist/analytics/personalGlossaryRecurrence.js +618 -0
- package/dist/analytics/personalGlossaryRefreshProjection.js +351 -0
- package/dist/analytics/personalGlossaryReviewRecordStorage.js +428 -0
- package/dist/analytics/personalGlossaryReviewRecords.js +332 -0
- package/dist/analytics/profileSignals.js +211 -0
- package/dist/analytics/usageStats.js +150 -23
- package/dist/audit/terminologyDrift.js +281 -0
- package/dist/bin/agentera.js +3 -2
- package/dist/capabilities/audit/instructions.js +16 -6
- package/dist/capabilities/build/instructions.js +59 -6
- package/dist/capabilities/design/instructions.js +3 -4
- package/dist/capabilities/discuss/instructions.js +29 -6
- package/dist/capabilities/document/instructions.js +11 -6
- package/dist/capabilities/index.js +20 -14
- package/dist/capabilities/optimize/instructions.js +14 -6
- package/dist/capabilities/orchestrate/instructions.js +42 -6
- package/dist/capabilities/plan/instructions.js +30 -3
- package/dist/capabilities/profile/instructions.js +104 -5
- package/dist/capabilities/research/instructions.js +4 -5
- package/dist/capabilities/status/instructions.js +15 -6
- package/dist/capabilities/status/startupInstructions.js +34 -0
- package/dist/capabilities/vision/instructions.js +3 -5
- package/dist/cli/appContext.js +14 -7
- package/dist/cli/argvalidate.js +0 -1
- package/dist/cli/capabilityContext/benchmark.js +5 -4
- package/dist/cli/capabilityContext/bespoke.js +14 -6
- package/dist/cli/capabilityContext/build.js +116 -42
- package/dist/cli/capabilityContext/closeout.js +30 -27
- package/dist/cli/capabilityContext/contract.js +18 -27
- package/dist/cli/capabilityContext/evidence.js +84 -77
- package/dist/cli/capabilityContext/index.js +0 -1
- package/dist/cli/capabilityContext/orchestration.js +42 -18
- package/dist/cli/capabilityContext/planState.js +89 -96
- package/dist/cli/capabilityContext/progress.js +52 -12
- package/dist/cli/capabilityContext/projectVerification.js +409 -0
- package/dist/cli/capabilityContext/shared.js +9 -20
- package/dist/cli/capabilityContext/slim.js +52 -8
- package/dist/cli/capabilityContext/startup.js +51 -114
- package/dist/cli/capabilityContext/startupAggregation.js +68 -0
- package/dist/cli/capabilityContext/types.js +26 -10
- 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 +163 -13
- package/dist/cli/commands/doctor.js +162 -11
- package/dist/cli/commands/durability.js +81 -0
- package/dist/cli/commands/glossaryAdvice.js +138 -0
- package/dist/cli/commands/lint.js +22 -8
- package/dist/cli/commands/personalGlossaryCandidateReads.js +755 -0
- package/dist/cli/commands/personalGlossaryDecision.js +349 -0
- package/dist/cli/commands/personalGlossaryPublish.js +484 -0
- package/dist/cli/commands/personalGlossaryReviewRecordReads.js +209 -0
- package/dist/cli/commands/personalGlossaryReviewRecords.js +623 -0
- package/dist/cli/commands/prime/briefOrientation.js +845 -0
- package/dist/cli/commands/prime/buildExecutionRequest.js +165 -0
- package/dist/cli/commands/prime/bundleStatus.js +54 -4
- package/dist/cli/commands/prime/collectEntityOrientation.js +338 -0
- package/dist/cli/commands/prime/collectOrientationState.js +124 -68
- package/dist/cli/commands/prime/orientationOutput.js +271 -59
- package/dist/cli/commands/prime/types.js +0 -1
- package/dist/cli/commands/prime.js +89 -11
- package/dist/cli/commands/profileGrounding.js +55 -0
- package/dist/cli/commands/query.js +74 -52
- package/dist/cli/commands/report.js +187 -27
- package/dist/cli/commands/route.js +142 -0
- package/dist/cli/commands/schema.js +436 -138
- package/dist/cli/commands/state/decisions.js +40 -56
- package/dist/cli/commands/state/docs.js +58 -85
- package/dist/cli/commands/state/experimentRecords.js +151 -0
- package/dist/cli/commands/state/experiments.js +11 -65
- package/dist/cli/commands/state/get.js +129 -0
- package/dist/cli/commands/state/health.js +11 -113
- package/dist/cli/commands/state/index.js +6 -41
- package/dist/cli/commands/state/list.js +194 -0
- package/dist/cli/commands/state/objective.js +21 -65
- package/dist/cli/commands/state/plan.js +11 -170
- package/dist/cli/commands/state/planTasks.js +154 -0
- package/dist/cli/commands/state/plans.js +154 -0
- package/dist/cli/commands/state/progress.js +11 -45
- package/dist/cli/commands/state/shared.js +0 -1
- package/dist/cli/commands/state/todo.js +28 -107
- package/dist/cli/commands/state/write.js +459 -0
- package/dist/cli/commands/upgrade.js +176 -5
- package/dist/cli/commands/upgradeVerify.js +118 -0
- package/dist/cli/commands/validate.js +235 -136
- package/dist/cli/commands/verify.js +73 -16
- 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 +84 -40
- package/dist/cli/dispatch/commands.js +3 -3
- package/dist/cli/dispatch/index.js +84 -52
- package/dist/cli/dispatch/lifecycle.js +182 -62
- package/dist/cli/dispatch/prime.js +37 -2
- package/dist/cli/dispatch/projections.js +17 -0
- package/dist/cli/dispatch/shared.js +1 -2
- package/dist/cli/dispatch/state.js +62 -66
- package/dist/cli/dispatch.js +0 -1
- package/dist/cli/errors.js +16 -17
- package/dist/cli/help.js +419 -41
- package/dist/cli/migrationRequired.js +125 -0
- package/dist/cli/orientation/attention.js +19 -22
- package/dist/cli/orientation/corpusCoverage.js +32 -1
- package/dist/cli/orientation.js +346 -129
- package/dist/cli/planArtifacts.js +350 -0
- package/dist/cli/planEvidence.js +157 -0
- package/dist/cli/planLifecycleState.js +36 -0
- package/dist/cli/planTaskIndex.js +11 -0
- package/dist/cli/preCutoverCommand.js +32 -0
- package/dist/cli/prime-blob.js +71 -3
- package/dist/cli/productV1Eol.js +55 -0
- package/dist/cli/profileAcquisition.js +167 -0
- package/dist/cli/startupCompletenessContract.js +11 -9
- package/dist/cli/stateQuery.js +47 -12
- package/dist/cli/structured.js +0 -1
- package/dist/cli/todoMarkdown.js +25 -12
- package/dist/cli/todoReadinessSelection.js +192 -0
- package/dist/cli/todoSeverity.js +0 -1
- package/dist/core/atomicWriter.js +23 -0
- package/dist/core/developmentChannel.js +1 -0
- package/dist/core/developmentInvocation.js +377 -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 +4 -0
- package/dist/core/skillIdentity.js +23 -0
- package/dist/core/sourceRoot.js +9 -12
- package/dist/core/text.js +10 -0
- package/dist/core/toml.js +0 -1
- package/dist/core/yaml.js +61 -2
- package/dist/eval/evalSkills.js +13 -14
- package/dist/eval/glossaryEvaluation.js +751 -0
- package/dist/eval/glossaryEvaluationProcess.js +29 -0
- package/dist/eval/glossaryEvaluationRunner.js +571 -0
- package/dist/eval/glossaryEvaluationSuccessReport.js +297 -0
- package/dist/eval/hybridRouteEvaluation.js +155 -0
- package/dist/eval/semanticEval.js +0 -1
- package/dist/eval/semanticFixtures.js +0 -1
- package/dist/hooks/common.js +3 -56
- package/dist/hooks/compaction/apply.js +224 -47
- package/dist/hooks/compaction/dryRun.js +2 -1
- package/dist/hooks/compaction/index.js +5 -6
- package/dist/hooks/compaction/parse.js +73 -6
- package/dist/hooks/compaction/retention.js +28 -25
- package/dist/hooks/compaction/status.js +145 -26
- 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 +9 -10
- package/dist/hooks/validateArtifact/schema.js +96 -9
- package/dist/hooks/validateArtifact/traversal.js +12 -11
- package/dist/hooks/validateArtifact/violations.js +5 -3
- package/dist/migrate/v2HandoffManifest.js +8 -3
- package/dist/registries/activationContract.js +2 -0
- package/dist/registries/activationTuples.js +145 -0
- package/dist/registries/artifactProtocolIds.js +2 -1
- package/dist/registries/artifactRegistry.js +207 -60
- package/dist/registries/artifactSchemaProjection.js +45 -0
- package/dist/registries/capabilityContract.js +5 -21
- package/dist/registries/evaluatorHandoffContract.js +0 -1
- package/dist/registries/evidenceTierContract.js +375 -0
- package/dist/registries/explicitSegmentGrammarContract.js +619 -0
- package/dist/registries/glossaryAdviceContract.js +79 -0
- package/dist/registries/glossaryCandidateContractPaths.js +6 -0
- package/dist/registries/glossaryCandidateContracts.js +820 -0
- package/dist/registries/glossaryCandidateDecisionAuthority.js +119 -0
- package/dist/registries/glossaryCandidateDecisionContract.js +62 -0
- package/dist/registries/glossaryCandidateProjectionAuthority.js +345 -0
- package/dist/registries/glossaryCandidateProjectionContract.js +108 -0
- package/dist/registries/glossaryCaveatContract.js +67 -0
- package/dist/registries/glossaryConsumerContractValidation.js +787 -0
- package/dist/registries/glossaryEntryContract.js +759 -0
- package/dist/registries/glossaryEntryTemporal.js +12 -0
- package/dist/registries/glossaryMiningAuthority.js +764 -0
- package/dist/registries/glossaryProfileFullContract.js +24 -0
- package/dist/registries/glossaryReviewRecordsAuthority.js +426 -0
- package/dist/registries/glossaryReviewRecordsContract.js +129 -0
- package/dist/registries/glossaryTermIdentity.js +139 -0
- package/dist/registries/glossaryTermOccurrence.js +20 -0
- package/dist/registries/hybridRoute.js +274 -0
- package/dist/registries/hybridRouteReceipt.js +221 -0
- package/dist/registries/packagePublication.js +273 -0
- package/dist/registries/packageRegistry.js +184 -209
- package/dist/registries/personalGlossaryContracts.js +1 -0
- package/dist/registries/todoReadinessContract.js +448 -0
- package/dist/registries/triggerLoader.js +7 -44
- package/dist/registries/verbosityBudgetContract.js +205 -0
- package/dist/release/releaseMetadata.js +168 -11
- package/dist/runtime/lifecycleAdapterContract.js +457 -0
- package/dist/runtime/lifecycleAdapters.js +777 -0
- package/dist/runtime/lifecycleAuthority.js +453 -0
- package/dist/runtime/lifecycleOperationContract.js +123 -0
- package/dist/runtime/lifecycleOperations.js +634 -0
- package/dist/runtime/lifecycleOwnershipJournal.js +622 -0
- package/dist/runtime/lifecyclePublication.js +415 -0
- package/dist/runtime/lifecycleSnapshot.js +438 -0
- package/dist/runtime/nativeResourceCleanup.js +618 -0
- package/dist/setup/opencode.js +20 -13
- package/dist/setup/opencodeConstants.js +1 -0
- package/dist/setup/sharedSkill.js +45 -0
- package/dist/setup/smokeChecks.js +14 -75
- package/dist/state/archiveDiscovery.js +580 -0
- package/dist/state/archivePublication.js +225 -0
- package/dist/state/archiveRecovery.js +237 -0
- package/dist/state/archiveReplay.js +53 -0
- package/dist/state/canonicalMigrationRecord.js +36 -0
- package/dist/state/changelog.js +221 -0
- package/dist/state/decisionEntities.js +367 -0
- package/dist/state/decisionLegacyValidation.js +215 -0
- package/dist/state/decisionMigrationProvenance.js +199 -0
- package/dist/state/decisionOverlay.js +254 -0
- package/dist/state/decisionRevision.js +256 -0
- package/dist/state/decisionRevisionMigration.js +89 -0
- package/dist/state/directRetrieval.js +323 -0
- package/dist/state/durability.js +324 -0
- package/dist/state/entityCutover.js +459 -0
- package/dist/state/entityCutoverGit.js +127 -0
- package/dist/state/entityGlossaryAuthority.js +13 -0
- package/dist/state/entityListProjection.js +187 -0
- package/dist/state/entityListRuntimeRegistry.js +85 -0
- package/dist/state/entityMigrationCausality.js +97 -0
- package/dist/state/entityMigrationIdentity.js +5 -0
- package/dist/state/entityMigrationPreview.js +840 -0
- package/dist/state/entityMigrationTodo.js +133 -0
- package/dist/state/entityPublicationContext.js +859 -0
- package/dist/state/entityRetrievalHelp.js +506 -0
- package/dist/state/entityStorage.js +894 -0
- package/dist/state/entityWriterLock.js +18 -0
- package/dist/state/exactReplacementRecovery.js +18 -0
- package/dist/state/experimentArchive.js +63 -0
- package/dist/state/experimentIdentity.js +202 -0
- package/dist/state/healthEntities.js +262 -0
- package/dist/state/healthEntityValidation.js +18 -0
- package/dist/state/healthRepair.js +69 -0
- package/dist/state/installRoot.js +15 -7
- package/dist/state/legacyEntityCutoverEvidence.js +65 -0
- package/dist/state/legacyIdentity.js +47 -0
- package/dist/state/legacySummaryRecord.js +6 -0
- package/dist/state/listAccounting.js +54 -0
- package/dist/state/listClassification.js +17 -0
- package/dist/state/listCursor.js +42 -0
- package/dist/state/listRetrieval.js +781 -0
- package/dist/state/migrationSourceBinding.js +30 -0
- package/dist/state/objectiveExperimentEntities.js +322 -0
- package/dist/state/planEntities.js +1027 -0
- package/dist/state/planIdentity.js +47 -0
- package/dist/state/planLineageValidation.js +52 -0
- package/dist/state/planReplacementTransaction.js +475 -0
- package/dist/state/planRetrieval.js +313 -0
- package/dist/state/planTaskRetrieval.js +294 -0
- package/dist/state/progressEntities.js +512 -0
- package/dist/state/progressGlossaryCaveat.js +168 -0
- package/dist/state/progressPublicationOrder.js +19 -0
- package/dist/state/progressWritePolicy.js +33 -0
- package/dist/state/projectRoot.js +62 -0
- package/dist/state/projectionPolicy.js +190 -0
- package/dist/state/retrievalAuthority.js +156 -0
- package/dist/state/safeProjectFile.js +155 -0
- package/dist/state/startupAnalysis/benchmark.js +70 -9
- package/dist/state/startupAnalysis/contract.js +44 -10
- package/dist/state/startupAnalysis/helpers.js +1 -2
- 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 +13 -1
- package/dist/state/startupAnalysis.js +0 -1
- package/dist/state/startupProjection.js +499 -0
- package/dist/state/stateMode.js +222 -0
- package/dist/state/stateStorageAuthority.js +47 -0
- package/dist/state/summaryEntityRead.js +25 -0
- package/dist/state/summaryMigrationProvenance.js +66 -0
- package/dist/state/summarySourceRowAuthority.js +36 -0
- package/dist/state/todoActivationSafety.js +58 -0
- package/dist/state/todoCreateBatch.js +69 -0
- package/dist/state/todoDocsEntities.js +1339 -0
- package/dist/state/todoDocsEntityValidation.js +158 -0
- package/dist/state/todoMarkdownProjection.js +63 -0
- package/dist/state/todoReconciliationActivation.js +182 -0
- package/dist/state/todoReconciliationInspection.js +184 -0
- package/dist/state/todoReconciliationRepair.js +320 -0
- package/dist/state/todoReconciliationTransaction.js +628 -0
- package/dist/state/todoSeverityHeadings.js +71 -0
- package/dist/state/todoTransitionBatch.js +65 -0
- package/dist/state/todoUpdateBatch.js +50 -0
- package/dist/state/write/assign.js +20 -0
- package/dist/state/write/candidateMutation.js +269 -0
- package/dist/state/write/errors.js +11 -0
- package/dist/state/write/experimentPublication.js +192 -0
- package/dist/state/write/explain.js +380 -0
- package/dist/state/write/fields.js +61 -0
- package/dist/state/write/glossaryPublication.js +263 -0
- package/dist/state/write/grammar.js +285 -0
- package/dist/state/write/helpers.js +29 -0
- package/dist/state/write/index.js +12 -0
- package/dist/state/write/input.js +391 -0
- package/dist/state/write/lock.js +837 -0
- package/dist/state/write/mutation.js +234 -0
- package/dist/state/write/operations.js +170 -0
- package/dist/state/write/planEvaluation.js +128 -0
- package/dist/state/write/planPublication.js +179 -0
- package/dist/state/write/runtimeOperations.js +146 -0
- package/dist/state/write/serialize.js +1 -0
- package/dist/state/write/transaction.js +57 -0
- package/dist/state/write/validate.js +7 -0
- package/dist/upgrade/appContentRefresh.js +77 -36
- package/dist/upgrade/appModel.js +0 -1
- package/dist/upgrade/atomicWriter.js +1 -0
- package/dist/upgrade/bundleEvidence.js +0 -1
- package/dist/upgrade/channels.js +6 -9
- package/dist/upgrade/compatibility.js +43 -17
- package/dist/upgrade/doctor.js +55 -32
- package/dist/upgrade/doctorClassifier.js +11 -1
- package/dist/upgrade/installedHooksRetirement.js +46 -40
- package/dist/upgrade/legacyAgentCleanup.js +133 -34
- package/dist/upgrade/lifecycleUpgrade.js +126 -0
- package/dist/upgrade/migrateArtifactsV2ToV3.js +325 -82
- package/dist/upgrade/migrationPublication.js +122 -0
- package/dist/upgrade/nextMajorDoctor.js +0 -22
- package/dist/upgrade/npxPlatformStatus.js +2 -2
- package/dist/upgrade/productV1Reset.js +515 -0
- package/dist/upgrade/productV1ResetAuthority.js +139 -0
- package/dist/upgrade/projectIntegration.js +126 -134
- package/dist/upgrade/projectIntegrationDecision.js +21 -13
- package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
- package/dist/upgrade/runtimeMigration.js +210 -430
- package/dist/upgrade/upgradeCommands.js +14 -1
- package/dist/upgrade/upgradeLock.js +85 -0
- package/dist/upgrade/upgradeOrchestrator.js +257 -48
- package/dist/upgrade/v3CapabilitySurface.js +2 -3
- package/dist/upgrade/versionResolution.js +0 -1
- package/dist/validate/activationArtifactEvidence.js +866 -0
- package/dist/validate/activationArtifactEvidenceTypes.js +12 -0
- package/dist/validate/activationConjunction.js +816 -0
- package/dist/validate/activationEvidenceManifest.js +610 -0
- package/dist/validate/activationPackageSemantics.js +29 -0
- package/dist/validate/appHomeContract.js +1 -7
- package/dist/validate/bootstrapAuthority.js +44 -0
- package/dist/validate/capability.js +11 -3
- package/dist/validate/crossCapability.js +14 -9
- package/dist/validate/glossaryVariantGuard.js +96 -0
- package/dist/validate/retainedReferenceAuthority.js +879 -0
- package/dist/validate/selfAudit.js +39 -45
- package/dist/validate/vocabularyAuthority.js +8 -8
- package/package.json +39 -13
- package/bundle/references/adapters/cursor.md +0 -214
- package/bundle/references/adapters/opencode.md +0 -530
- package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -337
- 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 -554
- package/bundle/references/adapters/runtime-feature-parity.md +0 -189
- package/bundle/references/analysis/benchmark.md +0 -267
- package/bundle/references/analysis/startup-measurement-contract.yaml +0 -424
- package/bundle/references/cli/agent-ready-state-contract.yaml +0 -953
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -369
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -250
- 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/routing-execution-vocabulary.yaml +0 -281
- package/bundle/references/cli/single-name-protocol.yaml +0 -42
- package/bundle/references/cli/upgrade-repair-wording.md +0 -45
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -98
- package/bundle/references/meta/documentation-inventory.md +0 -49
- package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
- package/bundle/skills/agentera/agents/audit.toml +0 -6
- package/bundle/skills/agentera/agents/build.toml +0 -6
- package/bundle/skills/agentera/agents/design.toml +0 -6
- package/bundle/skills/agentera/agents/discuss.toml +0 -6
- package/bundle/skills/agentera/agents/document.toml +0 -6
- package/bundle/skills/agentera/agents/optimize.toml +0 -6
- package/bundle/skills/agentera/agents/orchestrate.toml +0 -6
- package/bundle/skills/agentera/agents/plan.toml +0 -6
- package/bundle/skills/agentera/agents/profile.toml +0 -6
- package/bundle/skills/agentera/agents/research.toml +0 -6
- package/bundle/skills/agentera/agents/status.toml +0 -6
- package/bundle/skills/agentera/agents/vision.toml +0 -6
- package/bundle/skills/agentera/references/contract.md +0 -1048
- 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/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.js.map +0 -1
- package/dist/analytics/usageStats.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/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/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/lint.js.map +0 -1
- package/dist/cli/commands/prime/bundleStatus.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 +0 -39
- package/dist/cli/commands/prime/v1Migration.js.map +0 -1
- package/dist/cli/commands/prime.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/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/experiments.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/objective.js.map +0 -1
- package/dist/cli/commands/state/plan.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/upgrade.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/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/prime-blob.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/todoSeverity.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/sourceRoot.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/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 -79
- package/dist/hooks/cursorSessionStart.js.map +0 -1
- package/dist/hooks/sessionStart.js +0 -216
- package/dist/hooks/sessionStart.js.map +0 -1
- package/dist/hooks/sessionStop.js +0 -206
- 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/capabilityContract.js.map +0 -1
- package/dist/registries/evaluatorHandoffContract.js.map +0 -1
- package/dist/registries/packageRegistry.js.map +0 -1
- package/dist/registries/runtimeAdapterRegistry.js +0 -316
- package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
- package/dist/registries/triggerLoader.js.map +0 -1
- package/dist/release/releaseMetadata.js.map +0 -1
- package/dist/setup/codex/agents.js +0 -96
- package/dist/setup/codex/agents.js.map +0 -1
- package/dist/setup/codex/cli.js +0 -161
- package/dist/setup/codex/cli.js.map +0 -1
- package/dist/setup/codex/configToml.js +0 -639
- package/dist/setup/codex/configToml.js.map +0 -1
- package/dist/setup/codex/constants.js +0 -29
- 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 -270
- package/dist/setup/codex/state.js.map +0 -1
- package/dist/setup/codex.js +0 -12
- package/dist/setup/codex.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 -129
- package/dist/setup/cursor.js.map +0 -1
- package/dist/setup/cursorSurfaces.js +0 -67
- package/dist/setup/cursorSurfaces.js.map +0 -1
- package/dist/setup/doctor/core.js +0 -300
- package/dist/setup/doctor/core.js.map +0 -1
- package/dist/setup/doctor/diagnostics.js +0 -240
- package/dist/setup/doctor/diagnostics.js.map +0 -1
- package/dist/setup/doctor/opencode.js +0 -313
- package/dist/setup/doctor/opencode.js.map +0 -1
- package/dist/setup/doctor/report.js +0 -425
- package/dist/setup/doctor/report.js.map +0 -1
- package/dist/setup/doctor.js +0 -10
- package/dist/setup/doctor.js.map +0 -1
- package/dist/setup/opencode.js.map +0 -1
- package/dist/setup/smokeChecks.js.map +0 -1
- package/dist/state/installRoot.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/upgrade/appContentRefresh.js.map +0 -1
- package/dist/upgrade/appModel.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 -107
- 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/migrateArtifactsV1ToV2.js +0 -570
- package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.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/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/lifecycleAdapters/legacyPythonParity.js +0 -93
- package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +0 -1
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js +0 -488
- package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +0 -1
- package/dist/validate/lifecycleAdapters/shared.js +0 -198
- package/dist/validate/lifecycleAdapters/shared.js.map +0 -1
- package/dist/validate/lifecycleAdapters.js +0 -62
- package/dist/validate/lifecycleAdapters.js.map +0 -1
- package/dist/validate/selfAudit.js.map +0 -1
- package/dist/validate/vocabularyAuthority.js.map +0 -1
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { readCurrentPersonalGlossaryCandidateProjection } from "./personalGlossaryCurrentGeneration.js";
|
|
3
|
+
import { decidePersonalGlossaryCandidate } from "./personalGlossaryDecision.js";
|
|
4
|
+
import { createGlossaryReviewRecord, validateGlossaryAdmissionDecision, validateGlossaryHostClassificationReceipt, validateGlossaryReviewRecord, } from "../registries/glossaryCandidateContracts.js";
|
|
5
|
+
import { personalReviewApprovalReceiptDigest, personalReviewApprovalReplayStatus, personalReviewDispositionLifecycle, validatePersonalReviewApprovalReceipt, } from "../registries/glossaryMiningAuthority.js";
|
|
6
|
+
import { canonicalGlossaryJson, compareGlossaryUnicodeStrings } from "../registries/glossaryTermIdentity.js";
|
|
7
|
+
import { activeReplayDigestMap, currentReplayIndex, ensurePersonalGlossaryReviewRecordsPrivate, isCurrentReviewRecord, isCurrentReviewStore, isLegacyReviewStore, makePersonalGlossaryReviewStore, migrateLegacyPendingReviewRecord, personalGlossaryReviewRecordsPath, personalGlossaryReviewRecordsStorageContract, personalGlossaryTrustedLocalHostPath, privateWritePersonalGlossaryReviewRecords, readPersonalGlossaryReviewRecords, readPersonalGlossaryTrustedLocalHost, readablePersonalGlossaryReviewRecord, recordMatchesProjection, replayDigestMap, replayNonceDigest, reviewExpiry, reviewIdentity, reviewScope, sealPersonalGlossaryReviewRecord, terminalReviewRecordExpired, validPersonalGlossaryReviewGenerationBinding, validPersonalGlossaryReviewMetadataBinding, } from "./personalGlossaryReviewRecordStorage.js";
|
|
8
|
+
export { personalGlossaryReviewRecordsPath, personalGlossaryTrustedLocalHostPath, readPersonalGlossaryReviewRecords, validPersonalGlossaryReviewGenerationBinding, validPersonalGlossaryReviewMetadataBinding, };
|
|
9
|
+
const TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/u;
|
|
10
|
+
const SHA256 = /^[a-f0-9]{64}$/u;
|
|
11
|
+
function mapping(value) {
|
|
12
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function timestamp(value) {
|
|
15
|
+
return typeof value === "string" && TIMESTAMP.test(value) && !Number.isNaN(Date.parse(value));
|
|
16
|
+
}
|
|
17
|
+
function digest(value) {
|
|
18
|
+
return typeof value === "string" && SHA256.test(value);
|
|
19
|
+
}
|
|
20
|
+
function exactCandidate(candidates, decision) {
|
|
21
|
+
return candidates.find((candidate) => candidate.capsule.candidate_id === decision.candidate_id &&
|
|
22
|
+
candidate.capsule.candidate_revision === decision.candidate_revision &&
|
|
23
|
+
candidate.capsule.capsule_sha256 === decision.candidate_capsule_sha256 &&
|
|
24
|
+
candidate.capsule.generation === decision.generation &&
|
|
25
|
+
candidate.capsule.policy_version === decision.policy_version) ?? null;
|
|
26
|
+
}
|
|
27
|
+
function pendingRecord(decision, scope, queuedAt, reopenReason) {
|
|
28
|
+
const body = {
|
|
29
|
+
schema_version: "agentera.personalGlossaryReviewRecord.v2",
|
|
30
|
+
owner: "current_user",
|
|
31
|
+
candidate_id: decision.candidate_id,
|
|
32
|
+
candidate_revision: decision.candidate_revision,
|
|
33
|
+
candidate_capsule_sha256: decision.candidate_capsule_sha256,
|
|
34
|
+
candidate_projection_sha256: decision.candidate_projection_sha256,
|
|
35
|
+
host_receipt_sha256: decision.host_receipt_sha256,
|
|
36
|
+
cli_decision_sha256: decision.decision_sha256,
|
|
37
|
+
semantic_fingerprint: decision.semantic_fingerprint,
|
|
38
|
+
generation: decision.generation,
|
|
39
|
+
policy_version: decision.policy_version,
|
|
40
|
+
scope,
|
|
41
|
+
reason: decision.reason,
|
|
42
|
+
status: "pending",
|
|
43
|
+
disposition: null,
|
|
44
|
+
review_record: null,
|
|
45
|
+
reopen_reason: reopenReason,
|
|
46
|
+
queued_at: queuedAt,
|
|
47
|
+
terminal_at: null,
|
|
48
|
+
expires_at: null,
|
|
49
|
+
};
|
|
50
|
+
return sealPersonalGlossaryReviewRecord({ ...body, review_id: reviewIdentity(body) });
|
|
51
|
+
}
|
|
52
|
+
function suppresses(record) {
|
|
53
|
+
return record.disposition === "reject" || record.disposition === "defer";
|
|
54
|
+
}
|
|
55
|
+
function sameSuppressionBinding(previous, current) {
|
|
56
|
+
return previous.candidate_id === current.candidate_id &&
|
|
57
|
+
previous.semantic_fingerprint === current.semantic_fingerprint &&
|
|
58
|
+
previous.scope === current.scope && previous.policy_version === current.policy_version;
|
|
59
|
+
}
|
|
60
|
+
function reopeningReason(previous, current) {
|
|
61
|
+
if (previous.candidate_id !== current.candidate_id)
|
|
62
|
+
return null;
|
|
63
|
+
if (previous.policy_version !== current.policy_version)
|
|
64
|
+
return "policy_changed";
|
|
65
|
+
if (previous.scope !== current.scope)
|
|
66
|
+
return "scope_changed";
|
|
67
|
+
if (previous.semantic_fingerprint !== current.semantic_fingerprint)
|
|
68
|
+
return "meaning_changed";
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function latestComparableRecord(records, candidateId, now) {
|
|
72
|
+
return records.filter(isCurrentReviewRecord).filter((record) => record.candidate_id === candidateId && record.disposition !== null && !terminalReviewRecordExpired(record, now)).sort((left, right) => Date.parse(right.queued_at) - Date.parse(left.queued_at) || compareGlossaryUnicodeStrings(left.review_id, right.review_id))[0] ?? null;
|
|
73
|
+
}
|
|
74
|
+
function publicationAuthorization(record) {
|
|
75
|
+
return record.review_record && ["accept", "correct"].includes(String(record.disposition))
|
|
76
|
+
? { review_id: record.review_id, review_record_sha256: record.review_record.record_sha256 }
|
|
77
|
+
: null;
|
|
78
|
+
}
|
|
79
|
+
export function currentPersonalGlossaryReviewRecords(options = {}, now = new Date().toISOString()) {
|
|
80
|
+
if (!timestamp(now))
|
|
81
|
+
throw new TypeError("review read time must be an ISO timestamp");
|
|
82
|
+
const current = readPersonalGlossaryReviewRecords(options);
|
|
83
|
+
if (current.status === "missing")
|
|
84
|
+
return { status: "current", records: [], expired_records: 0, stale_records: 0 };
|
|
85
|
+
if (current.status !== "current" || current.store === null)
|
|
86
|
+
return { status: current.status, records: [], expired_records: 0, stale_records: 0 };
|
|
87
|
+
const projection = readCurrentPersonalGlossaryCandidateProjection(options);
|
|
88
|
+
// Keep stale metadata observable only through the existing degraded count.
|
|
89
|
+
if (projection.status === "projection_stale") {
|
|
90
|
+
return {
|
|
91
|
+
status: "current",
|
|
92
|
+
records: [],
|
|
93
|
+
expired_records: 0,
|
|
94
|
+
stale_records: current.store.records.length,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (projection.status !== "current" || projection.projection === null)
|
|
98
|
+
return { status: "projection_unavailable", records: [], expired_records: 0, stale_records: 0 };
|
|
99
|
+
let expiredRecords = 0;
|
|
100
|
+
let staleRecords = 0;
|
|
101
|
+
const records = current.store.records.filter((record) => {
|
|
102
|
+
if (terminalReviewRecordExpired(record, now)) {
|
|
103
|
+
expiredRecords += 1;
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (!recordMatchesProjection(record, projection.projection)) {
|
|
107
|
+
staleRecords += 1;
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}).map(readablePersonalGlossaryReviewRecord);
|
|
112
|
+
return { status: "current", records, expired_records: expiredRecords, stale_records: staleRecords };
|
|
113
|
+
}
|
|
114
|
+
/** Queue one current review-required decision without accepting a user disposition. */
|
|
115
|
+
export function queuePersonalGlossaryReviewRecord(input) {
|
|
116
|
+
const queuedAt = input.now ?? new Date().toISOString();
|
|
117
|
+
if (!timestamp(queuedAt))
|
|
118
|
+
throw new TypeError("review queue time must be an ISO timestamp");
|
|
119
|
+
if (!mapping(input.receipt))
|
|
120
|
+
return { status: "decision_not_review_required", reason: "receipt_invalid", record: null, reopen_reason: null };
|
|
121
|
+
const options = { env: input.env, platform: input.platform };
|
|
122
|
+
const decisionResult = decidePersonalGlossaryCandidate(input.receipt, options);
|
|
123
|
+
if (decisionResult.status !== "review_required" || decisionResult.decision === null)
|
|
124
|
+
return { status: "decision_not_review_required", reason: decisionResult.reason, record: null, reopen_reason: null };
|
|
125
|
+
const decision = decisionResult.decision;
|
|
126
|
+
const projection = readCurrentPersonalGlossaryCandidateProjection(options);
|
|
127
|
+
if (projection.status !== "current" || projection.projection === null || projection.projection.projection_sha256 !== decision.candidate_projection_sha256)
|
|
128
|
+
return { status: "current_binding_mismatch", reason: "projection_unavailable", record: null, reopen_reason: null };
|
|
129
|
+
const candidate = exactCandidate(projection.projection.candidates, decision);
|
|
130
|
+
const scope = reviewScope(input.receipt);
|
|
131
|
+
if (!validPersonalGlossaryReviewGenerationBinding(decision.generation) || !validPersonalGlossaryReviewMetadataBinding(decision.policy_version))
|
|
132
|
+
return { status: "current_binding_mismatch", reason: "record_binding_mismatch", record: null, reopen_reason: null };
|
|
133
|
+
if (candidate === null || scope === null || validateGlossaryHostClassificationReceipt(input.receipt, candidate.capsule, { candidateProjectionSha256: projection.projection.projection_sha256 }).length > 0 || validateGlossaryAdmissionDecision(decision, candidate.capsule, input.receipt).length > 0)
|
|
134
|
+
return { status: "current_binding_mismatch", reason: "candidate_binding_mismatch", record: null, reopen_reason: null };
|
|
135
|
+
const current = readPersonalGlossaryReviewRecords(options);
|
|
136
|
+
if (current.status === "corrupt" || (current.store !== null && isLegacyReviewStore(current.store)))
|
|
137
|
+
return { status: "records_unavailable", reason: "review_records_unavailable", record: null, reopen_reason: null };
|
|
138
|
+
const records = current.store?.records ?? [];
|
|
139
|
+
const candidateRecord = pendingRecord(decision, scope, queuedAt, null);
|
|
140
|
+
const existing = records.find((record) => record.review_id === candidateRecord.review_id);
|
|
141
|
+
if (existing) {
|
|
142
|
+
if (!isCurrentReviewRecord(existing))
|
|
143
|
+
return { status: "records_unavailable", reason: "review_records_unavailable", record: null, reopen_reason: null };
|
|
144
|
+
if (suppresses(existing))
|
|
145
|
+
return { status: "suppressed", reason: existing.reason, record: existing, reopen_reason: null };
|
|
146
|
+
if (existing.status === "pending") {
|
|
147
|
+
ensurePersonalGlossaryReviewRecordsPrivate(personalGlossaryReviewRecordsPath(options));
|
|
148
|
+
return { status: "unchanged_replay", reason: existing.reason, record: existing, reopen_reason: existing.reopen_reason };
|
|
149
|
+
}
|
|
150
|
+
return { status: "already_terminal", reason: "review_already_terminal", record: null, reopen_reason: null };
|
|
151
|
+
}
|
|
152
|
+
const suppressed = records.filter(isCurrentReviewRecord).find((record) => !terminalReviewRecordExpired(record, queuedAt) && suppresses(record) && sameSuppressionBinding(record, candidateRecord));
|
|
153
|
+
if (suppressed)
|
|
154
|
+
return { status: "suppressed", reason: suppressed.reason, record: suppressed, reopen_reason: null };
|
|
155
|
+
const previous = latestComparableRecord(records, decision.candidate_id, queuedAt);
|
|
156
|
+
const reopenReason = previous ? reopeningReason(previous, candidateRecord) : null;
|
|
157
|
+
const record = reopenReason === null ? candidateRecord : pendingRecord(decision, scope, queuedAt, reopenReason);
|
|
158
|
+
if (records.length >= personalGlossaryReviewRecordsStorageContract().recordsMax)
|
|
159
|
+
return { status: "record_capacity_exceeded", reason: "review_record_capacity_exceeded", record: null, reopen_reason: null };
|
|
160
|
+
privateWritePersonalGlossaryReviewRecords(personalGlossaryReviewRecordsPath(options), `${canonicalGlossaryJson(makePersonalGlossaryReviewStore([...records, record], current.store?.replay_index ?? []))}\n`);
|
|
161
|
+
return { status: reopenReason === null ? "queued" : "reopened", reason: record.reason, record, reopen_reason: reopenReason };
|
|
162
|
+
}
|
|
163
|
+
function currentRecordForDisposition(record, receipt) {
|
|
164
|
+
if (isCurrentReviewRecord(record))
|
|
165
|
+
return record;
|
|
166
|
+
const scope = reviewScope(receipt);
|
|
167
|
+
if (scope === null)
|
|
168
|
+
return null;
|
|
169
|
+
try {
|
|
170
|
+
return migrateLegacyPendingReviewRecord(record, scope);
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** Record one signed current-user disposition after current source and replay validation. */
|
|
177
|
+
export function dispositionPersonalGlossaryReviewRecord(input) {
|
|
178
|
+
const now = input.now ?? new Date().toISOString();
|
|
179
|
+
if (!timestamp(now))
|
|
180
|
+
throw new TypeError("review disposition time must be an ISO timestamp");
|
|
181
|
+
if (!digest(input.review_id) || !mapping(input.receipt) || !mapping(input.approval))
|
|
182
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
183
|
+
const options = { env: input.env, platform: input.platform };
|
|
184
|
+
const current = readPersonalGlossaryReviewRecords(options);
|
|
185
|
+
if (current.status !== "current" || current.store === null)
|
|
186
|
+
return { status: current.status === "corrupt" ? "records_unavailable" : "review_not_found", record: null, publication_authorization: null };
|
|
187
|
+
const storedRecord = current.store.records.find((record) => record.review_id === input.review_id);
|
|
188
|
+
if (!storedRecord || terminalReviewRecordExpired(storedRecord, now))
|
|
189
|
+
return { status: "review_not_found", record: null, publication_authorization: null };
|
|
190
|
+
const decisionResult = decidePersonalGlossaryCandidate(input.receipt, options);
|
|
191
|
+
if (decisionResult.status !== "review_required" || decisionResult.decision === null)
|
|
192
|
+
return { status: "current_binding_mismatch", record: null, publication_authorization: null };
|
|
193
|
+
const decision = decisionResult.decision;
|
|
194
|
+
const projection = readCurrentPersonalGlossaryCandidateProjection(options);
|
|
195
|
+
if (projection.status !== "current" || projection.projection === null || !recordMatchesProjection(storedRecord, projection.projection))
|
|
196
|
+
return { status: "current_binding_mismatch", record: null, publication_authorization: null };
|
|
197
|
+
const candidate = exactCandidate(projection.projection.candidates, decision);
|
|
198
|
+
if (candidate === null || decision.candidate_id !== storedRecord.candidate_id || decision.candidate_revision !== storedRecord.candidate_revision || decision.candidate_capsule_sha256 !== storedRecord.candidate_capsule_sha256 || decision.candidate_projection_sha256 !== storedRecord.candidate_projection_sha256 || decision.host_receipt_sha256 !== storedRecord.host_receipt_sha256 || decision.decision_sha256 !== storedRecord.cli_decision_sha256 || decision.semantic_fingerprint !== storedRecord.semantic_fingerprint || decision.generation !== storedRecord.generation || decision.policy_version !== storedRecord.policy_version || validateGlossaryHostClassificationReceipt(input.receipt, candidate.capsule, { candidateProjectionSha256: projection.projection.projection_sha256 }).length > 0 || validateGlossaryAdmissionDecision(decision, candidate.capsule, input.receipt).length > 0)
|
|
199
|
+
return { status: "current_binding_mismatch", record: null, publication_authorization: null };
|
|
200
|
+
const record = currentRecordForDisposition(storedRecord, input.receipt);
|
|
201
|
+
if (!record)
|
|
202
|
+
return { status: "current_binding_mismatch", record: null, publication_authorization: null };
|
|
203
|
+
const trustedHost = readPersonalGlossaryTrustedLocalHost(options);
|
|
204
|
+
if (!trustedHost)
|
|
205
|
+
return { status: "approval_unavailable", record: null, publication_authorization: null };
|
|
206
|
+
const replayEntries = isCurrentReviewStore(current.store) ? currentReplayIndex(current.store.replay_index, now) : [];
|
|
207
|
+
const replayNonceKey = typeof input.approval.nonce === "string" ? replayNonceDigest(input.approval.nonce) : undefined;
|
|
208
|
+
const errors = validatePersonalReviewApprovalReceipt(input.approval, {
|
|
209
|
+
currentUserSubject: trustedHost.subject,
|
|
210
|
+
reviewId: record.review_id,
|
|
211
|
+
candidateId: record.candidate_id,
|
|
212
|
+
candidateRevision: record.candidate_revision,
|
|
213
|
+
candidateProjectionSha256: record.candidate_projection_sha256,
|
|
214
|
+
semanticFingerprint: record.semantic_fingerprint,
|
|
215
|
+
generation: record.generation,
|
|
216
|
+
policyVersion: record.policy_version,
|
|
217
|
+
now: new Date(now),
|
|
218
|
+
trustedHostPublicKey: trustedHost.publicKey,
|
|
219
|
+
consumedReceiptDigests: activeReplayDigestMap(replayEntries, now),
|
|
220
|
+
replayNonceKey,
|
|
221
|
+
});
|
|
222
|
+
let replay;
|
|
223
|
+
let receiptDigest;
|
|
224
|
+
let nonceDigest;
|
|
225
|
+
try {
|
|
226
|
+
replay = personalReviewApprovalReplayStatus(input.approval, replayDigestMap(replayEntries), replayNonceKey);
|
|
227
|
+
receiptDigest = personalReviewApprovalReceiptDigest(input.approval);
|
|
228
|
+
nonceDigest = replayNonceDigest(String(input.approval.nonce));
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
232
|
+
}
|
|
233
|
+
if (replay === "conflicting_replay")
|
|
234
|
+
return { status: "approval_conflicting_replay", record: null, publication_authorization: null };
|
|
235
|
+
if (errors.length > 0)
|
|
236
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
237
|
+
if (replay === "exact_replay")
|
|
238
|
+
return { status: "unchanged_replay", record, publication_authorization: publicationAuthorization(record) };
|
|
239
|
+
if (record.status === "terminal")
|
|
240
|
+
return { status: "review_not_pending", record: null, publication_authorization: null };
|
|
241
|
+
const disposition = input.approval.disposition;
|
|
242
|
+
if (disposition === "correct" && typeof input.approval.corrected_meaning !== "string")
|
|
243
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
244
|
+
if (replayEntries.length >= personalGlossaryReviewRecordsStorageContract().replayEntriesMax)
|
|
245
|
+
return { status: "replay_capacity_exceeded", record: null, publication_authorization: null };
|
|
246
|
+
let review;
|
|
247
|
+
try {
|
|
248
|
+
review = createGlossaryReviewRecord({
|
|
249
|
+
capsule: candidate.capsule,
|
|
250
|
+
receipt: input.receipt,
|
|
251
|
+
decision,
|
|
252
|
+
disposition,
|
|
253
|
+
corrected_meaning: input.approval.corrected_meaning,
|
|
254
|
+
corrected_scope: input.approval.corrected_scope,
|
|
255
|
+
disposed_at: input.approval.disposed_at,
|
|
256
|
+
expires_at: reviewExpiry(input.approval.disposed_at),
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
261
|
+
}
|
|
262
|
+
const terminal = personalReviewDispositionLifecycle(disposition) === "terminal";
|
|
263
|
+
let nextRecord;
|
|
264
|
+
try {
|
|
265
|
+
nextRecord = sealPersonalGlossaryReviewRecord({
|
|
266
|
+
...record,
|
|
267
|
+
scope: disposition === "correct" ? "personal" : record.scope,
|
|
268
|
+
status: terminal ? "terminal" : "pending",
|
|
269
|
+
disposition,
|
|
270
|
+
review_record: review,
|
|
271
|
+
terminal_at: terminal ? review.disposed_at : null,
|
|
272
|
+
expires_at: terminal ? review.expires_at : null,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return { status: "approval_invalid", record: null, publication_authorization: null };
|
|
277
|
+
}
|
|
278
|
+
const replayEntry = { nonce_sha256: nonceDigest, receipt_sha256: receiptDigest, expires_at: input.approval.expires_at };
|
|
279
|
+
const next = makePersonalGlossaryReviewStore(current.store.records.map((item) => item.review_id === record.review_id ? nextRecord : item), [...replayEntries, replayEntry]);
|
|
280
|
+
try {
|
|
281
|
+
privateWritePersonalGlossaryReviewRecords(personalGlossaryReviewRecordsPath(options), `${canonicalGlossaryJson(next)}\n`);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return { status: "records_unavailable", record: null, publication_authorization: null };
|
|
285
|
+
}
|
|
286
|
+
return { status: "disposed", record: nextRecord, publication_authorization: publicationAuthorization(nextRecord) };
|
|
287
|
+
}
|
|
288
|
+
/** Resolve one stored accept/correct authorization without treating it as current evidence. */
|
|
289
|
+
export function personalGlossaryReviewPublicationAuthorization(input) {
|
|
290
|
+
const now = input.now ?? new Date().toISOString();
|
|
291
|
+
if (!timestamp(now) || !digest(input.review_id) || !digest(input.review_record_sha256))
|
|
292
|
+
return { status: "binding_mismatch", review: null };
|
|
293
|
+
const current = readPersonalGlossaryReviewRecords({ env: input.env, platform: input.platform });
|
|
294
|
+
if (current.status !== "current" || current.store === null)
|
|
295
|
+
return { status: "unavailable", review: null };
|
|
296
|
+
const projection = readCurrentPersonalGlossaryCandidateProjection({ env: input.env, platform: input.platform });
|
|
297
|
+
if (projection.status !== "current" || projection.projection === null)
|
|
298
|
+
return { status: "unavailable", review: null };
|
|
299
|
+
const storedRecord = current.store.records.find((record) => record.review_id === input.review_id);
|
|
300
|
+
if (!storedRecord || !isCurrentReviewRecord(storedRecord) || terminalReviewRecordExpired(storedRecord, now) || !storedRecord.review_record || storedRecord.status !== "terminal")
|
|
301
|
+
return { status: "not_publishable", review: null };
|
|
302
|
+
if (storedRecord.review_record.record_sha256 !== input.review_record_sha256 || !["accept", "correct"].includes(String(storedRecord.disposition)) || !recordMatchesProjection(storedRecord, projection.projection) || storedRecord.candidate_projection_sha256 !== input.candidate_projection_sha256 || storedRecord.candidate_id !== input.capsule.candidate_id || storedRecord.candidate_revision !== input.capsule.candidate_revision || storedRecord.candidate_capsule_sha256 !== input.capsule.capsule_sha256 || storedRecord.host_receipt_sha256 !== input.receipt.receipt_sha256 || storedRecord.cli_decision_sha256 !== input.decision.decision_sha256 || storedRecord.semantic_fingerprint !== input.receipt.semantic_fingerprint || storedRecord.generation !== input.capsule.generation || storedRecord.policy_version !== input.capsule.policy_version || validateGlossaryReviewRecord(storedRecord.review_record, input.capsule, input.receipt, input.decision).length > 0)
|
|
303
|
+
return { status: "binding_mismatch", review: null };
|
|
304
|
+
return { status: "authorized", review: storedRecord.review_record };
|
|
305
|
+
}
|
|
306
|
+
/** Remove expired terminal metadata and receipt replay digests, or a purged local store only. */
|
|
307
|
+
export function maintainPersonalGlossaryReviewRecords(input) {
|
|
308
|
+
if (!timestamp(input.now))
|
|
309
|
+
throw new TypeError("review maintenance time must be an ISO timestamp");
|
|
310
|
+
const options = { env: input.env, platform: input.platform };
|
|
311
|
+
const current = readPersonalGlossaryReviewRecords(options);
|
|
312
|
+
if (current.status === "missing" || current.status === "corrupt")
|
|
313
|
+
return { status: current.status, expired_records: 0, expired_receipts: 0 };
|
|
314
|
+
const pathname = personalGlossaryReviewRecordsPath(options);
|
|
315
|
+
if (input.current_user_purge_authorized === true) {
|
|
316
|
+
fs.rmSync(pathname, { force: true });
|
|
317
|
+
return { status: "purged", expired_records: 0, expired_receipts: 0 };
|
|
318
|
+
}
|
|
319
|
+
if (isLegacyReviewStore(current.store))
|
|
320
|
+
return { status: "unchanged", expired_records: 0, expired_receipts: 0 };
|
|
321
|
+
const records = current.store.records.filter((record) => !terminalReviewRecordExpired(record, input.now));
|
|
322
|
+
const replayIndex = currentReplayIndex(current.store.replay_index, input.now);
|
|
323
|
+
const expiredRecords = current.store.records.length - records.length;
|
|
324
|
+
const expiredReceipts = current.store.replay_index.length - replayIndex.length;
|
|
325
|
+
if (expiredRecords === 0 && expiredReceipts === 0)
|
|
326
|
+
return { status: "unchanged", expired_records: 0, expired_receipts: 0 };
|
|
327
|
+
if (records.length === 0 && replayIndex.length === 0)
|
|
328
|
+
fs.rmSync(pathname, { force: true });
|
|
329
|
+
else
|
|
330
|
+
privateWritePersonalGlossaryReviewRecords(pathname, `${canonicalGlossaryJson(makePersonalGlossaryReviewStore(records, replayIndex))}\n`);
|
|
331
|
+
return { status: "changed", expired_records: expiredRecords, expired_receipts: expiredReceipts };
|
|
332
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { PROFILE_SIGNAL_TYPES, profileSufficiency, } from "../registries/evidenceTierContract.js";
|
|
3
|
+
import { readCurrentPointer, readSignalTier, resolveEvidenceAnchor, } from "./extractCorpus/evidenceTiers.js";
|
|
4
|
+
import { assessTiers, recoveryForState, resolveTiersDir, } from "./extractCorpus/tierReader.js";
|
|
5
|
+
const PROFILE_TYPES_SET = new Set(PROFILE_SIGNAL_TYPES);
|
|
6
|
+
/** Resolve the absolute signal tier file path from the current generation. */
|
|
7
|
+
function signalTierPath(tiersDir) {
|
|
8
|
+
const pointer = readCurrentPointer(tiersDir);
|
|
9
|
+
if (!pointer)
|
|
10
|
+
return null;
|
|
11
|
+
return path.join(tiersDir, "generations", pointer.generation, "signal.json");
|
|
12
|
+
}
|
|
13
|
+
/** Resolve the co-located corpus path for legacy compatibility assessment. */
|
|
14
|
+
function corpusPathFromTiersDir(tiersDir) {
|
|
15
|
+
const idx = tiersDir.lastIndexOf(path.sep + "tiers");
|
|
16
|
+
if (idx === -1)
|
|
17
|
+
return undefined;
|
|
18
|
+
return path.join(tiersDir.slice(0, idx), "corpus.json");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Assess whether the retained profile-relevant signal distribution is
|
|
22
|
+
* sufficient against the contract threshold. The prior intended distribution
|
|
23
|
+
* is reconstructed from the signal tier's selection report (total per
|
|
24
|
+
* family); the retained distribution from the published signal records.
|
|
25
|
+
* No separate full-corpus read is needed — the selection report carries both.
|
|
26
|
+
*
|
|
27
|
+
* When the tier is uncapped, retained == total, so the bounded and intended
|
|
28
|
+
* distributions are identical and sufficiency is trivially met. When capped,
|
|
29
|
+
* the selection report's per-family total/retained is the authoritative prior
|
|
30
|
+
* distribution; the profile-relevant intended count is scaled from the
|
|
31
|
+
* retained profile-relevant count by the family's overall retention ratio.
|
|
32
|
+
*/
|
|
33
|
+
export function assessProfileSufficiency(selection, signals, contractPath) {
|
|
34
|
+
const suff = profileSufficiency(contractPath);
|
|
35
|
+
const threshold = suff.minimumFamilyRetention;
|
|
36
|
+
const profileRetainedPerFamily = new Map();
|
|
37
|
+
for (const sig of signals) {
|
|
38
|
+
const family = sig.source_product || "unknown";
|
|
39
|
+
profileRetainedPerFamily.set(family, (profileRetainedPerFamily.get(family) ?? 0) + 1);
|
|
40
|
+
}
|
|
41
|
+
const profileIntendedPerFamily = new Map();
|
|
42
|
+
if (!selection.capped) {
|
|
43
|
+
// Uncapped: retained == intended, so the retained counts ARE the intended.
|
|
44
|
+
for (const [family, retained] of profileRetainedPerFamily) {
|
|
45
|
+
profileIntendedPerFamily.set(family, retained);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Capped: the selection report's per_family is the authoritative source
|
|
50
|
+
// of which families had records. For families with profile-relevant
|
|
51
|
+
// retained signals, scale the intended count by the family's overall
|
|
52
|
+
// retention ratio. For families where all records were capped
|
|
53
|
+
// (retained=0, total>0), flag them as insufficient — no data survived
|
|
54
|
+
// to contribute to the profile.
|
|
55
|
+
for (const sel of selection.per_family) {
|
|
56
|
+
if (sel.total === 0)
|
|
57
|
+
continue;
|
|
58
|
+
const profileRetained = profileRetainedPerFamily.get(sel.family) ?? 0;
|
|
59
|
+
if (sel.retained > 0 && profileRetained > 0) {
|
|
60
|
+
profileIntendedPerFamily.set(sel.family, Math.round(profileRetained * (sel.total / sel.retained)));
|
|
61
|
+
}
|
|
62
|
+
else if (sel.retained === 0 && sel.total > 0) {
|
|
63
|
+
// All records for this family were capped — insufficient by definition.
|
|
64
|
+
profileIntendedPerFamily.set(sel.family, sel.total);
|
|
65
|
+
}
|
|
66
|
+
// If sel.retained > 0 but profileRetained == 0, the family's retained
|
|
67
|
+
// records were simply non-profile-relevant; leave it as sufficient.
|
|
68
|
+
}
|
|
69
|
+
// Also include any family that appears in retained signals but not in the
|
|
70
|
+
// selection report (should not normally happen, but handle gracefully).
|
|
71
|
+
for (const [family, retained] of profileRetainedPerFamily) {
|
|
72
|
+
if (!profileIntendedPerFamily.has(family)) {
|
|
73
|
+
profileIntendedPerFamily.set(family, retained);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const perFamily = [];
|
|
78
|
+
const allFamilies = new Set([...profileIntendedPerFamily.keys(), ...profileRetainedPerFamily.keys()]);
|
|
79
|
+
for (const family of [...allFamilies].sort()) {
|
|
80
|
+
const intended = profileIntendedPerFamily.get(family) ?? 0;
|
|
81
|
+
const retained = profileRetainedPerFamily.get(family) ?? 0;
|
|
82
|
+
const retention = intended > 0 ? retained / intended : 1;
|
|
83
|
+
const sufficient = intended === 0 || retention >= threshold;
|
|
84
|
+
perFamily.push({ family, intended, retained, retention, sufficient });
|
|
85
|
+
}
|
|
86
|
+
const insufficientFamilies = perFamily.filter((f) => !f.sufficient);
|
|
87
|
+
const sufficient = !selection.capped || insufficientFamilies.length === 0;
|
|
88
|
+
const reason = sufficient
|
|
89
|
+
? selection.capped
|
|
90
|
+
? "signal tier capped but per-family retention meets threshold"
|
|
91
|
+
: "signal tier uncapped; bounded and intended distributions identical"
|
|
92
|
+
: `insufficient retention for families: ${insufficientFamilies.map((f) => `${f.family} (${f.retained}/${f.intended}, ${(f.retention * 100).toFixed(0)}%)`).join(", ")}`;
|
|
93
|
+
return { sufficient, reason, threshold, capped: selection.capped, per_family: perFamily };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the bounded signal tier and return profile-relevant signals with a
|
|
97
|
+
* sufficiency assessment. This is the bounded profile-synthesis input: it
|
|
98
|
+
* loads only the signal tier (bounded by construction), never the full-
|
|
99
|
+
* evidence shards. Each signal's `evidence_anchor` resolves to retained full
|
|
100
|
+
* evidence via resolveProfileEvidence.
|
|
101
|
+
*/
|
|
102
|
+
export function readProfileSignals(tiersDir, corpusPath, contractPath) {
|
|
103
|
+
const assessment = assessTiers(tiersDir, corpusPath);
|
|
104
|
+
const recovery = recoveryForState(assessment.state);
|
|
105
|
+
const threshold = profileSufficiency(contractPath).minimumFamilyRetention;
|
|
106
|
+
if (!assessment.analyzable) {
|
|
107
|
+
return {
|
|
108
|
+
state: assessment.state,
|
|
109
|
+
tiers_dir: tiersDir,
|
|
110
|
+
signal_path: null,
|
|
111
|
+
signals: [],
|
|
112
|
+
profile_signal_count: 0,
|
|
113
|
+
sufficiency: {
|
|
114
|
+
sufficient: false,
|
|
115
|
+
reason: assessment.state === "missing"
|
|
116
|
+
? "no evidence tiers published"
|
|
117
|
+
: assessment.state === "legacy"
|
|
118
|
+
? "legacy monolithic state; refresh required"
|
|
119
|
+
: `tier state ${assessment.state}; ${recovery ?? "recovery unavailable"}`,
|
|
120
|
+
threshold,
|
|
121
|
+
capped: false,
|
|
122
|
+
per_family: [],
|
|
123
|
+
},
|
|
124
|
+
recovery,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const tier = readSignalTier(tiersDir);
|
|
128
|
+
if (!tier) {
|
|
129
|
+
return {
|
|
130
|
+
state: "corrupt",
|
|
131
|
+
tiers_dir: tiersDir,
|
|
132
|
+
signal_path: null,
|
|
133
|
+
signals: [],
|
|
134
|
+
profile_signal_count: 0,
|
|
135
|
+
sufficiency: {
|
|
136
|
+
sufficient: false,
|
|
137
|
+
reason: "signal tier unreadable or not found",
|
|
138
|
+
threshold,
|
|
139
|
+
capped: false,
|
|
140
|
+
per_family: [],
|
|
141
|
+
},
|
|
142
|
+
recovery,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const profileSignals = tier.records.filter((s) => PROFILE_TYPES_SET.has(s.signal_type));
|
|
146
|
+
const sufficiency = assessProfileSufficiency(tier.manifest.signal.selection, profileSignals, contractPath);
|
|
147
|
+
return {
|
|
148
|
+
state: assessment.state,
|
|
149
|
+
tiers_dir: tiersDir,
|
|
150
|
+
signal_path: signalTierPath(tiersDir),
|
|
151
|
+
signals: profileSignals,
|
|
152
|
+
profile_signal_count: profileSignals.length,
|
|
153
|
+
sufficiency,
|
|
154
|
+
recovery,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolve a synthesized claim's evidence anchor to its retained full-evidence
|
|
159
|
+
* record. Loads only the owning shard, never the whole tier. Returns null
|
|
160
|
+
* when the anchor does not resolve (the claim cannot be checked).
|
|
161
|
+
*/
|
|
162
|
+
export function resolveProfileEvidence(anchor, tiersDir) {
|
|
163
|
+
return resolveEvidenceAnchor(anchor, tiersDir);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Lightweight status for profile_context — assesses the tiers, reads the
|
|
167
|
+
* signal tier, and computes sufficiency. The signal records are counted but
|
|
168
|
+
* not returned in the status payload (the synthesis step reads them via
|
|
169
|
+
* readProfileSignals or the signal_path). This status tells the agent
|
|
170
|
+
* whether synthesis can proceed and where to read.
|
|
171
|
+
*/
|
|
172
|
+
export function profileSignalsStatus(env = process.env, platform = process.platform, contractPath) {
|
|
173
|
+
const tiersDir = resolveTiersDir(env, platform);
|
|
174
|
+
const corpusPath = corpusPathFromTiersDir(tiersDir);
|
|
175
|
+
const assessment = assessTiers(tiersDir, corpusPath);
|
|
176
|
+
const recovery = recoveryForState(assessment.state);
|
|
177
|
+
if (!assessment.analyzable) {
|
|
178
|
+
return {
|
|
179
|
+
state: assessment.state,
|
|
180
|
+
tiers_dir: tiersDir,
|
|
181
|
+
signal_path: null,
|
|
182
|
+
signal_count: 0,
|
|
183
|
+
profile_signal_count: 0,
|
|
184
|
+
sufficiency: null,
|
|
185
|
+
recovery,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const tier = readSignalTier(tiersDir);
|
|
189
|
+
if (!tier) {
|
|
190
|
+
return {
|
|
191
|
+
state: "corrupt",
|
|
192
|
+
tiers_dir: tiersDir,
|
|
193
|
+
signal_path: null,
|
|
194
|
+
signal_count: 0,
|
|
195
|
+
profile_signal_count: 0,
|
|
196
|
+
sufficiency: null,
|
|
197
|
+
recovery,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const profileSignals = tier.records.filter((s) => PROFILE_TYPES_SET.has(s.signal_type));
|
|
201
|
+
const sufficiency = assessProfileSufficiency(tier.manifest.signal.selection, profileSignals, contractPath);
|
|
202
|
+
return {
|
|
203
|
+
state: assessment.state,
|
|
204
|
+
tiers_dir: tiersDir,
|
|
205
|
+
signal_path: signalTierPath(tiersDir),
|
|
206
|
+
signal_count: tier.records.length,
|
|
207
|
+
profile_signal_count: profileSignals.length,
|
|
208
|
+
sufficiency,
|
|
209
|
+
recovery,
|
|
210
|
+
};
|
|
211
|
+
}
|