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,816 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { CAPABILITY_INSTRUCTIONS, capabilityInstructionModulePath } from "../capabilities/index.js";
|
|
5
|
+
import { capabilityInstructionTarget } from "../cli/capabilityContext/contract.js";
|
|
6
|
+
import { CAPABILITY_ROUTING_NAMES } from "../cli/commands/capability.js";
|
|
7
|
+
import { DISPATCHER_COMMANDS, DISPATCHER_TOP_LEVEL_COMMANDS } from "../cli/dispatch/commands.js";
|
|
8
|
+
import { DIAGNOSTIC_TOP_LEVEL_COMMANDS, HELP_TOP_LEVEL_COMMANDS, SCHEMA_TOP_LEVEL_COMMANDS, } from "../cli/dispatch/projections.js";
|
|
9
|
+
import { printTopLevelHelp } from "../cli/help.js";
|
|
10
|
+
import { isNpxBundleRoot, resolveSourceRoot } from "../core/sourceRoot.js";
|
|
11
|
+
import { loadYamlMapping } from "../core/yaml.js";
|
|
12
|
+
import { ACTIVATION_CENSUS_AUTHORITY, ACTIVATION_CHECK_IDS, ACTIVATION_CLASSES, ACTIVATION_CLASS_AUTHORITIES, ACTIVATION_DIMENSIONS, ACTIVATION_EVIDENCE_SOURCES, } from "../registries/activationContract.js";
|
|
13
|
+
import { ACTIVATION_CANONICAL_TUPLES, ACTIVATION_TUPLE_AUTHORITY, canonicalTupleJson, digestCanonicalTuples, } from "../registries/activationTuples.js";
|
|
14
|
+
import { loadCapabilitySchemaContract } from "../registries/capabilityContract.js";
|
|
15
|
+
import { loadPackagePublicationModel } from "../registries/packagePublication.js";
|
|
16
|
+
import { loadRegistry } from "../registries/packageRegistry.js";
|
|
17
|
+
import { loadLifecycleAuthority } from "../runtime/lifecycleAuthority.js";
|
|
18
|
+
import { loadNativeResourceCleanupContract, retiredResourceDiagnosticIds, } from "../runtime/nativeResourceCleanup.js";
|
|
19
|
+
import { entityListFamilies } from "../state/entityRetrievalHelp.js";
|
|
20
|
+
import { ENTITY_LIST_RUNTIME_BOUNDS, ENTITY_LIST_RUNTIME_FAMILIES } from "../state/entityListRuntimeRegistry.js";
|
|
21
|
+
import { stateWriterContract } from "../state/write/operations.js";
|
|
22
|
+
import { runtimeOperationSpecs } from "../state/write/runtimeOperations.js";
|
|
23
|
+
import { BOOTSTRAP_ACCEPTED_SPECS, BOOTSTRAP_REJECTION_SPECS, bootstrapMatrixAuthority, } from "./bootstrapAuthority.js";
|
|
24
|
+
import { ACTIVATION_EVIDENCE_FILE, activationEvidenceViolations, readActivationEvidenceManifest, } from "./activationEvidenceManifest.js";
|
|
25
|
+
import { packageDescriptorSemantics, packageDescriptors, packageSemanticSelector, } from "./activationPackageSemantics.js";
|
|
26
|
+
import { loadSourceCapabilityInstructions, retainedPackageSnapshotViolations, } from "./activationArtifactEvidence.js";
|
|
27
|
+
const OWNER_PATH = /^(?:packages\/cli\/(?:src\/.+\.ts|scripts\/.+\.mjs)|references\/.+\.(?:json|ya?ml))$/;
|
|
28
|
+
const SYMBOL = /^[A-Za-z_$][A-Za-z0-9_.$-]*$/;
|
|
29
|
+
const GENERATION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
30
|
+
const RETAINED_CLASSES = new Set(["current", "migration-only", "runbook"]);
|
|
31
|
+
function exactSet(left, right) {
|
|
32
|
+
return left.length === new Set(left).size && right.length === new Set(right).size
|
|
33
|
+
&& [...left].sort().join("\0") === [...right].sort().join("\0");
|
|
34
|
+
}
|
|
35
|
+
function ownerText(owner) { return `${owner.path}#${owner.selector ?? owner.symbol}`; }
|
|
36
|
+
function tupleOwnerText(tuple) {
|
|
37
|
+
return `${tuple.owner_path}#${tuple.owner_selector ?? tuple.owner_symbol_or_selector}`;
|
|
38
|
+
}
|
|
39
|
+
function tupleDiagnostic(tuple) {
|
|
40
|
+
const semantic = tuple.semantic_selector_if_any === null ? "none" : createHash("sha256").update(tuple.semantic_selector_if_any).digest("hex");
|
|
41
|
+
return `${tuple.class}:${tuple.surface_id} owner=${tupleOwnerText(tuple)} symbol=${tuple.owner_symbol_or_selector} semantic_sha256=${semantic}`;
|
|
42
|
+
}
|
|
43
|
+
function digestIdentities(ids) {
|
|
44
|
+
return createHash("sha256").update([...ids].sort().join("\n"), "utf8").digest("hex");
|
|
45
|
+
}
|
|
46
|
+
function plainClone(value) { return JSON.parse(JSON.stringify(value)); }
|
|
47
|
+
function registryJson(root) {
|
|
48
|
+
return JSON.parse(fs.readFileSync(path.join(root, "registry.json"), "utf8"));
|
|
49
|
+
}
|
|
50
|
+
function retainedInventoryAt(root) {
|
|
51
|
+
const authority = loadYamlMapping(fs.readFileSync(path.join(root, "references/meta/retained-reference-authority.yaml"), "utf8"));
|
|
52
|
+
return Array.isArray(authority.inventory)
|
|
53
|
+
? authority.inventory.filter((entry) => RETAINED_CLASSES.has(entry?.classification))
|
|
54
|
+
: [];
|
|
55
|
+
}
|
|
56
|
+
function classAuthority(classId) { return ACTIVATION_CLASS_AUTHORITIES[classId]; }
|
|
57
|
+
function classOwnerText(classId) {
|
|
58
|
+
const owner = classAuthority(classId);
|
|
59
|
+
return `${owner.path}#${owner.selector ?? owner.symbol}`;
|
|
60
|
+
}
|
|
61
|
+
function surfacesWithClassOwner(ids, classId) {
|
|
62
|
+
const authority = classAuthority(classId);
|
|
63
|
+
return ids.map((id) => ({
|
|
64
|
+
id,
|
|
65
|
+
owner: { path: authority.path, symbol: authority.symbol, ...(authority.selector ? { selector: authority.selector } : {}) },
|
|
66
|
+
correction: authority.correction,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
function evidence(classId, dimension, identities, valid = true) {
|
|
70
|
+
return { sourceId: ACTIVATION_EVIDENCE_SOURCES[classId][dimension], identities, valid };
|
|
71
|
+
}
|
|
72
|
+
function parseDispatchCases(source) {
|
|
73
|
+
const routed = [...source.matchAll(/case\s+"([^"]+)"\s*:/g)].map((match) => match[1]);
|
|
74
|
+
return [...new Set(routed.filter((id) => id !== "version" && id !== "--version"))];
|
|
75
|
+
}
|
|
76
|
+
function helpCommandIds(text) {
|
|
77
|
+
const match = /usage: agentera \[-h\] \[--version\] \{([^}]+)\}/.exec(text);
|
|
78
|
+
return match?.[1]?.split(",") ?? [];
|
|
79
|
+
}
|
|
80
|
+
function capabilityTargets(instructions) {
|
|
81
|
+
return Object.entries(instructions).map(([id, body]) => {
|
|
82
|
+
const target = capabilityInstructionTarget(id);
|
|
83
|
+
return {
|
|
84
|
+
id,
|
|
85
|
+
module: target.module,
|
|
86
|
+
present: target.instructions_present === true,
|
|
87
|
+
length: body.length,
|
|
88
|
+
sha256: createHash("sha256").update(body, "utf8").digest("hex"),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function instructionBodyDigests(instructions) {
|
|
93
|
+
return Object.fromEntries(Object.entries(instructions).sort(([left], [right]) => left.localeCompare(right)).map(([id, body]) => [id, createHash("sha256").update(body, "utf8").digest("hex")]));
|
|
94
|
+
}
|
|
95
|
+
function exactInstructionBodies(left, right) {
|
|
96
|
+
return JSON.stringify(instructionBodyDigests(left)) === JSON.stringify(instructionBodyDigests(right));
|
|
97
|
+
}
|
|
98
|
+
function nonEmptyInstructionBodies(instructions) {
|
|
99
|
+
return Object.values(instructions).every((body) => typeof body === "string" && Buffer.byteLength(body, "utf8") > 0);
|
|
100
|
+
}
|
|
101
|
+
function packageRootFor(root, generationRoot) {
|
|
102
|
+
const bundle = generationRoot ? path.join(generationRoot, "bundle") : "";
|
|
103
|
+
return bundle && fs.existsSync(path.join(bundle, "registry.json")) ? bundle : root;
|
|
104
|
+
}
|
|
105
|
+
function runtimeIdsFromLoaded(lifecycle, retired) {
|
|
106
|
+
return [
|
|
107
|
+
...(lifecycle.runtimes.length === 0 ? ["portable.shared-skill-cli"] : []),
|
|
108
|
+
...[...new Set(retired.resources.map(({ host }) => `host:${host}`))].sort(),
|
|
109
|
+
...retiredResourceDiagnosticIds(retired).map((id) => `retired:${id}`),
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
function expandedDiagnosticRecordIds(record) {
|
|
113
|
+
if (!record.id.includes("{name}"))
|
|
114
|
+
return [record.id];
|
|
115
|
+
return record.names.map((name) => record.id.replace("{name}", name));
|
|
116
|
+
}
|
|
117
|
+
function runtimeBehaviorIds(lifecycle, retired) {
|
|
118
|
+
return [
|
|
119
|
+
...(lifecycle.runtimes.length === 0 && lifecycle.canonicalSkillPath ? ["portable.shared-skill-cli"] : []),
|
|
120
|
+
...[...new Set(retired.resources.filter(({ hostSupportStatus }) => Boolean(hostSupportStatus)).map(({ host }) => `host:${host}`))].sort(),
|
|
121
|
+
...retired.diagnosticResources.filter(({ destinations }) => destinations.length > 0).flatMap((record) => expandedDiagnosticRecordIds(record).map((id) => `retired:${id}`)),
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
function runtimeDiagnosticIds(lifecycle, retired) {
|
|
125
|
+
return [
|
|
126
|
+
...(lifecycle.sourcePath.endsWith("runtime-lifecycle-authority.yaml") ? ["portable.shared-skill-cli"] : []),
|
|
127
|
+
...[...new Set(retired.resources.filter(({ durableProof }) => durableProof.length > 0).map(({ host }) => `host:${host}`))].sort(),
|
|
128
|
+
...retiredResourceDiagnosticIds(retired).map((id) => `retired:${id}`),
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
function runtimeInstructionIds(lifecycle, retired) {
|
|
132
|
+
return [
|
|
133
|
+
...(lifecycle.canonicalSkillPath ? ["portable.shared-skill-cli"] : []),
|
|
134
|
+
...[...new Set(retired.resources.filter(({ safetyNote }) => safetyNote.length > 0).map(({ host }) => `host:${host}`))].sort(),
|
|
135
|
+
...retired.diagnosticResources.filter(({ id, destinations, names, contains }) => destinations.length > 0 && (names.length > 0 || contains !== null || !id.includes("{name}"))).flatMap((record) => expandedDiagnosticRecordIds(record).map((id) => `retired:${id}`)),
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
function runtimeAdversarialIds(lifecycle, retired) {
|
|
139
|
+
return runtimeIdsFromLoaded(lifecycle, retired).filter((id) => /^[A-Za-z0-9][A-Za-z0-9._:-]+$/.test(id));
|
|
140
|
+
}
|
|
141
|
+
function referenceIds(inventory) { return inventory.map((entry) => String(entry.path)); }
|
|
142
|
+
function referenceBehaviorIds(inventory) {
|
|
143
|
+
return inventory.filter((entry) => entry.classification === "runbook"
|
|
144
|
+
? typeof entry.command === "string" && entry.command.length > 0
|
|
145
|
+
: Array.isArray(entry.consumers) && entry.consumers.some((consumer) => ["runtime", "validator"].includes(consumer?.kind) && consumer?.consumption === "loads"))
|
|
146
|
+
.map((entry) => entry.path);
|
|
147
|
+
}
|
|
148
|
+
function referenceDiagnosticIds(inventory) {
|
|
149
|
+
return inventory.filter((entry) => typeof entry.path === "string" && (entry.classification === "runbook"
|
|
150
|
+
? typeof entry.maintainer === "string" && typeof entry.working_directory === "string" && typeof entry.command === "string"
|
|
151
|
+
: entry.production_owner && Array.isArray(entry.consumers) && entry.consumers.length > 0)).map((entry) => entry.path);
|
|
152
|
+
}
|
|
153
|
+
function referenceInstructionIds(inventory) {
|
|
154
|
+
return inventory.filter((entry) => entry.classification === "runbook"
|
|
155
|
+
? entry.source_checkout_root === "." && entry.working_directory === "." && /^(?:pnpm|node) /.test(entry.command ?? "")
|
|
156
|
+
: Array.isArray(entry.consumers) && entry.consumers.every((consumer) => typeof consumer.module === "string" && typeof consumer.symbol === "string"))
|
|
157
|
+
.map((entry) => entry.path);
|
|
158
|
+
}
|
|
159
|
+
function referenceAdversarialIds(inventory) {
|
|
160
|
+
return inventory.filter((entry) => entry.classification === "runbook"
|
|
161
|
+
? !/[\0\r\n]/.test(entry.command ?? "")
|
|
162
|
+
: OWNER_PATH.test(entry.production_owner?.module ?? "") && SYMBOL.test(entry.production_owner?.symbol ?? ""))
|
|
163
|
+
.map((entry) => entry.path);
|
|
164
|
+
}
|
|
165
|
+
function stateIds(input) {
|
|
166
|
+
return [
|
|
167
|
+
...input.readFamilies.map((family) => `read:${family.key}`),
|
|
168
|
+
...input.operations.map((operation) => `write:${operation.artifact}.${operation.verb}`),
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
function stateProjectionIds(input) {
|
|
172
|
+
const reads = input.helpFamilies.map((family) => `read:${family.key}`);
|
|
173
|
+
const artifacts = Array.isArray(input.writerContract?.artifacts) ? input.writerContract.artifacts : [];
|
|
174
|
+
const writes = artifacts.flatMap((artifact) => (artifact.operations ?? []).map((operation) => `write:${artifact.artifact}.${operation.verb}`));
|
|
175
|
+
return [...reads, ...writes];
|
|
176
|
+
}
|
|
177
|
+
function bootstrapIds(matrix) {
|
|
178
|
+
return [
|
|
179
|
+
...matrix.runtimeIds.map((id) => `runtime:${id}`),
|
|
180
|
+
...matrix.stateIds.map((id) => `state:${id}`),
|
|
181
|
+
...matrix.accepted.map(({ id }) => `accepted:${id}`),
|
|
182
|
+
...matrix.rejections.map(({ id }) => `rejection:${id}`),
|
|
183
|
+
];
|
|
184
|
+
}
|
|
185
|
+
function bootstrapBehaviorIds(matrix) {
|
|
186
|
+
return [
|
|
187
|
+
...matrix.runtimeIds.filter((id) => typeof id === "string").map((id) => `runtime:${id}`),
|
|
188
|
+
...matrix.stateIds.filter((id) => typeof id === "string").map((id) => `state:${id}`),
|
|
189
|
+
...matrix.accepted.filter((entry) => entry.classification === "accepted" && entry.states.length > 0).map(({ id }) => `accepted:${id}`),
|
|
190
|
+
...matrix.rejections.filter((entry) => ["wrong_channel", "not_exact", "malformed"].includes(entry.classification) && entry.states.length > 0).map(({ id }) => `rejection:${id}`),
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
function bootstrapDiagnosticIds(matrix) {
|
|
194
|
+
return [
|
|
195
|
+
...matrix.runtimeIds.filter((id) => /^[a-z]+$/.test(String(id))).map((id) => `runtime:${id}`),
|
|
196
|
+
...matrix.stateIds.filter((id) => /^[a-z0-9]+$/.test(String(id))).map((id) => `state:${id}`),
|
|
197
|
+
...matrix.accepted.filter((entry) => entry.classification === "accepted" && entry.states.every((state) => matrix.stateIds.includes(state))).map(({ id }) => `accepted:${id}`),
|
|
198
|
+
...matrix.rejections.filter((entry) => typeof entry.candidate === "string" && entry.candidate.length > 0 && ["wrong_channel", "not_exact", "malformed"].includes(entry.classification)).map(({ id }) => `rejection:${id}`),
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
function bootstrapInstructionIds(matrix) {
|
|
202
|
+
return [
|
|
203
|
+
...matrix.runtimeIds.filter((id) => ["source", "package"].includes(id)).map((id) => `runtime:${id}`),
|
|
204
|
+
...matrix.stateIds.filter((id) => ["clean", "v2", "partial", "v3"].includes(id)).map((id) => `state:${id}`),
|
|
205
|
+
...matrix.accepted.filter((entry) => entry.states.length > 0 && new Set(entry.states).size === entry.states.length).map(({ id }) => `accepted:${id}`),
|
|
206
|
+
...matrix.rejections.filter((entry) => entry.states.length > 0 && typeof entry.candidate === "string").map(({ id }) => `rejection:${id}`),
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
function bootstrapAdversarialIds(matrix) {
|
|
210
|
+
return [
|
|
211
|
+
...matrix.runtimeIds.filter((id) => !/[;&|\s]/.test(id)).map((id) => `runtime:${id}`),
|
|
212
|
+
...matrix.stateIds.filter((id) => !/[;&|\s]/.test(id)).map((id) => `state:${id}`),
|
|
213
|
+
...matrix.accepted.filter((entry) => entry.classification === "accepted" && !entry.candidate).map(({ id }) => `accepted:${id}`),
|
|
214
|
+
...matrix.rejections.filter((entry) => typeof entry.candidate === "string" && ["wrong_channel", "not_exact", "malformed"].includes(entry.classification)).map(({ id }) => `rejection:${id}`),
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
/** Load injectable inputs from production exports, loaders, and projections. */
|
|
218
|
+
export function loadActivationProductionInputs(root, generationRoot) {
|
|
219
|
+
const packageRoot = packageRootFor(root, generationRoot);
|
|
220
|
+
const capabilityContract = loadCapabilitySchemaContract(path.join(root, "skills/agentera/capability_schema_contract.yaml"));
|
|
221
|
+
const schemaDirectories = () => fs.readdirSync(path.join(root, "skills/agentera/capabilities"), { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
222
|
+
const sourceRegistryCapabilities = () => registryJson(root)?.skills?.[0]?.capabilities ?? [];
|
|
223
|
+
const packagedRegistryCapabilities = () => registryJson(packageRoot)?.skills?.[0]?.capabilities ?? [];
|
|
224
|
+
const runtimeInput = (usePackage = false) => {
|
|
225
|
+
const authorityRoot = usePackage ? packageRoot : root;
|
|
226
|
+
return {
|
|
227
|
+
lifecycle: loadLifecycleAuthority(path.join(authorityRoot, "references/adapters/runtime-lifecycle-authority.yaml")),
|
|
228
|
+
retired: loadNativeResourceCleanupContract(path.join(authorityRoot, "references/adapters/runtime-retired-resources.yaml")),
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
const referenceInput = (usePackage = false) => ({ inventory: retainedInventoryAt(usePackage ? packageRoot : root) });
|
|
232
|
+
const stateInput = () => ({
|
|
233
|
+
readFamilies: structuredClone(ENTITY_LIST_RUNTIME_FAMILIES),
|
|
234
|
+
operations: runtimeOperationSpecs(),
|
|
235
|
+
bounds: structuredClone(ENTITY_LIST_RUNTIME_BOUNDS),
|
|
236
|
+
helpFamilies: entityListFamilies(),
|
|
237
|
+
writerContract: stateWriterContract(),
|
|
238
|
+
});
|
|
239
|
+
const packageInput = (usePackage = false) => {
|
|
240
|
+
const authorityRoot = usePackage ? packageRoot : root;
|
|
241
|
+
const record = loadRegistry(path.join(authorityRoot, "references/adapters/package-registry.yaml"), authorityRoot).get("agentera");
|
|
242
|
+
return { record, constructionPlan: packageDescriptors(record).map(({ id, entry }) => ({ id, path: entry.path })) };
|
|
243
|
+
};
|
|
244
|
+
const bootstrapInput = () => bootstrapMatrixAuthority();
|
|
245
|
+
const bootstrapBehaviorInput = () => ({ ...bootstrapMatrixAuthority(), binderBehavior: bootstrapIds(bootstrapMatrixAuthority()) });
|
|
246
|
+
const bootstrapDiagnosticInput = () => ({ ...bootstrapMatrixAuthority(), diagnostics: BOOTSTRAP_REJECTION_SPECS.map(({ id, classification }) => ({ id, classification })) });
|
|
247
|
+
const bootstrapPackageInput = () => ({ ...bootstrapMatrixAuthority(), extractedClassifications: [...BOOTSTRAP_ACCEPTED_SPECS, ...BOOTSTRAP_REJECTION_SPECS].map(({ id, classification }) => ({ id, classification })) });
|
|
248
|
+
const bootstrapInstructionInput = () => ({ ...bootstrapMatrixAuthority(), startupProducers: BOOTSTRAP_ACCEPTED_SPECS.map(({ id }) => id) });
|
|
249
|
+
const bootstrapAdversarialInput = () => ({ ...bootstrapMatrixAuthority(), invalidCommandResults: BOOTSTRAP_REJECTION_SPECS.map(({ id, classification }) => ({ id, classification })) });
|
|
250
|
+
const sourceCapabilityObservation = loadSourceCapabilityInstructions(root);
|
|
251
|
+
const instructions = structuredClone(sourceCapabilityObservation.modules);
|
|
252
|
+
return plainClone({
|
|
253
|
+
classes: {
|
|
254
|
+
cli: {
|
|
255
|
+
census: { commands: [...DISPATCHER_TOP_LEVEL_COMMANDS] },
|
|
256
|
+
dimensions: {
|
|
257
|
+
discovery: { commands: [...DISPATCHER_TOP_LEVEL_COMMANDS] },
|
|
258
|
+
behavior: { dispatchSource: fs.readFileSync(path.join(root, "packages/cli/src/cli/dispatch/index.ts"), "utf8"), capabilityRoutes: [...CAPABILITY_ROUTING_NAMES] },
|
|
259
|
+
diagnostics: { commands: [...DIAGNOSTIC_TOP_LEVEL_COMMANDS], runtimeDiagnosticCommands: [...DISPATCHER_COMMANDS] },
|
|
260
|
+
package_projection: { commands: [...SCHEMA_TOP_LEVEL_COMMANDS] },
|
|
261
|
+
instructions: { helpText: printTopLevelHelp(), declaredCommands: [...HELP_TOP_LEVEL_COMMANDS] },
|
|
262
|
+
adversarial: { commands: [...DISPATCHER_COMMANDS] },
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
capability: {
|
|
266
|
+
census: { instructions },
|
|
267
|
+
dimensions: {
|
|
268
|
+
discovery: { instructions: structuredClone(sourceCapabilityObservation.modules) },
|
|
269
|
+
behavior: { routes: ["status", ...CAPABILITY_ROUTING_NAMES], servedInstructions: structuredClone(CAPABILITY_INSTRUCTIONS) },
|
|
270
|
+
diagnostics: { schemaDirectories: schemaDirectories(), generatedInstructions: structuredClone(CAPABILITY_INSTRUCTIONS) },
|
|
271
|
+
package_projection: { capabilities: packagedRegistryCapabilities(), packagedInstructions: structuredClone(CAPABILITY_INSTRUCTIONS) },
|
|
272
|
+
instructions: { targets: capabilityTargets(CAPABILITY_INSTRUCTIONS), servedInstructions: structuredClone(CAPABILITY_INSTRUCTIONS) },
|
|
273
|
+
adversarial: { registryCapabilities: sourceRegistryCapabilities(), schemaDirectories: schemaDirectories(), instructionNames: Object.keys(CAPABILITY_INSTRUCTIONS), aliases: capabilityContract.routeAliases.primaryAliases.map(({ capability }) => capability), instructionBodies: structuredClone(CAPABILITY_INSTRUCTIONS), omissionRejected: true, driftRejected: true },
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
runtime: {
|
|
277
|
+
census: runtimeInput(),
|
|
278
|
+
dimensions: {
|
|
279
|
+
discovery: runtimeInput(), behavior: runtimeInput(), diagnostics: runtimeInput(),
|
|
280
|
+
package_projection: runtimeInput(true), instructions: runtimeInput(), adversarial: runtimeInput(),
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
reference: {
|
|
284
|
+
census: referenceInput(),
|
|
285
|
+
dimensions: {
|
|
286
|
+
discovery: referenceInput(), behavior: referenceInput(),
|
|
287
|
+
diagnostics: referenceInput(),
|
|
288
|
+
package_projection: referenceInput(true), instructions: referenceInput(), adversarial: referenceInput(),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
state: {
|
|
292
|
+
census: stateInput(),
|
|
293
|
+
dimensions: {
|
|
294
|
+
discovery: stateInput(), behavior: stateInput(), diagnostics: stateInput(),
|
|
295
|
+
package_projection: stateInput(), instructions: stateInput(), adversarial: stateInput(),
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
package: {
|
|
299
|
+
census: packageInput(),
|
|
300
|
+
dimensions: {
|
|
301
|
+
discovery: packageInput(), behavior: packageInput(), diagnostics: packageInput(),
|
|
302
|
+
package_projection: packageInput(true), instructions: packageInput(), adversarial: packageInput(),
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
bootstrap: {
|
|
306
|
+
census: bootstrapInput(),
|
|
307
|
+
dimensions: {
|
|
308
|
+
discovery: bootstrapInput(), behavior: bootstrapBehaviorInput(), diagnostics: bootstrapDiagnosticInput(),
|
|
309
|
+
package_projection: bootstrapPackageInput(), instructions: bootstrapInstructionInput(), adversarial: bootstrapAdversarialInput(),
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/** Collect facts from injectable production inputs without deriving expectations from them. */
|
|
316
|
+
export function collectActivationProductionEvidence(root, productionInputs = loadActivationProductionInputs(root)) {
|
|
317
|
+
const inputs = productionInputs.classes;
|
|
318
|
+
const classes = {};
|
|
319
|
+
const cliIds = inputs.cli.census.commands;
|
|
320
|
+
classes.cli = {
|
|
321
|
+
surfaces: surfacesWithClassOwner(cliIds, "cli"),
|
|
322
|
+
dimensions: {
|
|
323
|
+
discovery: evidence("cli", "discovery", inputs.cli.dimensions.discovery.commands),
|
|
324
|
+
behavior: evidence("cli", "behavior", [...parseDispatchCases(inputs.cli.dimensions.behavior.dispatchSource), ...inputs.cli.dimensions.behavior.capabilityRoutes]),
|
|
325
|
+
diagnostics: evidence("cli", "diagnostics", inputs.cli.dimensions.diagnostics.commands.filter((id) => inputs.cli.dimensions.diagnostics.runtimeDiagnosticCommands.includes(id))),
|
|
326
|
+
package_projection: evidence("cli", "package_projection", inputs.cli.dimensions.package_projection.commands),
|
|
327
|
+
instructions: evidence("cli", "instructions", helpCommandIds(inputs.cli.dimensions.instructions.helpText).filter((id) => inputs.cli.dimensions.instructions.declaredCommands.includes(id))),
|
|
328
|
+
adversarial: evidence("cli", "adversarial", inputs.cli.dimensions.adversarial.commands.filter((id) => !/\s|[;&|]/.test(id))),
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
const capabilityIds = Object.keys(inputs.capability.census.instructions);
|
|
332
|
+
const sourceInstructionBodies = inputs.capability.census.instructions;
|
|
333
|
+
classes.capability = {
|
|
334
|
+
surfaces: capabilityIds.map((id) => ({
|
|
335
|
+
id,
|
|
336
|
+
owner: { path: capabilityInstructionModulePath(id), symbol: "instructions" },
|
|
337
|
+
correction: classAuthority("capability").correction,
|
|
338
|
+
})),
|
|
339
|
+
dimensions: {
|
|
340
|
+
discovery: evidence("capability", "discovery", Object.keys(inputs.capability.dimensions.discovery.instructions), nonEmptyInstructionBodies(sourceInstructionBodies) && exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.discovery.instructions)),
|
|
341
|
+
behavior: evidence("capability", "behavior", inputs.capability.dimensions.behavior.routes, exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.behavior.servedInstructions)),
|
|
342
|
+
diagnostics: evidence("capability", "diagnostics", inputs.capability.dimensions.diagnostics.schemaDirectories, exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.diagnostics.generatedInstructions)),
|
|
343
|
+
package_projection: evidence("capability", "package_projection", inputs.capability.dimensions.package_projection.capabilities, exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.package_projection.packagedInstructions)),
|
|
344
|
+
instructions: evidence("capability", "instructions", inputs.capability.dimensions.instructions.targets.filter((target) => target.present && target.length > 0 && /^[0-9a-f]{64}$/.test(target.sha256) && target.module === capabilityInstructionModulePath(target.id)).map(({ id }) => id), exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.instructions.servedInstructions)),
|
|
345
|
+
adversarial: evidence("capability", "adversarial", [...new Set([
|
|
346
|
+
...inputs.capability.dimensions.adversarial.registryCapabilities,
|
|
347
|
+
...inputs.capability.dimensions.adversarial.schemaDirectories,
|
|
348
|
+
...inputs.capability.dimensions.adversarial.instructionNames,
|
|
349
|
+
...inputs.capability.dimensions.adversarial.aliases,
|
|
350
|
+
])].filter((id) => [
|
|
351
|
+
inputs.capability.dimensions.adversarial.registryCapabilities,
|
|
352
|
+
inputs.capability.dimensions.adversarial.schemaDirectories,
|
|
353
|
+
inputs.capability.dimensions.adversarial.instructionNames,
|
|
354
|
+
inputs.capability.dimensions.adversarial.aliases,
|
|
355
|
+
].every((values) => values.includes(id))), exactInstructionBodies(sourceInstructionBodies, inputs.capability.dimensions.adversarial.instructionBodies)
|
|
356
|
+
&& inputs.capability.dimensions.adversarial.omissionRejected === true
|
|
357
|
+
&& inputs.capability.dimensions.adversarial.driftRejected === true),
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
const runtimeCensusIds = runtimeIdsFromLoaded(inputs.runtime.census.lifecycle, inputs.runtime.census.retired);
|
|
361
|
+
const runtimeSurfaces = runtimeCensusIds.map((id) => ({
|
|
362
|
+
id,
|
|
363
|
+
owner: id.startsWith("retired:") || id.startsWith("host:")
|
|
364
|
+
? { path: "packages/cli/src/runtime/nativeResourceCleanup.ts", symbol: "loadNativeResourceCleanupContract", selector: id }
|
|
365
|
+
: { path: "packages/cli/src/runtime/lifecycleAuthority.ts", symbol: "loadLifecycleAuthority", selector: id },
|
|
366
|
+
correction: classAuthority("runtime").correction,
|
|
367
|
+
}));
|
|
368
|
+
classes.runtime = {
|
|
369
|
+
surfaces: runtimeSurfaces,
|
|
370
|
+
dimensions: {
|
|
371
|
+
discovery: evidence("runtime", "discovery", runtimeIdsFromLoaded(inputs.runtime.dimensions.discovery.lifecycle, inputs.runtime.dimensions.discovery.retired)),
|
|
372
|
+
behavior: evidence("runtime", "behavior", runtimeBehaviorIds(inputs.runtime.dimensions.behavior.lifecycle, inputs.runtime.dimensions.behavior.retired)),
|
|
373
|
+
diagnostics: evidence("runtime", "diagnostics", runtimeDiagnosticIds(inputs.runtime.dimensions.diagnostics.lifecycle, inputs.runtime.dimensions.diagnostics.retired)),
|
|
374
|
+
package_projection: evidence("runtime", "package_projection", runtimeIdsFromLoaded(inputs.runtime.dimensions.package_projection.lifecycle, inputs.runtime.dimensions.package_projection.retired)),
|
|
375
|
+
instructions: evidence("runtime", "instructions", runtimeInstructionIds(inputs.runtime.dimensions.instructions.lifecycle, inputs.runtime.dimensions.instructions.retired)),
|
|
376
|
+
adversarial: evidence("runtime", "adversarial", runtimeAdversarialIds(inputs.runtime.dimensions.adversarial.lifecycle, inputs.runtime.dimensions.adversarial.retired)),
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
const referenceCensus = inputs.reference.census.inventory;
|
|
380
|
+
const referenceSurfaces = referenceCensus.map((entry) => ({
|
|
381
|
+
id: entry.path,
|
|
382
|
+
owner: entry.production_owner
|
|
383
|
+
? { path: entry.production_owner.module, symbol: entry.production_owner.symbol, selector: entry.path }
|
|
384
|
+
: { path: "references/meta/retained-reference-authority.yaml", symbol: "inventory", selector: entry.path },
|
|
385
|
+
correction: classAuthority("reference").correction,
|
|
386
|
+
}));
|
|
387
|
+
classes.reference = {
|
|
388
|
+
surfaces: referenceSurfaces,
|
|
389
|
+
dimensions: {
|
|
390
|
+
discovery: evidence("reference", "discovery", referenceIds(inputs.reference.dimensions.discovery.inventory)),
|
|
391
|
+
behavior: evidence("reference", "behavior", referenceBehaviorIds(inputs.reference.dimensions.behavior.inventory)),
|
|
392
|
+
diagnostics: evidence("reference", "diagnostics", referenceDiagnosticIds(inputs.reference.dimensions.diagnostics.inventory)),
|
|
393
|
+
package_projection: evidence("reference", "package_projection", referenceIds(inputs.reference.dimensions.package_projection.inventory)),
|
|
394
|
+
instructions: evidence("reference", "instructions", referenceInstructionIds(inputs.reference.dimensions.instructions.inventory)),
|
|
395
|
+
adversarial: evidence("reference", "adversarial", referenceAdversarialIds(inputs.reference.dimensions.adversarial.inventory)),
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
const stateCensus = inputs.state.census;
|
|
399
|
+
const readSurfaces = stateCensus.readFamilies.map((family) => ({
|
|
400
|
+
id: `read:${family.key}`,
|
|
401
|
+
owner: { path: "packages/cli/src/state/entityListRuntimeRegistry.ts", symbol: "ENTITY_LIST_RUNTIME_REGISTRY", selector: family.key },
|
|
402
|
+
correction: classAuthority("state").correction,
|
|
403
|
+
}));
|
|
404
|
+
const writeSurfaces = stateCensus.operations.map((operation) => ({
|
|
405
|
+
id: `write:${operation.artifact}.${operation.verb}`,
|
|
406
|
+
owner: { path: "packages/cli/src/state/write/runtimeOperations.ts", symbol: "runtimeOperationSpecs", selector: `${operation.artifact}.${operation.verb}` },
|
|
407
|
+
correction: classAuthority("state").correction,
|
|
408
|
+
}));
|
|
409
|
+
const stateDiagnosticInput = inputs.state.dimensions.diagnostics;
|
|
410
|
+
const stateInstructionInput = inputs.state.dimensions.instructions;
|
|
411
|
+
const stateAdversarialInput = inputs.state.dimensions.adversarial;
|
|
412
|
+
classes.state = {
|
|
413
|
+
surfaces: [...readSurfaces, ...writeSurfaces],
|
|
414
|
+
dimensions: {
|
|
415
|
+
discovery: evidence("state", "discovery", stateIds(inputs.state.dimensions.discovery)),
|
|
416
|
+
behavior: evidence("state", "behavior", stateIds(inputs.state.dimensions.behavior).filter((id) => id.startsWith("read:")
|
|
417
|
+
? inputs.state.dimensions.behavior.readFamilies.find((family) => `read:${family.key}` === id)?.commandTokens.length > 0
|
|
418
|
+
: inputs.state.dimensions.behavior.operations.find((operation) => `write:${operation.artifact}.${operation.verb}` === id)?.inputMode !== undefined)),
|
|
419
|
+
diagnostics: evidence("state", "diagnostics", [
|
|
420
|
+
...stateDiagnosticInput.readFamilies.filter((family) => family.boundary && stateDiagnosticInput.bounds.maxUtf8Bytes > 0).map((family) => `read:${family.key}`),
|
|
421
|
+
...stateDiagnosticInput.operations.filter((operation) => operation.projection.recovery.runtime.length > 0).map((operation) => `write:${operation.artifact}.${operation.verb}`),
|
|
422
|
+
]),
|
|
423
|
+
package_projection: evidence("state", "package_projection", stateProjectionIds(inputs.state.dimensions.package_projection)),
|
|
424
|
+
instructions: evidence("state", "instructions", [
|
|
425
|
+
...stateInstructionInput.helpFamilies.filter((family) => family.syntax && family.example).map((family) => `read:${family.key}`),
|
|
426
|
+
...stateInstructionInput.operations.filter((operation) => operation.projection.examples.length > 0).map((operation) => `write:${operation.artifact}.${operation.verb}`),
|
|
427
|
+
]),
|
|
428
|
+
adversarial: evidence("state", "adversarial", [
|
|
429
|
+
...stateAdversarialInput.readFamilies.filter((family) => stateAdversarialInput.bounds.minimum > 0 && stateAdversarialInput.bounds.maximum >= stateAdversarialInput.bounds.default).map((family) => `read:${family.key}`),
|
|
430
|
+
...stateAdversarialInput.operations.filter((operation) => operation.inputMaxBytes >= 0 && operation.projection.formatValues.length === 2).map((operation) => `write:${operation.artifact}.${operation.verb}`),
|
|
431
|
+
]),
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
const packageCensusDescriptors = packageDescriptors(inputs.package.census.record);
|
|
435
|
+
const packageSurfaces = packageCensusDescriptors.map((descriptor) => ({
|
|
436
|
+
id: descriptor.id,
|
|
437
|
+
owner: { path: "packages/cli/src/registries/packageRegistry.ts", symbol: "loadRegistry", selector: descriptor.entry.selector ?? descriptor.entry.path },
|
|
438
|
+
semanticSelector: packageSemanticSelector(descriptor.entry),
|
|
439
|
+
correction: classAuthority("package").correction,
|
|
440
|
+
}));
|
|
441
|
+
const packageDimensionDescriptors = (dimension) => packageDescriptors(inputs.package.dimensions[dimension].record);
|
|
442
|
+
const packageCensusSemantics = packageDescriptorSemantics(packageCensusDescriptors);
|
|
443
|
+
const exactPackageSemantics = (dimension) => JSON.stringify(packageDescriptorSemantics(packageDimensionDescriptors(dimension))) === JSON.stringify(packageCensusSemantics);
|
|
444
|
+
classes.package = {
|
|
445
|
+
surfaces: packageSurfaces,
|
|
446
|
+
dimensions: {
|
|
447
|
+
discovery: evidence("package", "discovery", packageDimensionDescriptors("discovery").map(({ id }) => id), exactPackageSemantics("discovery")),
|
|
448
|
+
behavior: evidence("package", "behavior", packageDimensionDescriptors("behavior").filter(({ entry }) => typeof entry.path === "string" && entry.path.length > 0).map(({ id }) => id), exactPackageSemantics("behavior") && JSON.stringify(inputs.package.dimensions.behavior.constructionPlan) === JSON.stringify(inputs.package.census.constructionPlan)),
|
|
449
|
+
diagnostics: evidence("package", "diagnostics", packageDimensionDescriptors("diagnostics").filter(({ id, entry }) => !id.startsWith("generated:") || (entry.classification === "active" && entry.command_authority_reason?.length > 0)).map(({ id }) => id), exactPackageSemantics("diagnostics")),
|
|
450
|
+
package_projection: evidence("package", "package_projection", packageDimensionDescriptors("package_projection").map(({ id }) => id), exactPackageSemantics("package_projection")),
|
|
451
|
+
instructions: evidence("package", "instructions", packageDimensionDescriptors("instructions").filter(({ entry }) => typeof entry.path === "string" && (typeof entry.selector === "string" || !String(entry.id ?? "").startsWith("version:"))).map(({ id }) => id), exactPackageSemantics("instructions")),
|
|
452
|
+
adversarial: evidence("package", "adversarial", packageDimensionDescriptors("adversarial").filter(({ entry }) => typeof entry.path === "string" && !/[\0\r\n]/.test(entry.selector ?? entry.path)).map(({ id }) => id), exactPackageSemantics("adversarial")),
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
const bootstrapCensusIds = bootstrapIds(inputs.bootstrap.census);
|
|
456
|
+
const bootstrapSurfaces = surfacesWithClassOwner(bootstrapCensusIds, "bootstrap").map((surface) => ({ ...surface, owner: { ...surface.owner, selector: surface.id } }));
|
|
457
|
+
classes.bootstrap = {
|
|
458
|
+
surfaces: bootstrapSurfaces,
|
|
459
|
+
dimensions: {
|
|
460
|
+
discovery: evidence("bootstrap", "discovery", bootstrapIds(inputs.bootstrap.dimensions.discovery)),
|
|
461
|
+
behavior: evidence("bootstrap", "behavior", bootstrapBehaviorIds(inputs.bootstrap.dimensions.behavior), exactSet(inputs.bootstrap.dimensions.behavior.binderBehavior, bootstrapCensusIds)),
|
|
462
|
+
diagnostics: evidence("bootstrap", "diagnostics", bootstrapDiagnosticIds(inputs.bootstrap.dimensions.diagnostics), JSON.stringify(inputs.bootstrap.dimensions.diagnostics.diagnostics) === JSON.stringify(BOOTSTRAP_REJECTION_SPECS.map(({ id, classification }) => ({ id, classification })))),
|
|
463
|
+
package_projection: evidence("bootstrap", "package_projection", bootstrapIds(inputs.bootstrap.dimensions.package_projection), JSON.stringify(inputs.bootstrap.dimensions.package_projection.extractedClassifications) === JSON.stringify([...BOOTSTRAP_ACCEPTED_SPECS, ...BOOTSTRAP_REJECTION_SPECS].map(({ id, classification }) => ({ id, classification })))),
|
|
464
|
+
instructions: evidence("bootstrap", "instructions", bootstrapInstructionIds(inputs.bootstrap.dimensions.instructions), exactSet(inputs.bootstrap.dimensions.instructions.startupProducers, BOOTSTRAP_ACCEPTED_SPECS.map(({ id }) => id))),
|
|
465
|
+
adversarial: evidence("bootstrap", "adversarial", bootstrapAdversarialIds(inputs.bootstrap.dimensions.adversarial), JSON.stringify(inputs.bootstrap.dimensions.adversarial.invalidCommandResults) === JSON.stringify(BOOTSTRAP_REJECTION_SPECS.map(({ id, classification }) => ({ id, classification })))),
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
return structuredClone({ classes });
|
|
469
|
+
}
|
|
470
|
+
export function activationCensus(evidenceInput) {
|
|
471
|
+
const classes = Object.fromEntries(ACTIVATION_CLASSES.map((classId) => {
|
|
472
|
+
const ids = evidenceInput.classes[classId]?.surfaces.map(({ id }) => id) ?? [];
|
|
473
|
+
return [classId, { count: ids.length, sha256: digestIdentities(ids) }];
|
|
474
|
+
}));
|
|
475
|
+
const totalIds = ACTIVATION_CLASSES.flatMap((classId) => (evidenceInput.classes[classId]?.surfaces ?? []).map(({ id }) => `${classId}:${id}`));
|
|
476
|
+
return { classes, total: { count: totalIds.length, sha256: digestIdentities(totalIds) } };
|
|
477
|
+
}
|
|
478
|
+
export function deriveActivationSurfaces(evidenceInput) {
|
|
479
|
+
return ACTIVATION_CLASSES.flatMap((classId) => {
|
|
480
|
+
const classEvidence = evidenceInput.classes[classId];
|
|
481
|
+
if (!classEvidence)
|
|
482
|
+
return [];
|
|
483
|
+
return classEvidence.surfaces.map((surface) => ({
|
|
484
|
+
classId,
|
|
485
|
+
surfaceId: surface.id,
|
|
486
|
+
owner: structuredClone(surface.owner),
|
|
487
|
+
dimensions: ACTIVATION_DIMENSIONS.map((dimension) => {
|
|
488
|
+
const record = classEvidence.dimensions[dimension];
|
|
489
|
+
return {
|
|
490
|
+
dimension,
|
|
491
|
+
status: record?.valid === true && record.identities.includes(surface.id) ? "pass" : "fail",
|
|
492
|
+
checkId: `${classId}.${dimension}`,
|
|
493
|
+
evidenceRef: record?.sourceId ?? "missing",
|
|
494
|
+
};
|
|
495
|
+
}),
|
|
496
|
+
correction: surface.correction,
|
|
497
|
+
}));
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
function productionTuples(evidenceInput) {
|
|
501
|
+
return ACTIVATION_CLASSES.flatMap((classId) => (evidenceInput.classes[classId]?.surfaces ?? []).map((surface) => ({
|
|
502
|
+
class: classId,
|
|
503
|
+
surface_id: surface.id,
|
|
504
|
+
owner_path: surface.owner.path,
|
|
505
|
+
owner_symbol_or_selector: surface.owner.symbol,
|
|
506
|
+
owner_selector: surface.owner.selector ?? null,
|
|
507
|
+
semantic_selector_if_any: surface.semanticSelector ?? null,
|
|
508
|
+
canonical_correction: surface.correction,
|
|
509
|
+
})));
|
|
510
|
+
}
|
|
511
|
+
function canonicalRows(evidenceInput) {
|
|
512
|
+
return ACTIVATION_CANONICAL_TUPLES.map((tuple) => ({
|
|
513
|
+
classId: tuple.class,
|
|
514
|
+
surfaceId: tuple.surface_id,
|
|
515
|
+
owner: {
|
|
516
|
+
path: tuple.owner_path,
|
|
517
|
+
symbol: tuple.owner_symbol_or_selector,
|
|
518
|
+
...(tuple.owner_selector === null ? {} : { selector: tuple.owner_selector }),
|
|
519
|
+
},
|
|
520
|
+
correction: tuple.canonical_correction,
|
|
521
|
+
dimensions: ACTIVATION_DIMENSIONS.map((dimension) => {
|
|
522
|
+
const record = evidenceInput.classes[tuple.class]?.dimensions[dimension];
|
|
523
|
+
return {
|
|
524
|
+
dimension,
|
|
525
|
+
status: record?.valid === true && record.identities.includes(tuple.surface_id) ? "pass" : "fail",
|
|
526
|
+
checkId: `${tuple.class}.${dimension}`,
|
|
527
|
+
evidenceRef: record?.sourceId ?? "missing",
|
|
528
|
+
};
|
|
529
|
+
}),
|
|
530
|
+
}));
|
|
531
|
+
}
|
|
532
|
+
export function discoverActivationSurfaces(root) {
|
|
533
|
+
return deriveActivationSurfaces(collectActivationProductionEvidence(root));
|
|
534
|
+
}
|
|
535
|
+
function generationViolation(root, id, generationRoot, contract) {
|
|
536
|
+
if (id.length > contract.bounds.maxGenerationIdCharacters || !GENERATION_ID.test(id))
|
|
537
|
+
return "generation identity violates the exact UUID grammar or bound";
|
|
538
|
+
const expected = path.resolve(root, "packages/cli/.agentera-generated/generations", id);
|
|
539
|
+
const actual = generationRoot ? path.resolve(generationRoot) : expected;
|
|
540
|
+
if (actual !== expected)
|
|
541
|
+
return "generation path does not match the selected current-source generation";
|
|
542
|
+
for (const relative of [".agentera-generation.json", "dist/.agentera-generation.json", "bundle/.agentera-generation.json"]) {
|
|
543
|
+
try {
|
|
544
|
+
if (JSON.parse(fs.readFileSync(path.join(actual, relative), "utf8")).id !== id)
|
|
545
|
+
return "generation identity does not match across package surfaces";
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
return "generation identity is missing from a required package surface";
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
function boundedIdentity(surface, contract) {
|
|
554
|
+
const { bounds } = contract;
|
|
555
|
+
if (surface.surfaceId.length > bounds.maxSurfaceIdCharacters || !/^[A-Za-z0-9][A-Za-z0-9._:/\[\]=@-]*$/.test(surface.surfaceId))
|
|
556
|
+
return "surface ID violates grammar or bound";
|
|
557
|
+
if (surface.owner.path.length > bounds.maxPathCharacters || !OWNER_PATH.test(surface.owner.path))
|
|
558
|
+
return "owner path violates grammar or bound";
|
|
559
|
+
if (surface.owner.symbol.length > bounds.maxSymbolCharacters || !SYMBOL.test(surface.owner.symbol))
|
|
560
|
+
return "owner symbol violates grammar or bound";
|
|
561
|
+
if (surface.owner.selector !== undefined && (surface.owner.selector.length === 0 || surface.owner.selector.length > bounds.maxSelectorCharacters || /[\0\r\n]/.test(surface.owner.selector)))
|
|
562
|
+
return "owner selector violates grammar or bound";
|
|
563
|
+
if (!surface.correction || surface.correction.length > bounds.maxCorrectionCharacters || !/^(?:pnpm|node) [^\0\r\n]+$/.test(surface.correction))
|
|
564
|
+
return "correction violates runnable grammar or bound";
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
function validateActivationConjunctionUnchecked(inputs = {}) {
|
|
568
|
+
const root = inputs.root ?? resolveSourceRoot();
|
|
569
|
+
if (isNpxBundleRoot(root))
|
|
570
|
+
return fixedFailure("source checkout required");
|
|
571
|
+
const contract = inputs.contract ?? loadPackagePublicationModel(root).activationConjunction;
|
|
572
|
+
const generation = inputs.expectedGeneration ?? process.env.AGENTERA_ACTIVATION_GENERATION_ID;
|
|
573
|
+
const generationRoot = inputs.generationRoot ?? process.env.AGENTERA_ACTIVATION_GENERATION_ROOT;
|
|
574
|
+
const expectedEvidenceDigest = inputs.expectedEvidenceDigest ?? process.env.AGENTERA_ACTIVATION_EVIDENCE_DIGEST;
|
|
575
|
+
const expectedPackageIdentity = inputs.expectedPackageIdentity ?? (() => {
|
|
576
|
+
const serialized = process.env.AGENTERA_ACTIVATION_PACKAGE_IDENTITY;
|
|
577
|
+
if (serialized === undefined)
|
|
578
|
+
return null;
|
|
579
|
+
try {
|
|
580
|
+
return JSON.parse(serialized);
|
|
581
|
+
}
|
|
582
|
+
catch {
|
|
583
|
+
return serialized;
|
|
584
|
+
}
|
|
585
|
+
})();
|
|
586
|
+
const productionInputs = inputs.productionInputs ?? loadActivationProductionInputs(root, generationRoot);
|
|
587
|
+
const productionEvidence = collectActivationProductionEvidence(root, productionInputs);
|
|
588
|
+
const actualTuples = productionTuples(productionEvidence);
|
|
589
|
+
const expected = canonicalRows(productionEvidence);
|
|
590
|
+
const observed = inputs.surfaces ?? deriveActivationSurfaces(productionEvidence);
|
|
591
|
+
const census = activationCensus(productionEvidence);
|
|
592
|
+
const violations = [];
|
|
593
|
+
const fallback = classAuthority("package");
|
|
594
|
+
const add = (owner, violation, correction = fallback.correction) => {
|
|
595
|
+
if (violations.length >= contract.bounds.maxViolations)
|
|
596
|
+
return;
|
|
597
|
+
const safeViolation = violation.length <= contract.bounds.maxDiagnosticCharacters && !/[\0\r\n]/.test(violation) ? violation : "diagnostic violates the governed bound";
|
|
598
|
+
violations.push({ owner, violation: safeViolation, correction });
|
|
599
|
+
};
|
|
600
|
+
const canonicalByIdentity = new Map(ACTIVATION_CANONICAL_TUPLES.map((tuple) => [`${tuple.class}:${tuple.surface_id}`, tuple]));
|
|
601
|
+
const actualByIdentity = new Map();
|
|
602
|
+
for (const tuple of actualTuples) {
|
|
603
|
+
const key = `${tuple.class}:${tuple.surface_id}`;
|
|
604
|
+
actualByIdentity.set(key, [...(actualByIdentity.get(key) ?? []), tuple]);
|
|
605
|
+
}
|
|
606
|
+
for (const canonical of ACTIVATION_CANONICAL_TUPLES) {
|
|
607
|
+
const key = `${canonical.class}:${canonical.surface_id}`;
|
|
608
|
+
const matches = actualByIdentity.get(key) ?? [];
|
|
609
|
+
if (matches.length !== 1) {
|
|
610
|
+
add(tupleOwnerText(canonical), `${key} canonical tuple is ${matches.length === 0 ? "missing" : "duplicated"}; canonical tuple ${tupleDiagnostic(canonical)}`, canonical.canonical_correction);
|
|
611
|
+
}
|
|
612
|
+
else if (canonicalTupleJson(matches[0]) !== canonicalTupleJson(canonical)) {
|
|
613
|
+
add(tupleOwnerText(canonical), `${key} production tuple drifted; canonical tuple ${tupleDiagnostic(canonical)}`, canonical.canonical_correction);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
for (const actual of actualTuples) {
|
|
617
|
+
if (!canonicalByIdentity.has(`${actual.class}:${actual.surface_id}`)) {
|
|
618
|
+
const sameId = ACTIVATION_CANONICAL_TUPLES.find((tuple) => tuple.surface_id === actual.surface_id);
|
|
619
|
+
const canonical = sameId ?? ACTIVATION_CANONICAL_TUPLES.find((tuple) => tuple.class === actual.class) ?? ACTIVATION_CANONICAL_TUPLES[0];
|
|
620
|
+
add(tupleOwnerText(canonical), `${actual.class}:${actual.surface_id} is extra or class-reassigned; canonical tuple ${tupleDiagnostic(canonical)}`, canonical.canonical_correction);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
for (const classId of ACTIVATION_CLASSES) {
|
|
624
|
+
const tuples = actualTuples.filter((tuple) => tuple.class === classId);
|
|
625
|
+
const authority = ACTIVATION_TUPLE_AUTHORITY.classes[classId];
|
|
626
|
+
if (tuples.length !== authority.count || digestCanonicalTuples(tuples) !== authority.sha256) {
|
|
627
|
+
const canonical = ACTIVATION_CANONICAL_TUPLES.find((tuple) => tuple.class === classId);
|
|
628
|
+
add(tupleOwnerText(canonical), `${classId} tuple digest mismatch: expected ${authority.count}/${authority.sha256}, observed ${tuples.length}/${digestCanonicalTuples(tuples)}; canonical tuple ${tupleDiagnostic(canonical)}`, canonical.canonical_correction);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (actualTuples.length !== ACTIVATION_TUPLE_AUTHORITY.total.count || digestCanonicalTuples(actualTuples) !== ACTIVATION_TUPLE_AUTHORITY.total.sha256) {
|
|
632
|
+
const canonical = ACTIVATION_CANONICAL_TUPLES.find((tuple) => tuple.class === "package");
|
|
633
|
+
add(tupleOwnerText(canonical), `total tuple digest mismatch: expected ${ACTIVATION_TUPLE_AUTHORITY.total.count}/${ACTIVATION_TUPLE_AUTHORITY.total.sha256}, observed ${actualTuples.length}/${digestCanonicalTuples(actualTuples)}; canonical tuple ${tupleDiagnostic(canonical)}`, canonical.canonical_correction);
|
|
634
|
+
}
|
|
635
|
+
if (!exactSet(contract.classes, ACTIVATION_CLASSES))
|
|
636
|
+
add(classOwnerText("package"), "class set differs from code-owned activation authority");
|
|
637
|
+
if (!exactSet(contract.dimensions, ACTIVATION_DIMENSIONS))
|
|
638
|
+
add(classOwnerText("package"), "dimension set differs from code-owned activation authority");
|
|
639
|
+
if (!exactSet(contract.checkIds, ACTIVATION_CHECK_IDS))
|
|
640
|
+
add(classOwnerText("package"), "check ID set differs from code-owned activation authority");
|
|
641
|
+
for (const classId of ACTIVATION_CLASSES) {
|
|
642
|
+
const canonical = classAuthority(classId);
|
|
643
|
+
const declared = contract.owners[classId];
|
|
644
|
+
if (!declared || declared.path !== canonical.path || declared.symbol !== canonical.symbol || declared.selector !== canonical.selector || declared.correction !== canonical.correction) {
|
|
645
|
+
add(classOwnerText(classId), "class owner or correction differs from code-owned activation authority", canonical.correction);
|
|
646
|
+
}
|
|
647
|
+
const actualCensus = census.classes[classId];
|
|
648
|
+
const expectedCensus = ACTIVATION_CENSUS_AUTHORITY.classes[classId];
|
|
649
|
+
if (actualCensus.count !== expectedCensus.count || actualCensus.sha256 !== expectedCensus.sha256) {
|
|
650
|
+
add(classOwnerText(classId), `census closure failed: expected ${expectedCensus.count}/${expectedCensus.sha256}, observed ${actualCensus.count}/${actualCensus.sha256}`, canonical.correction);
|
|
651
|
+
}
|
|
652
|
+
const classEvidence = productionEvidence.classes[classId];
|
|
653
|
+
for (const dimension of ACTIVATION_DIMENSIONS) {
|
|
654
|
+
const record = classEvidence?.dimensions[dimension];
|
|
655
|
+
const expectedSource = ACTIVATION_EVIDENCE_SOURCES[classId][dimension];
|
|
656
|
+
if (!record || record.sourceId !== expectedSource) {
|
|
657
|
+
add(classOwnerText(classId), `${dimension} evidence source is missing or unrecognized`, canonical.correction);
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (!record.valid || record.identities.length !== expectedCensus.count || digestIdentities(record.identities) !== expectedCensus.sha256 || new Set(record.identities).size !== record.identities.length) {
|
|
661
|
+
add(classOwnerText(classId), `${dimension} evidence failed exact identity closure`, canonical.correction);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (census.total.count !== ACTIVATION_CENSUS_AUTHORITY.total.count || census.total.sha256 !== ACTIVATION_CENSUS_AUTHORITY.total.sha256) {
|
|
666
|
+
add(classOwnerText("package"), `total census closure failed: expected ${ACTIVATION_CENSUS_AUTHORITY.total.count}/${ACTIVATION_CENSUS_AUTHORITY.total.sha256}, observed ${census.total.count}/${census.total.sha256}`);
|
|
667
|
+
}
|
|
668
|
+
if (observed.length > contract.bounds.maxRows)
|
|
669
|
+
add(classOwnerText("package"), "surface row count exceeds its bound");
|
|
670
|
+
const expectedById = new Map(expected.map((row) => [`${row.classId}:${row.surfaceId}`, row]));
|
|
671
|
+
const observedIds = observed.map((row) => `${row.classId}:${row.surfaceId}`);
|
|
672
|
+
if (!exactSet([...expectedById.keys()], observedIds))
|
|
673
|
+
add(classOwnerText("package"), "retained surface set is missing, duplicate, reassigned, or unknown");
|
|
674
|
+
for (const surface of observed.slice(0, contract.bounds.maxRows)) {
|
|
675
|
+
const expectedSurface = expectedById.get(`${surface.classId}:${surface.surfaceId}`);
|
|
676
|
+
const classId = ACTIVATION_CLASSES.includes(surface.classId) ? surface.classId : undefined;
|
|
677
|
+
if (!classId) {
|
|
678
|
+
add(classOwnerText("package"), "surface has an unknown class");
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
const canonical = classAuthority(classId);
|
|
682
|
+
const identityFailure = boundedIdentity(surface, contract);
|
|
683
|
+
if (identityFailure) {
|
|
684
|
+
add(classOwnerText(classId), identityFailure, canonical.correction);
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const canonicalTuple = canonicalByIdentity.get(`${surface.classId}:${surface.surfaceId}`);
|
|
688
|
+
if (!expectedSurface || ownerText(surface.owner) !== ownerText(expectedSurface.owner) || surface.owner.symbol !== expectedSurface.owner.symbol) {
|
|
689
|
+
add(canonicalTuple ? tupleOwnerText(canonicalTuple) : classOwnerText(classId), `owner does not match the canonical tuple${canonicalTuple ? ` ${tupleDiagnostic(canonicalTuple)}` : ""}`, canonicalTuple?.canonical_correction ?? canonical.correction);
|
|
690
|
+
}
|
|
691
|
+
if (!expectedSurface || surface.correction !== expectedSurface.correction) {
|
|
692
|
+
add(canonicalTuple ? tupleOwnerText(canonicalTuple) : classOwnerText(classId), `correction does not match the canonical tuple${canonicalTuple ? ` ${tupleDiagnostic(canonicalTuple)}` : ""}`, canonicalTuple?.canonical_correction ?? canonical.correction);
|
|
693
|
+
}
|
|
694
|
+
if (!exactSet(surface.dimensions.map(({ dimension }) => dimension), ACTIVATION_DIMENSIONS))
|
|
695
|
+
add(classOwnerText(classId), "dimensions are missing, duplicate, or unknown", canonical.correction);
|
|
696
|
+
for (const dimension of surface.dimensions) {
|
|
697
|
+
const dimensionId = ACTIVATION_DIMENSIONS.includes(dimension.dimension) ? dimension.dimension : undefined;
|
|
698
|
+
const expectedSource = dimensionId ? ACTIVATION_EVIDENCE_SOURCES[classId][dimensionId] : undefined;
|
|
699
|
+
if (dimension.checkId.length > contract.bounds.maxCheckIdCharacters || dimension.checkId !== `${surface.classId}.${dimension.dimension}` || !ACTIVATION_CHECK_IDS.includes(dimension.checkId))
|
|
700
|
+
add(classOwnerText(classId), "check ID is not recognized for this class and dimension", canonical.correction);
|
|
701
|
+
if (!expectedSource || dimension.evidenceRef !== expectedSource)
|
|
702
|
+
add(classOwnerText(classId), "evidence reference is not recognized for this class and dimension", canonical.correction);
|
|
703
|
+
if (dimension.status !== "pass")
|
|
704
|
+
add(classOwnerText(classId), `${dimension.dimension} evidence failed`, canonical.correction);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if (generation) {
|
|
708
|
+
const stale = generationViolation(root, generation, generationRoot, contract);
|
|
709
|
+
if (stale)
|
|
710
|
+
add("packages/cli/scripts/release-qualification.mjs#runSourceQualificationDag", stale, fallback.correction);
|
|
711
|
+
if (!stale && generationRoot) {
|
|
712
|
+
const snapshotViolations = retainedPackageSnapshotViolations(generationRoot, expectedPackageIdentity);
|
|
713
|
+
for (const violation of snapshotViolations) {
|
|
714
|
+
add("packages/cli/scripts/verify-generated-overlap.mjs#writeActivationEvidence", violation, fallback.correction);
|
|
715
|
+
}
|
|
716
|
+
if (snapshotViolations.length === 0) {
|
|
717
|
+
const manifest = inputs.evidenceManifest ?? readActivationEvidenceManifest(generationRoot);
|
|
718
|
+
for (const violation of activationEvidenceViolations(manifest, {
|
|
719
|
+
root,
|
|
720
|
+
generationRoot,
|
|
721
|
+
generation,
|
|
722
|
+
productionInputs,
|
|
723
|
+
expectedManifestDigest: expectedEvidenceDigest ?? "",
|
|
724
|
+
expectedPackageIdentity,
|
|
725
|
+
})) {
|
|
726
|
+
add("packages/cli/scripts/verify-generated-overlap.mjs#writeActivationEvidence", violation, fallback.correction);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return report(contract, observed, census, violations, generation, generationRoot);
|
|
732
|
+
}
|
|
733
|
+
export function validateActivationConjunction(inputs = {}) {
|
|
734
|
+
try {
|
|
735
|
+
return validateActivationConjunctionUnchecked(inputs);
|
|
736
|
+
}
|
|
737
|
+
catch (error) {
|
|
738
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
739
|
+
const reason = /ENOENT|missing|no (?:such|CLI|package root)/i.test(message)
|
|
740
|
+
? "authoritative activation evidence artifact is missing"
|
|
741
|
+
: /JSON|parse|syntax|malformed/i.test(message)
|
|
742
|
+
? "authoritative activation evidence artifact is malformed"
|
|
743
|
+
: "authoritative activation evidence artifact could not be executed";
|
|
744
|
+
return authoritativeEvidenceFailure(reason);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
function compactRows(rows) {
|
|
748
|
+
return rows.map((row) => ({
|
|
749
|
+
class: row.classId,
|
|
750
|
+
surface: row.surfaceId,
|
|
751
|
+
owner: ownerText(row.owner),
|
|
752
|
+
checks: row.dimensions.map(({ checkId, status }) => [checkId, status]),
|
|
753
|
+
}));
|
|
754
|
+
}
|
|
755
|
+
function report(contract, rows, census, violations, generation, generationRoot) {
|
|
756
|
+
const reportableRows = rows.filter((row) => boundedIdentity(row, contract) === null
|
|
757
|
+
&& row.dimensions.every(({ checkId, evidenceRef }) => checkId.length <= contract.bounds.maxCheckIdCharacters && ACTIVATION_CHECK_IDS.includes(checkId) && evidenceRef.length <= 80));
|
|
758
|
+
const result = {
|
|
759
|
+
schemaVersion: contract.gateIdentity,
|
|
760
|
+
command: "check validate activation-conjunction",
|
|
761
|
+
target_family: "activation-conjunction",
|
|
762
|
+
status: violations.length === 0 ? "pass" : "fail",
|
|
763
|
+
valid: violations.length === 0,
|
|
764
|
+
counts: { classes: ACTIVATION_CLASSES.length, surfaces: rows.length, dimensions: ACTIVATION_DIMENSIONS.length, by_class: Object.fromEntries(ACTIVATION_CLASSES.map((id) => [id, rows.filter((row) => row.classId === id).length])) },
|
|
765
|
+
census,
|
|
766
|
+
evidence_sources: Object.fromEntries(ACTIVATION_CLASSES.flatMap((classId) => ACTIVATION_DIMENSIONS.map((dimension) => [`${classId}.${dimension}`, ACTIVATION_EVIDENCE_SOURCES[classId][dimension]]))),
|
|
767
|
+
provenance: { source: "current-source", package: generation ? "fresh-generation" : "not-required", ...(generation ? { generation } : {}) },
|
|
768
|
+
tuple_authority: ACTIVATION_TUPLE_AUTHORITY,
|
|
769
|
+
evidence_manifest: generation && generationRoot ? {
|
|
770
|
+
schema: "agentera.activationEvidence.v1",
|
|
771
|
+
path: `packages/cli/.agentera-generated/generations/${generation}/${ACTIVATION_EVIDENCE_FILE}`,
|
|
772
|
+
digest: (() => {
|
|
773
|
+
const manifest = readActivationEvidenceManifest(generationRoot);
|
|
774
|
+
return typeof manifest?.manifestDigest === "string" ? manifest.manifestDigest : null;
|
|
775
|
+
})(),
|
|
776
|
+
} : null,
|
|
777
|
+
rows: compactRows(reportableRows.slice(0, contract.bounds.maxRows)),
|
|
778
|
+
violation_count: violations.length,
|
|
779
|
+
violations: violations,
|
|
780
|
+
side_effects: { activation: false, publication: false, receipt: false, candidate: false, registry: false },
|
|
781
|
+
};
|
|
782
|
+
return Buffer.byteLength(JSON.stringify(result), "utf8") <= contract.bounds.maxOutputBytes ? result : fixedFailure("bounded activation report exceeded its serialized output limit");
|
|
783
|
+
}
|
|
784
|
+
function fixedFailure(reason) {
|
|
785
|
+
return {
|
|
786
|
+
schemaVersion: "agentera.activationConjunction.v1", command: "check validate activation-conjunction", target_family: "activation-conjunction",
|
|
787
|
+
status: "fail", valid: false, rows: [], violation_count: 1,
|
|
788
|
+
violations: [{ owner: "packages/cli/src/validate/activationConjunction.ts#activationConjunctionMain", violation: reason, correction: "node packages/cli/dist/bin/agentera.js check validate activation-conjunction --format json" }],
|
|
789
|
+
side_effects: { activation: false, publication: false, receipt: false, candidate: false, registry: false },
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function authoritativeEvidenceFailure(reason) {
|
|
793
|
+
return {
|
|
794
|
+
schemaVersion: "agentera.activationConjunction.v1", command: "check validate activation-conjunction", target_family: "activation-conjunction",
|
|
795
|
+
status: "fail", valid: false, rows: [], violation_count: 1,
|
|
796
|
+
violations: [{
|
|
797
|
+
owner: "packages/cli/scripts/verify-generated-overlap.mjs#writeActivationEvidence",
|
|
798
|
+
violation: reason,
|
|
799
|
+
correction: ACTIVATION_CLASS_AUTHORITIES.package.correction,
|
|
800
|
+
}],
|
|
801
|
+
side_effects: { activation: false, publication: false, receipt: false, candidate: false, registry: false },
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
export function activationConjunctionMain(options = {}) {
|
|
805
|
+
let result = validateActivationConjunction(options);
|
|
806
|
+
let serialized = `${JSON.stringify(result)}\n`;
|
|
807
|
+
const maximum = options.contract?.bounds.maxOutputBytes ?? 196_608;
|
|
808
|
+
if (Buffer.byteLength(serialized, "utf8") > maximum) {
|
|
809
|
+
result = fixedFailure("bounded activation report exceeded its serialized output limit");
|
|
810
|
+
serialized = `${JSON.stringify(result)}\n`;
|
|
811
|
+
if (Buffer.byteLength(serialized, "utf8") > maximum)
|
|
812
|
+
throw new Error("internal fixed activation fallback exceeds output bound");
|
|
813
|
+
}
|
|
814
|
+
(options.out ?? ((text) => process.stdout.write(text)))(serialized);
|
|
815
|
+
return result.valid === true ? 0 : 1;
|
|
816
|
+
}
|