agentera 3.0.0-dev.41 → 3.0.0-dev.46

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.
Files changed (728) hide show
  1. package/README.md +33 -4
  2. package/bundle/CHANGELOG.md +91 -1
  3. package/bundle/README.md +26 -19
  4. package/bundle/UPGRADE.md +50 -15
  5. package/bundle/references/adapters/package-publication.json +408 -14
  6. package/bundle/references/adapters/package-registry.yaml +414 -1
  7. package/bundle/references/adapters/package-surface-characterization.md +20 -0
  8. package/bundle/references/adapters/runtime-retired-resources.yaml +237 -1
  9. package/bundle/references/analysis/evidence-tier-authority.yaml +3 -3
  10. package/bundle/references/analysis/verification-policy.yaml +48 -0
  11. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +1 -1
  12. package/bundle/references/artifacts/glossary-entry-contract.yaml +11 -11
  13. package/bundle/references/artifacts/state-storage-authority.yaml +170 -118
  14. package/bundle/references/cli/capability-instruction-contract.yaml +4 -4
  15. package/bundle/references/cli/hybrid-route-contract.yaml +27 -5
  16. package/bundle/references/cli/routing-model.md +20 -4
  17. package/bundle/references/cli/trigger-schema-enrichment.md +7 -0
  18. package/bundle/references/cli/vocabulary-index.yaml +1 -3
  19. package/bundle/references/cli/vocabulary.md +18 -60
  20. package/bundle/references/meta/retained-reference-authority.yaml +151 -0
  21. package/bundle/skills/agentera/SKILL.md +32 -16
  22. package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +3 -3
  23. package/bundle/skills/agentera/capabilities/audit/schemas/validation.yaml +1 -1
  24. package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +5 -5
  25. package/bundle/skills/agentera/capabilities/build/schemas/validation.yaml +5 -5
  26. package/bundle/skills/agentera/capabilities/design/schemas/exit.yaml +2 -2
  27. package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +3 -3
  28. package/bundle/skills/agentera/capabilities/discuss/schemas/validation.yaml +2 -2
  29. package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +3 -3
  30. package/bundle/skills/agentera/capabilities/document/schemas/validation.yaml +1 -1
  31. package/bundle/skills/agentera/capabilities/optimize/schemas/artifacts.yaml +1 -1
  32. package/bundle/skills/agentera/capabilities/optimize/schemas/validation.yaml +1 -1
  33. package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +5 -5
  34. package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +2 -2
  35. package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +1 -1
  36. package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +1 -1
  37. package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +1 -1
  38. package/bundle/skills/agentera/capability_schema_contract.yaml +2 -2
  39. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +3 -3
  40. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +3 -3
  41. package/bundle/skills/agentera/schemas/artifacts/glossary.yaml +1 -1
  42. package/bundle/skills/agentera/schemas/artifacts/health.yaml +3 -3
  43. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +12 -10
  44. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +3 -3
  45. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +6 -4
  46. package/dist/analytics/extractCorpus/cli.js +0 -1
  47. package/dist/analytics/extractCorpus/copilotSessions.js +0 -1
  48. package/dist/analytics/extractCorpus/core.js +0 -1
  49. package/dist/analytics/extractCorpus/corpus.js +0 -1
  50. package/dist/analytics/extractCorpus/coverageAudit.js +0 -1
  51. package/dist/analytics/extractCorpus/cursorSessions.js +0 -1
  52. package/dist/analytics/extractCorpus/evidenceTiers.js +0 -1
  53. package/dist/analytics/extractCorpus/extractCorpusParity.js +0 -1
  54. package/dist/analytics/extractCorpus/filesystemSources.js +0 -1
  55. package/dist/analytics/extractCorpus/index.js +0 -1
  56. package/dist/analytics/extractCorpus/jsonlSessions.js +0 -1
  57. package/dist/analytics/extractCorpus/sqliteCaps.js +0 -1
  58. package/dist/analytics/extractCorpus/sqliteSessions.js +0 -1
  59. package/dist/analytics/extractCorpus/tierReader.js +0 -1
  60. package/dist/analytics/extractCorpus.js +0 -1
  61. package/dist/analytics/glossaryAdviceResolution.js +0 -1
  62. package/dist/analytics/glossaryInputAcquisition.js +0 -1
  63. package/dist/analytics/personalGlossaryAdmission.js +0 -1
  64. package/dist/analytics/personalGlossaryProfile.js +0 -1
  65. package/dist/analytics/profileSignals.js +0 -1
  66. package/dist/analytics/usageStats.js +0 -1
  67. package/dist/audit/terminologyDrift.js +0 -1
  68. package/dist/bin/agentera.js +0 -1
  69. package/dist/capabilities/audit/instructions.js +3 -4
  70. package/dist/capabilities/build/instructions.js +2 -3
  71. package/dist/capabilities/design/instructions.js +1 -2
  72. package/dist/capabilities/discuss/instructions.js +2 -3
  73. package/dist/capabilities/document/instructions.js +2 -3
  74. package/dist/capabilities/index.js +5 -4
  75. package/dist/capabilities/optimize/instructions.js +1 -2
  76. package/dist/capabilities/orchestrate/instructions.js +3 -4
  77. package/dist/capabilities/plan/instructions.js +1 -2
  78. package/dist/capabilities/profile/instructions.js +1 -2
  79. package/dist/capabilities/research/instructions.js +1 -2
  80. package/dist/capabilities/status/instructions.js +1 -2
  81. package/dist/capabilities/status/startupInstructions.js +0 -5
  82. package/dist/capabilities/vision/instructions.js +1 -2
  83. package/dist/cli/appContext.js +0 -1
  84. package/dist/cli/argvalidate.js +0 -1
  85. package/dist/cli/capabilityContext/benchmark.js +4 -4
  86. package/dist/cli/capabilityContext/bespoke.js +0 -1
  87. package/dist/cli/capabilityContext/build.js +8 -10
  88. package/dist/cli/capabilityContext/closeout.js +8 -10
  89. package/dist/cli/capabilityContext/contract.js +7 -42
  90. package/dist/cli/capabilityContext/evidence.js +12 -14
  91. package/dist/cli/capabilityContext/index.js +0 -1
  92. package/dist/cli/capabilityContext/orchestration.js +6 -8
  93. package/dist/cli/capabilityContext/planState.js +0 -1
  94. package/dist/cli/capabilityContext/progress.js +0 -1
  95. package/dist/cli/capabilityContext/projectVerification.js +0 -1
  96. package/dist/cli/capabilityContext/shared.js +2 -19
  97. package/dist/cli/capabilityContext/slim.js +0 -1
  98. package/dist/cli/capabilityContext/startup.js +24 -152
  99. package/dist/cli/capabilityContext/startupAggregation.js +68 -0
  100. package/dist/cli/capabilityContext/types.js +4 -4
  101. package/dist/cli/capabilityContext.js +0 -1
  102. package/dist/cli/commands/appHome.js +0 -1
  103. package/dist/cli/commands/capability.js +2 -2
  104. package/dist/cli/commands/compact.js +0 -1
  105. package/dist/cli/commands/doctor.js +104 -9
  106. package/dist/cli/commands/durability.js +0 -1
  107. package/dist/cli/commands/glossaryAdvice.js +0 -1
  108. package/dist/cli/commands/lint.js +0 -1
  109. package/dist/cli/commands/personalGlossary.js +0 -1
  110. package/dist/cli/commands/prime/briefOrientation.js +24 -85
  111. package/dist/cli/commands/prime/buildExecutionRequest.js +2 -2
  112. package/dist/cli/commands/prime/bundleStatus.js +0 -1
  113. package/dist/cli/commands/prime/collectEntityOrientation.js +47 -27
  114. package/dist/cli/commands/prime/collectOrientationState.js +36 -2
  115. package/dist/cli/commands/prime/orientationOutput.js +104 -84
  116. package/dist/cli/commands/prime/types.js +0 -1
  117. package/dist/cli/commands/prime/v1Migration.js +0 -1
  118. package/dist/cli/commands/prime.js +18 -36
  119. package/dist/cli/commands/profileGrounding.js +0 -1
  120. package/dist/cli/commands/query.js +2 -2
  121. package/dist/cli/commands/report.js +0 -1
  122. package/dist/cli/commands/route.js +3 -3
  123. package/dist/cli/commands/schema.js +62 -92
  124. package/dist/cli/commands/state/decisions.js +0 -1
  125. package/dist/cli/commands/state/docs.js +0 -1
  126. package/dist/cli/commands/state/experimentRecords.js +0 -1
  127. package/dist/cli/commands/state/experiments.js +0 -1
  128. package/dist/cli/commands/state/get.js +0 -1
  129. package/dist/cli/commands/state/health.js +0 -1
  130. package/dist/cli/commands/state/index.js +0 -1
  131. package/dist/cli/commands/state/list.js +0 -1
  132. package/dist/cli/commands/state/objective.js +0 -1
  133. package/dist/cli/commands/state/plan.js +0 -1
  134. package/dist/cli/commands/state/planTasks.js +0 -1
  135. package/dist/cli/commands/state/plans.js +0 -1
  136. package/dist/cli/commands/state/progress.js +0 -1
  137. package/dist/cli/commands/state/shared.js +0 -1
  138. package/dist/cli/commands/state/todo.js +0 -1
  139. package/dist/cli/commands/state/write.js +10 -1
  140. package/dist/cli/commands/upgrade.js +0 -1
  141. package/dist/cli/commands/upgradeVerify.js +0 -1
  142. package/dist/cli/commands/validate.js +106 -10
  143. package/dist/cli/commands/verify.js +0 -1
  144. package/dist/cli/contracts/bundleStatus.js +0 -1
  145. package/dist/cli/contracts/orientationState.js +0 -1
  146. package/dist/cli/dispatch/argvParser.js +0 -1
  147. package/dist/cli/dispatch/check.js +6 -24
  148. package/dist/cli/dispatch/commands.js +3 -3
  149. package/dist/cli/dispatch/index.js +9 -36
  150. package/dist/cli/dispatch/lifecycle.js +11 -57
  151. package/dist/cli/dispatch/prime.js +0 -1
  152. package/dist/cli/dispatch/projections.js +17 -0
  153. package/dist/cli/dispatch/shared.js +0 -1
  154. package/dist/cli/dispatch/state.js +0 -1
  155. package/dist/cli/dispatch.js +0 -1
  156. package/dist/cli/errors.js +0 -1
  157. package/dist/cli/help.js +51 -30
  158. package/dist/cli/migrationRequired.js +3 -5
  159. package/dist/cli/orientation/attention.js +4 -17
  160. package/dist/cli/orientation/corpusCoverage.js +0 -1
  161. package/dist/cli/orientation.js +5 -5
  162. package/dist/cli/planArtifacts.js +0 -1
  163. package/dist/cli/planEvidence.js +0 -1
  164. package/dist/cli/planLifecycleState.js +2 -2
  165. package/dist/cli/planTaskIndex.js +0 -1
  166. package/dist/cli/preCutoverCommand.js +32 -0
  167. package/dist/cli/prime-blob.js +6 -6
  168. package/dist/cli/profileAcquisition.js +0 -1
  169. package/dist/cli/startupCompletenessContract.js +0 -1
  170. package/dist/cli/stateQuery.js +17 -21
  171. package/dist/cli/structured.js +0 -1
  172. package/dist/cli/todoMarkdown.js +0 -1
  173. package/dist/cli/todoReadinessSelection.js +2 -2
  174. package/dist/cli/todoSeverity.js +0 -1
  175. package/dist/core/atomicWriter.js +0 -1
  176. package/dist/core/developmentChannel.js +1 -0
  177. package/dist/core/developmentInvocation.js +374 -0
  178. package/dist/core/difflib.js +0 -1
  179. package/dist/core/envPaths.js +0 -1
  180. package/dist/core/jsonValue.js +0 -1
  181. package/dist/core/paths.js +0 -1
  182. package/dist/core/pyjson.js +0 -1
  183. package/dist/core/shell.js +0 -1
  184. package/dist/core/skillIdentity.js +0 -1
  185. package/dist/core/sourceRoot.js +9 -12
  186. package/dist/core/text.js +0 -1
  187. package/dist/core/toml.js +0 -1
  188. package/dist/core/yaml.js +0 -1
  189. package/dist/eval/evalSkills.js +0 -1
  190. package/dist/eval/hybridRouteEvaluation.js +0 -1
  191. package/dist/eval/semanticEval.js +0 -1
  192. package/dist/eval/semanticFixtures.js +0 -1
  193. package/dist/hooks/common.js +1 -54
  194. package/dist/hooks/compaction/apply.js +0 -1
  195. package/dist/hooks/compaction/dryRun.js +0 -1
  196. package/dist/hooks/compaction/index.js +1 -2
  197. package/dist/hooks/compaction/parse.js +0 -1
  198. package/dist/hooks/compaction/retention.js +0 -1
  199. package/dist/hooks/compaction/status.js +0 -1
  200. package/dist/hooks/compaction/types.js +0 -1
  201. package/dist/hooks/validateArtifact/agentFacing.js +0 -1
  202. package/dist/hooks/validateArtifact/index.js +6 -65
  203. package/dist/hooks/validateArtifact/markdown.js +0 -1
  204. package/dist/hooks/validateArtifact/schema.js +0 -1
  205. package/dist/hooks/validateArtifact/traversal.js +0 -1
  206. package/dist/hooks/validateArtifact/violations.js +0 -1
  207. package/dist/migrate/v2HandoffManifest.js +0 -3
  208. package/dist/registries/activationContract.js +2 -0
  209. package/dist/registries/activationTuples.js +106 -0
  210. package/dist/registries/artifactProtocolIds.js +0 -1
  211. package/dist/registries/artifactRegistry.js +0 -1
  212. package/dist/registries/artifactSchemaProjection.js +0 -1
  213. package/dist/registries/capabilityContract.js +0 -1
  214. package/dist/registries/evaluatorHandoffContract.js +0 -1
  215. package/dist/registries/evidenceTierContract.js +0 -1
  216. package/dist/registries/glossaryAdviceContract.js +2 -2
  217. package/dist/registries/glossaryCaveatContract.js +0 -1
  218. package/dist/registries/glossaryConsumerContractValidation.js +5 -6
  219. package/dist/registries/glossaryEntryContract.js +8 -8
  220. package/dist/registries/glossaryTermIdentity.js +0 -1
  221. package/dist/registries/glossaryTermOccurrence.js +0 -1
  222. package/dist/registries/hybridRoute.js +73 -2
  223. package/dist/registries/hybridRouteReceipt.js +2 -2
  224. package/dist/registries/packagePublication.js +229 -0
  225. package/dist/registries/packageRegistry.js +118 -2
  226. package/dist/registries/todoReadinessContract.js +0 -1
  227. package/dist/registries/triggerLoader.js +0 -1
  228. package/dist/registries/verbosityBudgetContract.js +0 -1
  229. package/dist/release/releaseMetadata.js +69 -3
  230. package/dist/runtime/lifecycleAdapterContract.js +0 -1
  231. package/dist/runtime/lifecycleAdapters.js +0 -1
  232. package/dist/runtime/lifecycleAuthority.js +0 -1
  233. package/dist/runtime/lifecycleOperationContract.js +12 -3
  234. package/dist/runtime/lifecycleOperations.js +0 -1
  235. package/dist/runtime/lifecycleOwnershipJournal.js +0 -1
  236. package/dist/runtime/lifecyclePublication.js +0 -1
  237. package/dist/runtime/lifecycleSnapshot.js +0 -1
  238. package/dist/runtime/nativeResourceCleanup.js +191 -6
  239. package/dist/setup/opencode.js +0 -1
  240. package/dist/setup/opencodeConstants.js +0 -1
  241. package/dist/setup/sharedSkill.js +0 -1
  242. package/dist/setup/smokeChecks.js +1 -33
  243. package/dist/state/archiveDiscovery.js +0 -1
  244. package/dist/state/archivePublication.js +0 -1
  245. package/dist/state/archiveRecovery.js +0 -1
  246. package/dist/state/archiveReplay.js +0 -1
  247. package/dist/state/canonicalMigrationRecord.js +0 -1
  248. package/dist/state/changelog.js +0 -1
  249. package/dist/state/decisionEntities.js +0 -1
  250. package/dist/state/decisionLegacyValidation.js +0 -1
  251. package/dist/state/decisionMigrationProvenance.js +0 -1
  252. package/dist/state/decisionOverlay.js +0 -1
  253. package/dist/state/decisionRevision.js +0 -1
  254. package/dist/state/decisionRevisionMigration.js +0 -1
  255. package/dist/state/directRetrieval.js +0 -1
  256. package/dist/state/durability.js +0 -1
  257. package/dist/state/entityCutover.js +174 -9
  258. package/dist/state/entityCutoverGit.js +0 -1
  259. package/dist/state/entityGlossaryAuthority.js +0 -1
  260. package/dist/state/entityListProjection.js +0 -1
  261. package/dist/state/entityListRuntimeRegistry.js +46 -11
  262. package/dist/state/entityMigrationCausality.js +3 -5
  263. package/dist/state/entityMigrationIdentity.js +0 -1
  264. package/dist/state/entityMigrationPreview.js +35 -73
  265. package/dist/state/entityMigrationTodo.js +133 -0
  266. package/dist/state/entityPublicationContext.js +0 -1
  267. package/dist/state/entityRetrievalHelp.js +53 -23
  268. package/dist/state/entityStorage.js +0 -1
  269. package/dist/state/exactReplacementRecovery.js +0 -1
  270. package/dist/state/experimentArchive.js +0 -1
  271. package/dist/state/experimentIdentity.js +0 -1
  272. package/dist/state/healthEntities.js +0 -1
  273. package/dist/state/healthEntityValidation.js +0 -1
  274. package/dist/state/healthRepair.js +0 -1
  275. package/dist/state/installRoot.js +0 -1
  276. package/dist/state/legacyEntityCutoverEvidence.js +0 -1
  277. package/dist/state/legacyIdentity.js +0 -1
  278. package/dist/state/legacySummaryRecord.js +0 -1
  279. package/dist/state/listAccounting.js +0 -1
  280. package/dist/state/listClassification.js +0 -1
  281. package/dist/state/listCursor.js +0 -1
  282. package/dist/state/listRetrieval.js +0 -1
  283. package/dist/state/migrationSourceBinding.js +0 -1
  284. package/dist/state/objectiveExperimentEntities.js +0 -1
  285. package/dist/state/planEntities.js +0 -1
  286. package/dist/state/planIdentity.js +0 -1
  287. package/dist/state/planRetrieval.js +0 -1
  288. package/dist/state/planTaskRetrieval.js +0 -1
  289. package/dist/state/progressEntities.js +0 -1
  290. package/dist/state/progressGlossaryCaveat.js +0 -1
  291. package/dist/state/progressPublicationOrder.js +0 -1
  292. package/dist/state/projectRoot.js +0 -1
  293. package/dist/state/projectionPolicy.js +0 -1
  294. package/dist/state/retrievalAuthority.js +0 -1
  295. package/dist/state/safeProjectFile.js +0 -1
  296. package/dist/state/startupAnalysis/benchmark.js +0 -1
  297. package/dist/state/startupAnalysis/contract.js +44 -10
  298. package/dist/state/startupAnalysis/helpers.js +0 -1
  299. package/dist/state/startupAnalysis/index.js +0 -1
  300. package/dist/state/startupAnalysis/metrics.js +0 -1
  301. package/dist/state/startupAnalysis/records.js +0 -1
  302. package/dist/state/startupAnalysis/report.js +0 -1
  303. package/dist/state/startupAnalysis/threshold.js +0 -1
  304. package/dist/state/startupAnalysis.js +0 -1
  305. package/dist/state/startupProjection.js +2 -2
  306. package/dist/state/stateMode.js +0 -1
  307. package/dist/state/stateStorageAuthority.js +0 -1
  308. package/dist/state/summaryEntityRead.js +0 -1
  309. package/dist/state/summaryMigrationProvenance.js +0 -1
  310. package/dist/state/summarySourceRowAuthority.js +0 -1
  311. package/dist/state/todoDocsEntities.js +161 -83
  312. package/dist/state/todoDocsEntityValidation.js +0 -1
  313. package/dist/state/todoMarkdownProjection.js +51 -0
  314. package/dist/state/todoReconciliationActivation.js +73 -4
  315. package/dist/state/todoReconciliationInspection.js +173 -0
  316. package/dist/state/todoReconciliationRepair.js +170 -0
  317. package/dist/state/todoReconciliationTransaction.js +41 -13
  318. package/dist/state/write/assign.js +0 -1
  319. package/dist/state/write/candidateMutation.js +0 -1
  320. package/dist/state/write/errors.js +0 -1
  321. package/dist/state/write/experimentPublication.js +0 -1
  322. package/dist/state/write/explain.js +0 -1
  323. package/dist/state/write/fields.js +0 -1
  324. package/dist/state/write/glossaryPublication.js +0 -1
  325. package/dist/state/write/grammar.js +13 -4
  326. package/dist/state/write/helpers.js +0 -1
  327. package/dist/state/write/index.js +0 -1
  328. package/dist/state/write/input.js +0 -1
  329. package/dist/state/write/lock.js +0 -1
  330. package/dist/state/write/mutation.js +0 -1
  331. package/dist/state/write/operations.js +0 -1
  332. package/dist/state/write/planEvaluation.js +0 -1
  333. package/dist/state/write/planPublication.js +0 -1
  334. package/dist/state/write/runtimeOperations.js +83 -6
  335. package/dist/state/write/serialize.js +0 -1
  336. package/dist/state/write/transaction.js +0 -1
  337. package/dist/state/write/validate.js +0 -1
  338. package/dist/upgrade/appContentRefresh.js +0 -1
  339. package/dist/upgrade/appModel.js +0 -1
  340. package/dist/upgrade/atomicWriter.js +0 -1
  341. package/dist/upgrade/bundleEvidence.js +0 -1
  342. package/dist/upgrade/channels.js +0 -1
  343. package/dist/upgrade/compatibility.js +0 -1
  344. package/dist/upgrade/doctor.js +0 -1
  345. package/dist/upgrade/doctorClassifier.js +0 -1
  346. package/dist/upgrade/installedHooksRetirement.js +0 -1
  347. package/dist/upgrade/legacyAgentCleanup.js +0 -1
  348. package/dist/upgrade/lifecycleUpgrade.js +0 -1
  349. package/dist/upgrade/migrateArtifactsV2ToV3.js +7 -15
  350. package/dist/upgrade/migrationPublication.js +0 -1
  351. package/dist/upgrade/nextMajorDoctor.js +0 -1
  352. package/dist/upgrade/npxPlatformStatus.js +0 -1
  353. package/dist/upgrade/projectIntegration.js +4 -17
  354. package/dist/upgrade/projectIntegrationDecision.js +0 -1
  355. package/dist/upgrade/retiredResourceDiagnostics.js +117 -0
  356. package/dist/upgrade/runtimeMigration.js +61 -190
  357. package/dist/upgrade/upgradeCommands.js +5 -1
  358. package/dist/upgrade/upgradeLock.js +0 -1
  359. package/dist/upgrade/upgradeOrchestrator.js +52 -9
  360. package/dist/upgrade/v3CapabilitySurface.js +0 -1
  361. package/dist/upgrade/versionResolution.js +0 -1
  362. package/dist/validate/activationArtifactEvidence.js +844 -0
  363. package/dist/validate/activationConjunction.js +816 -0
  364. package/dist/validate/activationEvidenceManifest.js +515 -0
  365. package/dist/validate/activationPackageSemantics.js +29 -0
  366. package/dist/validate/appHomeContract.js +0 -2
  367. package/dist/validate/bootstrapAuthority.js +44 -0
  368. package/dist/validate/capability.js +0 -1
  369. package/dist/validate/crossCapability.js +0 -1
  370. package/dist/validate/retainedReferenceAuthority.js +879 -0
  371. package/dist/validate/selfAudit.js +0 -1
  372. package/dist/validate/v1LegacyCruft.js +0 -10
  373. package/dist/validate/vocabularyAuthority.js +6 -8
  374. package/package.json +12 -5
  375. package/bundle/references/adapters/package-manifest-interface-model.yaml +0 -127
  376. package/bundle/references/analysis/benchmark.md +0 -271
  377. package/bundle/references/analysis/startup-measurement-contract.yaml +0 -435
  378. package/bundle/references/cli/agent-ready-state-contract.yaml +0 -1015
  379. package/bundle/references/cli/audience-namespace-cli-migration.yaml +0 -395
  380. package/bundle/references/cli/bundle-skill-vocabulary.yaml +0 -241
  381. package/bundle/references/cli/capability-instruction-structure.md +0 -144
  382. package/bundle/references/cli/capability-tool-classification.yaml +0 -53
  383. package/bundle/references/cli/coexistence-probe.yaml +0 -13
  384. package/bundle/references/cli/parity-expected-actual-template.md +0 -30
  385. package/bundle/references/cli/prime-consumer-compatibility.yaml +0 -701
  386. package/bundle/references/cli/routing-execution-vocabulary.yaml +0 -259
  387. package/bundle/references/cli/single-name-protocol.yaml +0 -42
  388. package/bundle/references/cli/upgrade-repair-wording.md +0 -25
  389. package/bundle/references/cli/v3-handoff-manifest.schema.yaml +0 -97
  390. package/bundle/references/meta/documentation-inventory.md +0 -50
  391. package/bundle/skills/agentera/references/contract.md +0 -1097
  392. package/dist/analytics/extractCorpus/cli.js.map +0 -1
  393. package/dist/analytics/extractCorpus/copilotSessions.js.map +0 -1
  394. package/dist/analytics/extractCorpus/core.js.map +0 -1
  395. package/dist/analytics/extractCorpus/corpus.js.map +0 -1
  396. package/dist/analytics/extractCorpus/coverageAudit.js.map +0 -1
  397. package/dist/analytics/extractCorpus/cursorSessions.js.map +0 -1
  398. package/dist/analytics/extractCorpus/evidenceTiers.js.map +0 -1
  399. package/dist/analytics/extractCorpus/extractCorpusParity.js.map +0 -1
  400. package/dist/analytics/extractCorpus/filesystemSources.js.map +0 -1
  401. package/dist/analytics/extractCorpus/index.js.map +0 -1
  402. package/dist/analytics/extractCorpus/jsonlSessions.js.map +0 -1
  403. package/dist/analytics/extractCorpus/sqliteCaps.js.map +0 -1
  404. package/dist/analytics/extractCorpus/sqliteSessions.js.map +0 -1
  405. package/dist/analytics/extractCorpus/tierReader.js.map +0 -1
  406. package/dist/analytics/extractCorpus.js.map +0 -1
  407. package/dist/analytics/glossaryAdviceResolution.js.map +0 -1
  408. package/dist/analytics/glossaryInputAcquisition.js.map +0 -1
  409. package/dist/analytics/personalGlossaryAdmission.js.map +0 -1
  410. package/dist/analytics/personalGlossaryProfile.js.map +0 -1
  411. package/dist/analytics/profileSignals.js.map +0 -1
  412. package/dist/analytics/usageStats.js.map +0 -1
  413. package/dist/audit/terminologyDrift.js.map +0 -1
  414. package/dist/bin/agentera.js.map +0 -1
  415. package/dist/capabilities/audit/instructions.js.map +0 -1
  416. package/dist/capabilities/build/instructions.js.map +0 -1
  417. package/dist/capabilities/design/instructions.js.map +0 -1
  418. package/dist/capabilities/discuss/instructions.js.map +0 -1
  419. package/dist/capabilities/document/instructions.js.map +0 -1
  420. package/dist/capabilities/index.js.map +0 -1
  421. package/dist/capabilities/optimize/instructions.js.map +0 -1
  422. package/dist/capabilities/orchestrate/instructions.js.map +0 -1
  423. package/dist/capabilities/plan/instructions.js.map +0 -1
  424. package/dist/capabilities/profile/instructions.js.map +0 -1
  425. package/dist/capabilities/research/instructions.js.map +0 -1
  426. package/dist/capabilities/status/instructions.js.map +0 -1
  427. package/dist/capabilities/status/startupInstructions.js.map +0 -1
  428. package/dist/capabilities/vision/instructions.js.map +0 -1
  429. package/dist/cli/appContext.js.map +0 -1
  430. package/dist/cli/argvalidate.js.map +0 -1
  431. package/dist/cli/capabilityContext/benchmark.js.map +0 -1
  432. package/dist/cli/capabilityContext/bespoke.js.map +0 -1
  433. package/dist/cli/capabilityContext/build.js.map +0 -1
  434. package/dist/cli/capabilityContext/closeout.js.map +0 -1
  435. package/dist/cli/capabilityContext/contract.js.map +0 -1
  436. package/dist/cli/capabilityContext/evidence.js.map +0 -1
  437. package/dist/cli/capabilityContext/index.js.map +0 -1
  438. package/dist/cli/capabilityContext/orchestration.js.map +0 -1
  439. package/dist/cli/capabilityContext/planState.js.map +0 -1
  440. package/dist/cli/capabilityContext/progress.js.map +0 -1
  441. package/dist/cli/capabilityContext/projectVerification.js.map +0 -1
  442. package/dist/cli/capabilityContext/shared.js.map +0 -1
  443. package/dist/cli/capabilityContext/slim.js.map +0 -1
  444. package/dist/cli/capabilityContext/startup.js.map +0 -1
  445. package/dist/cli/capabilityContext/types.js.map +0 -1
  446. package/dist/cli/capabilityContext.js.map +0 -1
  447. package/dist/cli/commands/appHome.js.map +0 -1
  448. package/dist/cli/commands/capability.js.map +0 -1
  449. package/dist/cli/commands/compact.js.map +0 -1
  450. package/dist/cli/commands/doctor.js.map +0 -1
  451. package/dist/cli/commands/durability.js.map +0 -1
  452. package/dist/cli/commands/entityMigrate.js +0 -132
  453. package/dist/cli/commands/entityMigrate.js.map +0 -1
  454. package/dist/cli/commands/glossaryAdvice.js.map +0 -1
  455. package/dist/cli/commands/lint.js.map +0 -1
  456. package/dist/cli/commands/personalGlossary.js.map +0 -1
  457. package/dist/cli/commands/prime/briefOrientation.js.map +0 -1
  458. package/dist/cli/commands/prime/buildExecutionRequest.js.map +0 -1
  459. package/dist/cli/commands/prime/bundleStatus.js.map +0 -1
  460. package/dist/cli/commands/prime/collectEntityOrientation.js.map +0 -1
  461. package/dist/cli/commands/prime/collectOrientationState.js.map +0 -1
  462. package/dist/cli/commands/prime/orientationOutput.js.map +0 -1
  463. package/dist/cli/commands/prime/types.js.map +0 -1
  464. package/dist/cli/commands/prime/v1Migration.js.map +0 -1
  465. package/dist/cli/commands/prime.js.map +0 -1
  466. package/dist/cli/commands/profileGrounding.js.map +0 -1
  467. package/dist/cli/commands/query.js.map +0 -1
  468. package/dist/cli/commands/report.js.map +0 -1
  469. package/dist/cli/commands/route.js.map +0 -1
  470. package/dist/cli/commands/schema.js.map +0 -1
  471. package/dist/cli/commands/state/decisions.js.map +0 -1
  472. package/dist/cli/commands/state/docs.js.map +0 -1
  473. package/dist/cli/commands/state/experimentRecords.js.map +0 -1
  474. package/dist/cli/commands/state/experiments.js.map +0 -1
  475. package/dist/cli/commands/state/get.js.map +0 -1
  476. package/dist/cli/commands/state/health.js.map +0 -1
  477. package/dist/cli/commands/state/index.js.map +0 -1
  478. package/dist/cli/commands/state/list.js.map +0 -1
  479. package/dist/cli/commands/state/objective.js.map +0 -1
  480. package/dist/cli/commands/state/plan.js.map +0 -1
  481. package/dist/cli/commands/state/planTasks.js.map +0 -1
  482. package/dist/cli/commands/state/plans.js.map +0 -1
  483. package/dist/cli/commands/state/progress.js.map +0 -1
  484. package/dist/cli/commands/state/shared.js.map +0 -1
  485. package/dist/cli/commands/state/todo.js.map +0 -1
  486. package/dist/cli/commands/state/write.js.map +0 -1
  487. package/dist/cli/commands/upgrade.js.map +0 -1
  488. package/dist/cli/commands/upgradeVerify.js.map +0 -1
  489. package/dist/cli/commands/validate.js.map +0 -1
  490. package/dist/cli/commands/verify.js.map +0 -1
  491. package/dist/cli/contracts/bundleStatus.js.map +0 -1
  492. package/dist/cli/contracts/orientationState.js.map +0 -1
  493. package/dist/cli/dispatch/argvParser.js.map +0 -1
  494. package/dist/cli/dispatch/check.js.map +0 -1
  495. package/dist/cli/dispatch/commands.js.map +0 -1
  496. package/dist/cli/dispatch/index.js.map +0 -1
  497. package/dist/cli/dispatch/lifecycle.js.map +0 -1
  498. package/dist/cli/dispatch/prime.js.map +0 -1
  499. package/dist/cli/dispatch/shared.js.map +0 -1
  500. package/dist/cli/dispatch/state.js.map +0 -1
  501. package/dist/cli/dispatch.js.map +0 -1
  502. package/dist/cli/errors.js.map +0 -1
  503. package/dist/cli/help.js.map +0 -1
  504. package/dist/cli/migrationRequired.js.map +0 -1
  505. package/dist/cli/orientation/attention.js.map +0 -1
  506. package/dist/cli/orientation/corpusCoverage.js.map +0 -1
  507. package/dist/cli/orientation.js.map +0 -1
  508. package/dist/cli/planArtifacts.js.map +0 -1
  509. package/dist/cli/planEvidence.js.map +0 -1
  510. package/dist/cli/planLifecycleState.js.map +0 -1
  511. package/dist/cli/planTaskIndex.js.map +0 -1
  512. package/dist/cli/prime-blob.js.map +0 -1
  513. package/dist/cli/profileAcquisition.js.map +0 -1
  514. package/dist/cli/startupCompletenessContract.js.map +0 -1
  515. package/dist/cli/stateQuery.js.map +0 -1
  516. package/dist/cli/structured.js.map +0 -1
  517. package/dist/cli/todoMarkdown.js.map +0 -1
  518. package/dist/cli/todoReadinessSelection.js.map +0 -1
  519. package/dist/cli/todoSeverity.js.map +0 -1
  520. package/dist/core/atomicWriter.js.map +0 -1
  521. package/dist/core/difflib.js.map +0 -1
  522. package/dist/core/envPaths.js.map +0 -1
  523. package/dist/core/jsonValue.js.map +0 -1
  524. package/dist/core/paths.js.map +0 -1
  525. package/dist/core/pyjson.js.map +0 -1
  526. package/dist/core/shell.js.map +0 -1
  527. package/dist/core/skillIdentity.js.map +0 -1
  528. package/dist/core/sourceRoot.js.map +0 -1
  529. package/dist/core/text.js.map +0 -1
  530. package/dist/core/toml.js.map +0 -1
  531. package/dist/core/yaml.js.map +0 -1
  532. package/dist/eval/evalSkills.js.map +0 -1
  533. package/dist/eval/hybridRouteEvaluation.js.map +0 -1
  534. package/dist/eval/semanticEval.js.map +0 -1
  535. package/dist/eval/semanticFixtures.js.map +0 -1
  536. package/dist/hooks/common.js.map +0 -1
  537. package/dist/hooks/compaction/apply.js.map +0 -1
  538. package/dist/hooks/compaction/dryRun.js.map +0 -1
  539. package/dist/hooks/compaction/index.js.map +0 -1
  540. package/dist/hooks/compaction/parse.js.map +0 -1
  541. package/dist/hooks/compaction/retention.js.map +0 -1
  542. package/dist/hooks/compaction/status.js.map +0 -1
  543. package/dist/hooks/compaction/types.js.map +0 -1
  544. package/dist/hooks/cursorPreToolUse.js +0 -19
  545. package/dist/hooks/cursorPreToolUse.js.map +0 -1
  546. package/dist/hooks/cursorSessionStart.js +0 -64
  547. package/dist/hooks/cursorSessionStart.js.map +0 -1
  548. package/dist/hooks/projectHookInput.js +0 -26
  549. package/dist/hooks/projectHookInput.js.map +0 -1
  550. package/dist/hooks/sessionStart.js +0 -94
  551. package/dist/hooks/sessionStart.js.map +0 -1
  552. package/dist/hooks/sessionStop.js +0 -198
  553. package/dist/hooks/sessionStop.js.map +0 -1
  554. package/dist/hooks/validateArtifact/agentFacing.js.map +0 -1
  555. package/dist/hooks/validateArtifact/index.js.map +0 -1
  556. package/dist/hooks/validateArtifact/markdown.js.map +0 -1
  557. package/dist/hooks/validateArtifact/runtime.js +0 -86
  558. package/dist/hooks/validateArtifact/runtime.js.map +0 -1
  559. package/dist/hooks/validateArtifact/schema.js.map +0 -1
  560. package/dist/hooks/validateArtifact/traversal.js.map +0 -1
  561. package/dist/hooks/validateArtifact/violations.js.map +0 -1
  562. package/dist/migrate/v2HandoffManifest.js.map +0 -1
  563. package/dist/registries/artifactProtocolIds.js.map +0 -1
  564. package/dist/registries/artifactRegistry.js.map +0 -1
  565. package/dist/registries/artifactSchemaProjection.js.map +0 -1
  566. package/dist/registries/capabilityContract.js.map +0 -1
  567. package/dist/registries/evaluatorHandoffContract.js.map +0 -1
  568. package/dist/registries/evidenceTierContract.js.map +0 -1
  569. package/dist/registries/glossaryAdviceContract.js.map +0 -1
  570. package/dist/registries/glossaryCaveatContract.js.map +0 -1
  571. package/dist/registries/glossaryConsumerContractValidation.js.map +0 -1
  572. package/dist/registries/glossaryEntryContract.js.map +0 -1
  573. package/dist/registries/glossaryTermIdentity.js.map +0 -1
  574. package/dist/registries/glossaryTermOccurrence.js.map +0 -1
  575. package/dist/registries/hybridRoute.js.map +0 -1
  576. package/dist/registries/hybridRouteReceipt.js.map +0 -1
  577. package/dist/registries/packageRegistry.js.map +0 -1
  578. package/dist/registries/todoReadinessContract.js.map +0 -1
  579. package/dist/registries/triggerLoader.js.map +0 -1
  580. package/dist/registries/verbosityBudgetContract.js.map +0 -1
  581. package/dist/release/releaseMetadata.js.map +0 -1
  582. package/dist/runtime/lifecycleAdapterContract.js.map +0 -1
  583. package/dist/runtime/lifecycleAdapters.js.map +0 -1
  584. package/dist/runtime/lifecycleAuthority.js.map +0 -1
  585. package/dist/runtime/lifecycleOperationContract.js.map +0 -1
  586. package/dist/runtime/lifecycleOperations.js.map +0 -1
  587. package/dist/runtime/lifecycleOwnershipJournal.js.map +0 -1
  588. package/dist/runtime/lifecyclePublication.js.map +0 -1
  589. package/dist/runtime/lifecycleSnapshot.js.map +0 -1
  590. package/dist/runtime/nativeResourceCleanup.js.map +0 -1
  591. package/dist/setup/codex/cli.js +0 -130
  592. package/dist/setup/codex/cli.js.map +0 -1
  593. package/dist/setup/codex/configToml.js +0 -558
  594. package/dist/setup/codex/configToml.js.map +0 -1
  595. package/dist/setup/codex/constants.js +0 -14
  596. package/dist/setup/codex/constants.js.map +0 -1
  597. package/dist/setup/codex/installRoot.js +0 -64
  598. package/dist/setup/codex/installRoot.js.map +0 -1
  599. package/dist/setup/codex/state.js +0 -252
  600. package/dist/setup/codex/state.js.map +0 -1
  601. package/dist/setup/codex.js +0 -10
  602. package/dist/setup/codex.js.map +0 -1
  603. package/dist/setup/opencode.js.map +0 -1
  604. package/dist/setup/opencodeConstants.js.map +0 -1
  605. package/dist/setup/sharedSkill.js.map +0 -1
  606. package/dist/setup/smokeChecks.js.map +0 -1
  607. package/dist/state/archiveDiscovery.js.map +0 -1
  608. package/dist/state/archivePublication.js.map +0 -1
  609. package/dist/state/archiveRecovery.js.map +0 -1
  610. package/dist/state/archiveReplay.js.map +0 -1
  611. package/dist/state/canonicalMigrationRecord.js.map +0 -1
  612. package/dist/state/changelog.js.map +0 -1
  613. package/dist/state/decisionEntities.js.map +0 -1
  614. package/dist/state/decisionLegacyValidation.js.map +0 -1
  615. package/dist/state/decisionMigrationProvenance.js.map +0 -1
  616. package/dist/state/decisionOverlay.js.map +0 -1
  617. package/dist/state/decisionRevision.js.map +0 -1
  618. package/dist/state/decisionRevisionMigration.js.map +0 -1
  619. package/dist/state/directRetrieval.js.map +0 -1
  620. package/dist/state/durability.js.map +0 -1
  621. package/dist/state/entityCutover.js.map +0 -1
  622. package/dist/state/entityCutoverGit.js.map +0 -1
  623. package/dist/state/entityGlossaryAuthority.js.map +0 -1
  624. package/dist/state/entityListProjection.js.map +0 -1
  625. package/dist/state/entityListRuntimeRegistry.js.map +0 -1
  626. package/dist/state/entityMigrationCausality.js.map +0 -1
  627. package/dist/state/entityMigrationIdentity.js.map +0 -1
  628. package/dist/state/entityMigrationPreview.js.map +0 -1
  629. package/dist/state/entityPublicationContext.js.map +0 -1
  630. package/dist/state/entityRetrievalHelp.js.map +0 -1
  631. package/dist/state/entityStorage.js.map +0 -1
  632. package/dist/state/exactReplacementRecovery.js.map +0 -1
  633. package/dist/state/experimentArchive.js.map +0 -1
  634. package/dist/state/experimentIdentity.js.map +0 -1
  635. package/dist/state/healthEntities.js.map +0 -1
  636. package/dist/state/healthEntityValidation.js.map +0 -1
  637. package/dist/state/healthRepair.js.map +0 -1
  638. package/dist/state/installRoot.js.map +0 -1
  639. package/dist/state/legacyEntityCutoverEvidence.js.map +0 -1
  640. package/dist/state/legacyIdentity.js.map +0 -1
  641. package/dist/state/legacySummaryRecord.js.map +0 -1
  642. package/dist/state/listAccounting.js.map +0 -1
  643. package/dist/state/listClassification.js.map +0 -1
  644. package/dist/state/listCursor.js.map +0 -1
  645. package/dist/state/listRetrieval.js.map +0 -1
  646. package/dist/state/migrationSourceBinding.js.map +0 -1
  647. package/dist/state/objectiveExperimentEntities.js.map +0 -1
  648. package/dist/state/planEntities.js.map +0 -1
  649. package/dist/state/planIdentity.js.map +0 -1
  650. package/dist/state/planRetrieval.js.map +0 -1
  651. package/dist/state/planTaskRetrieval.js.map +0 -1
  652. package/dist/state/progressEntities.js.map +0 -1
  653. package/dist/state/progressGlossaryCaveat.js.map +0 -1
  654. package/dist/state/progressPublicationOrder.js.map +0 -1
  655. package/dist/state/projectRoot.js.map +0 -1
  656. package/dist/state/projectionPolicy.js.map +0 -1
  657. package/dist/state/retrievalAuthority.js.map +0 -1
  658. package/dist/state/safeProjectFile.js.map +0 -1
  659. package/dist/state/startupAnalysis/benchmark.js.map +0 -1
  660. package/dist/state/startupAnalysis/contract.js.map +0 -1
  661. package/dist/state/startupAnalysis/helpers.js.map +0 -1
  662. package/dist/state/startupAnalysis/index.js.map +0 -1
  663. package/dist/state/startupAnalysis/metrics.js.map +0 -1
  664. package/dist/state/startupAnalysis/records.js.map +0 -1
  665. package/dist/state/startupAnalysis/report.js.map +0 -1
  666. package/dist/state/startupAnalysis/threshold.js.map +0 -1
  667. package/dist/state/startupAnalysis.js.map +0 -1
  668. package/dist/state/startupProjection.js.map +0 -1
  669. package/dist/state/stateMode.js.map +0 -1
  670. package/dist/state/stateStorageAuthority.js.map +0 -1
  671. package/dist/state/summaryEntityRead.js.map +0 -1
  672. package/dist/state/summaryMigrationProvenance.js.map +0 -1
  673. package/dist/state/summarySourceRowAuthority.js.map +0 -1
  674. package/dist/state/todoDocsEntities.js.map +0 -1
  675. package/dist/state/todoDocsEntityValidation.js.map +0 -1
  676. package/dist/state/todoReconciliationActivation.js.map +0 -1
  677. package/dist/state/todoReconciliationTransaction.js.map +0 -1
  678. package/dist/state/write/assign.js.map +0 -1
  679. package/dist/state/write/candidateMutation.js.map +0 -1
  680. package/dist/state/write/errors.js.map +0 -1
  681. package/dist/state/write/experimentPublication.js.map +0 -1
  682. package/dist/state/write/explain.js.map +0 -1
  683. package/dist/state/write/fields.js.map +0 -1
  684. package/dist/state/write/glossaryPublication.js.map +0 -1
  685. package/dist/state/write/grammar.js.map +0 -1
  686. package/dist/state/write/helpers.js.map +0 -1
  687. package/dist/state/write/index.js.map +0 -1
  688. package/dist/state/write/input.js.map +0 -1
  689. package/dist/state/write/lock.js.map +0 -1
  690. package/dist/state/write/mutation.js.map +0 -1
  691. package/dist/state/write/operations.js.map +0 -1
  692. package/dist/state/write/planEvaluation.js.map +0 -1
  693. package/dist/state/write/planPublication.js.map +0 -1
  694. package/dist/state/write/runtimeOperations.js.map +0 -1
  695. package/dist/state/write/serialize.js.map +0 -1
  696. package/dist/state/write/transaction.js.map +0 -1
  697. package/dist/state/write/validate.js.map +0 -1
  698. package/dist/upgrade/appContentRefresh.js.map +0 -1
  699. package/dist/upgrade/appModel.js.map +0 -1
  700. package/dist/upgrade/atomicWriter.js.map +0 -1
  701. package/dist/upgrade/bundleEvidence.js.map +0 -1
  702. package/dist/upgrade/channels.js.map +0 -1
  703. package/dist/upgrade/coexistenceProbe.js +0 -105
  704. package/dist/upgrade/coexistenceProbe.js.map +0 -1
  705. package/dist/upgrade/compatibility.js.map +0 -1
  706. package/dist/upgrade/doctor.js.map +0 -1
  707. package/dist/upgrade/doctorClassifier.js.map +0 -1
  708. package/dist/upgrade/installedHooksRetirement.js.map +0 -1
  709. package/dist/upgrade/legacyAgentCleanup.js.map +0 -1
  710. package/dist/upgrade/lifecycleUpgrade.js.map +0 -1
  711. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +0 -1
  712. package/dist/upgrade/migrationPublication.js.map +0 -1
  713. package/dist/upgrade/nextMajorDoctor.js.map +0 -1
  714. package/dist/upgrade/npxPlatformStatus.js.map +0 -1
  715. package/dist/upgrade/projectIntegration.js.map +0 -1
  716. package/dist/upgrade/projectIntegrationDecision.js.map +0 -1
  717. package/dist/upgrade/runtimeMigration.js.map +0 -1
  718. package/dist/upgrade/upgradeCommands.js.map +0 -1
  719. package/dist/upgrade/upgradeLock.js.map +0 -1
  720. package/dist/upgrade/upgradeOrchestrator.js.map +0 -1
  721. package/dist/upgrade/v3CapabilitySurface.js.map +0 -1
  722. package/dist/upgrade/versionResolution.js.map +0 -1
  723. package/dist/validate/appHomeContract.js.map +0 -1
  724. package/dist/validate/capability.js.map +0 -1
  725. package/dist/validate/crossCapability.js.map +0 -1
  726. package/dist/validate/selfAudit.js.map +0 -1
  727. package/dist/validate/v1LegacyCruft.js.map +0 -1
  728. package/dist/validate/vocabularyAuthority.js.map +0 -1
@@ -0,0 +1,844 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { ACTIVATION_CANONICAL_TUPLES } from "../registries/activationTuples.js";
7
+ import { loadRegistry } from "../registries/packageRegistry.js";
8
+ import { packageCommandDeclarations, packageDescriptorSemantics, packageDescriptors, } from "./activationPackageSemantics.js";
9
+ import { bootstrapMatrixAuthority } from "./bootstrapAuthority.js";
10
+ export const SOURCE_OWNER_EVIDENCE_SCHEMA = "agentera.activationSourceOwnerEvidence.v1";
11
+ export const PACKAGE_OWNER_EVIDENCE_SCHEMA = "agentera.activationPackageOwnerEvidence.v1";
12
+ export const GENERATED_OWNER_EVIDENCE_SCHEMA = "agentera.activationGeneratedOwnerEvidence.v1";
13
+ export const PACKAGE_IDENTITY_SCHEMA = "agentera.activationPackageIdentity.v1";
14
+ export const PACKAGE_SNAPSHOT_SCHEMA = "agentera.activationPackageSnapshot.v1";
15
+ export const PACKAGE_SNAPSHOT_DIRECTORY = ".activation-package-snapshot";
16
+ export const OWNER_EVIDENCE_MAX_BYTES = 262_144;
17
+ export const PACKAGE_IDENTITY_MAX_BYTES = 16_384;
18
+ export const PACKAGE_SNAPSHOT_MARKER_MAX_BYTES = 16_384;
19
+ export const PACKAGE_SNAPSHOT_TARBALL_MAX_BYTES = 64 * 1024 * 1024;
20
+ export const PACKAGE_SNAPSHOT_EXTRACTED_MAX_BYTES = 128 * 1024 * 1024;
21
+ export const PACKAGE_SNAPSHOT_MAX_ENTRIES = 4_096;
22
+ const sourceCapabilityCache = new Map();
23
+ const CAPABILITY_IDS = Object.freeze(ACTIVATION_CANONICAL_TUPLES
24
+ .filter((tuple) => tuple.class === "capability")
25
+ .map((tuple) => tuple.surface_id)
26
+ .sort());
27
+ function canonical(value) {
28
+ if (Array.isArray(value))
29
+ return value.map(canonical);
30
+ if (value && typeof value === "object") {
31
+ const object = value;
32
+ return Object.fromEntries(Object.keys(object).sort().map((key) => [key, canonical(object[key])]));
33
+ }
34
+ return value;
35
+ }
36
+ export function canonicalObservationJson(value) {
37
+ return JSON.stringify(canonical(value));
38
+ }
39
+ export function observationDigest(value) {
40
+ return createHash("sha256").update(canonicalObservationJson(value), "utf8").digest("hex");
41
+ }
42
+ function fileSha256(file) {
43
+ return createHash("sha256").update(fs.readFileSync(file)).digest("hex");
44
+ }
45
+ function artifactDigest(root, relatives) {
46
+ return observationDigest([...relatives].sort().map((relative) => ({
47
+ path: relative.split(path.sep).join("/"),
48
+ sha256: fs.existsSync(path.join(root, relative)) && fs.statSync(path.join(root, relative)).isFile()
49
+ ? fileSha256(path.join(root, relative))
50
+ : "missing",
51
+ })));
52
+ }
53
+ function filesBelow(root, relative = "") {
54
+ const directory = path.join(root, relative);
55
+ if (!fs.existsSync(directory))
56
+ return [];
57
+ return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
58
+ const child = path.join(relative, entry.name);
59
+ if (entry.isSymbolicLink())
60
+ return [];
61
+ return entry.isDirectory() ? filesBelow(root, child) : [child];
62
+ });
63
+ }
64
+ function completeTreeObservation(root, options = {}) {
65
+ const rootStat = fs.lstatSync(root);
66
+ if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
67
+ throw new Error("authoritative extracted package root is not a directory");
68
+ const entries = [];
69
+ let fileCount = 0;
70
+ let totalBytes = 0;
71
+ const visit = (directory) => {
72
+ const directoryPath = path.join(root, directory);
73
+ const directoryBefore = fs.lstatSync(directoryPath);
74
+ const names = fs.readdirSync(directoryPath).sort();
75
+ for (const name of names) {
76
+ const relative = path.join(directory, name);
77
+ const target = path.join(root, relative);
78
+ const stat = fs.lstatSync(target);
79
+ const normalized = relative.split(path.sep).join("/");
80
+ if (normalized.length > 512 || /[\0\r\n]/.test(normalized))
81
+ throw new Error("authoritative extracted package path violates its bound");
82
+ if (entries.length >= (options.maxEntries ?? PACKAGE_SNAPSHOT_MAX_ENTRIES))
83
+ throw new Error("authoritative extracted package exceeds its entry bound");
84
+ if (stat.isDirectory()) {
85
+ entries.push({ path: normalized, type: "directory", mode: stat.mode & 0o777 });
86
+ visit(relative);
87
+ }
88
+ else if (stat.isFile()) {
89
+ const bytes = readBoundedRegularFile(target, Math.max(0, (options.maxTotalBytes ?? PACKAGE_SNAPSHOT_EXTRACTED_MAX_BYTES) - totalBytes), true, stat);
90
+ fileCount += 1;
91
+ totalBytes += bytes.length;
92
+ if (totalBytes > (options.maxTotalBytes ?? PACKAGE_SNAPSHOT_EXTRACTED_MAX_BYTES))
93
+ throw new Error("authoritative extracted package exceeds its byte bound");
94
+ entries.push({
95
+ path: normalized,
96
+ type: "file",
97
+ mode: stat.mode & 0o777,
98
+ size: bytes.length,
99
+ sha256: createHash("sha256").update(bytes).digest("hex"),
100
+ });
101
+ }
102
+ else if (stat.isSymbolicLink()) {
103
+ if (options.allowSymlinks === false)
104
+ throw new Error("authoritative extracted package contains a symlink");
105
+ entries.push({
106
+ path: normalized,
107
+ type: "symlink",
108
+ mode: stat.mode & 0o777,
109
+ targetSha256: observationDigest(fs.readlinkSync(target)),
110
+ });
111
+ }
112
+ else {
113
+ throw new Error(`authoritative extracted package contains unsupported entry '${normalized}'`);
114
+ }
115
+ }
116
+ const directoryAfter = fs.lstatSync(directoryPath);
117
+ if (names.join("\0") !== fs.readdirSync(directoryPath).sort().join("\0")
118
+ || directoryBefore.dev !== directoryAfter.dev || directoryBefore.ino !== directoryAfter.ino
119
+ || directoryBefore.mtimeMs !== directoryAfter.mtimeMs) {
120
+ throw new Error("authoritative extracted package changed while it was observed");
121
+ }
122
+ };
123
+ visit("");
124
+ return { entries, digest: observationDigest(entries), fileCount, totalBytes };
125
+ }
126
+ function readBoundedRegularFile(file, maximumBytes, allowEmpty = false, expected) {
127
+ const noFollow = fs.constants.O_NOFOLLOW ?? 0;
128
+ const descriptor = fs.openSync(file, fs.constants.O_RDONLY | noFollow);
129
+ try {
130
+ const before = fs.fstatSync(descriptor);
131
+ if (!before.isFile() || (!allowEmpty && before.size <= 0) || before.size > maximumBytes
132
+ || (expected && (expected.dev !== before.dev || expected.ino !== before.ino))) {
133
+ throw new Error("authoritative package file violates its regular-file or byte bound");
134
+ }
135
+ const bytes = fs.readFileSync(descriptor);
136
+ const after = fs.fstatSync(descriptor);
137
+ if (bytes.length !== before.size || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs) {
138
+ throw new Error("authoritative package tarball changed while it was read");
139
+ }
140
+ return bytes;
141
+ }
142
+ finally {
143
+ fs.closeSync(descriptor);
144
+ }
145
+ }
146
+ function packageArtifactIdentity(filename, bytes) {
147
+ return {
148
+ filename,
149
+ integrity: `sha512-${createHash("sha512").update(bytes).digest("base64")}`,
150
+ shasum: createHash("sha1").update(bytes).digest("hex"),
151
+ tarballSha256: createHash("sha256").update(bytes).digest("hex"),
152
+ };
153
+ }
154
+ function preflightPackageBytes(bytes) {
155
+ const listed = spawnSync("tar", ["-tvzf", "-", "--numeric-owner", "--full-time"], {
156
+ input: bytes,
157
+ encoding: "utf8",
158
+ env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
159
+ stdio: ["pipe", "pipe", "pipe"],
160
+ timeout: 30_000,
161
+ maxBuffer: PACKAGE_SNAPSHOT_MAX_ENTRIES * 2_048,
162
+ });
163
+ if (listed.status !== 0)
164
+ throw new Error("authoritative package tarball cannot be listed");
165
+ const lines = listed.stdout.trimEnd() === "" ? [] : listed.stdout.trimEnd().split("\n");
166
+ if (lines.length < 1 || lines.length > PACKAGE_SNAPSHOT_MAX_ENTRIES)
167
+ throw new Error("authoritative package tarball violates its entry bound");
168
+ let totalBytes = 0;
169
+ for (const line of lines) {
170
+ const columns = line.trim().split(/\s+/);
171
+ const size = Number(columns[2]);
172
+ if (line.length > 2_048 || !["-", "d"].includes(line[0] ?? "") || !Number.isSafeInteger(size) || size < 0) {
173
+ throw new Error("authoritative package tarball listing is malformed or contains an unsupported entry");
174
+ }
175
+ totalBytes += size;
176
+ if (totalBytes > PACKAGE_SNAPSHOT_EXTRACTED_MAX_BYTES)
177
+ throw new Error("authoritative package tarball exceeds its extracted byte bound");
178
+ }
179
+ }
180
+ function extractPackageBytes(bytes, temporary) {
181
+ preflightPackageBytes(bytes);
182
+ const extracted = spawnSync("tar", ["-xzf", "-", "-C", temporary], {
183
+ input: bytes,
184
+ encoding: "utf8",
185
+ stdio: ["pipe", "pipe", "pipe"],
186
+ timeout: 30_000,
187
+ maxBuffer: 65_536,
188
+ });
189
+ if (extracted.status !== 0)
190
+ throw new Error("authoritative package tarball cannot be extracted");
191
+ const topLevel = fs.readdirSync(temporary, { withFileTypes: true });
192
+ if (topLevel.length !== 1 || topLevel[0]?.name !== "package" || !topLevel[0].isDirectory() || topLevel[0].isSymbolicLink()) {
193
+ throw new Error("authoritative package tarball has an invalid package root");
194
+ }
195
+ return path.join(temporary, "package");
196
+ }
197
+ function snapshotMarker(artifact, tree) {
198
+ const unsigned = {
199
+ schemaVersion: PACKAGE_SNAPSHOT_SCHEMA,
200
+ packageArtifact: artifact,
201
+ tarballTree: { count: tree.entries.length, digest: tree.digest, fileCount: tree.fileCount, totalBytes: tree.totalBytes },
202
+ };
203
+ return { ...unsigned, snapshotDigest: observationDigest(unsigned) };
204
+ }
205
+ function writeRetainedPackageSnapshot(directory, bytes, packageRoot, artifact, tree) {
206
+ const parent = path.dirname(path.resolve(directory));
207
+ fs.mkdirSync(parent, { recursive: true, mode: 0o700 });
208
+ const parentReal = fs.realpathSync(parent);
209
+ const target = path.join(parentReal, path.basename(directory));
210
+ if (path.resolve(directory) !== target || fs.existsSync(target))
211
+ throw new Error("retained package snapshot target is not a new direct child of its parent");
212
+ const staging = `${target}.${process.pid}.tmp`;
213
+ fs.mkdirSync(staging, { mode: 0o700 });
214
+ try {
215
+ fs.writeFileSync(path.join(staging, "package.tgz"), bytes, { flag: "wx", mode: 0o600 });
216
+ fs.cpSync(packageRoot, path.join(staging, "extracted"), { recursive: true, verbatimSymlinks: true });
217
+ const marker = snapshotMarker(artifact, tree);
218
+ const markerBytes = `${canonicalObservationJson(marker)}\n`;
219
+ if (Buffer.byteLength(markerBytes, "utf8") > PACKAGE_SNAPSHOT_MARKER_MAX_BYTES)
220
+ throw new Error("retained package snapshot marker exceeds its byte bound");
221
+ fs.writeFileSync(path.join(staging, "snapshot.json"), markerBytes, { flag: "wx", mode: 0o600 });
222
+ fs.renameSync(staging, target);
223
+ }
224
+ finally {
225
+ fs.rmSync(staging, { recursive: true, force: true });
226
+ }
227
+ }
228
+ export function observeCurrentPackageArtifact(tarball, extractedRoot, snapshotDirectory) {
229
+ const bytes = readBoundedRegularFile(tarball, PACKAGE_SNAPSHOT_TARBALL_MAX_BYTES);
230
+ const packageArtifact = {
231
+ ...packageArtifactIdentity(path.basename(tarball), bytes),
232
+ };
233
+ const extractedTree = completeTreeObservation(extractedRoot, { allowSymlinks: true });
234
+ const temporary = fs.mkdtempSync(path.join(process.env.TMPDIR ?? os.tmpdir(), "activation-tarball-tree-"));
235
+ let tarballTree;
236
+ try {
237
+ const packageRoot = extractPackageBytes(bytes, temporary);
238
+ tarballTree = completeTreeObservation(packageRoot, { allowSymlinks: false });
239
+ if (snapshotDirectory)
240
+ writeRetainedPackageSnapshot(snapshotDirectory, bytes, packageRoot, packageArtifact, tarballTree);
241
+ }
242
+ finally {
243
+ fs.rmSync(temporary, { recursive: true, force: true });
244
+ }
245
+ const runtimeSupportPaths = extractedTree.entries
246
+ .filter((entry) => entry.path === "node_modules" && entry.type === "symlink")
247
+ .map((entry) => entry.path);
248
+ const extractedPayload = extractedTree.entries.filter((entry) => !runtimeSupportPaths.includes(entry.path));
249
+ if (canonicalObservationJson(extractedPayload) !== canonicalObservationJson(tarballTree.entries)) {
250
+ throw new Error("authoritative extracted package tree does not exactly match the current tarball payload");
251
+ }
252
+ return { ...packageArtifact, extractedTree, tarballTree, runtimeSupportPaths };
253
+ }
254
+ function packageSnapshotRootViolations(snapshotRoot, expectedIdentity, allowedRoot) {
255
+ const invalid = "retained package snapshot differs from the independently retained package identity";
256
+ if (activationPackageIdentityViolations(expectedIdentity).length > 0)
257
+ return [invalid];
258
+ const identity = expectedIdentity;
259
+ let temporary;
260
+ try {
261
+ const snapshotStat = fs.lstatSync(snapshotRoot);
262
+ if (!snapshotStat.isDirectory() || snapshotStat.isSymbolicLink())
263
+ return [invalid];
264
+ const snapshotReal = fs.realpathSync(snapshotRoot);
265
+ if (snapshotReal !== path.resolve(snapshotRoot))
266
+ return [invalid];
267
+ if (allowedRoot) {
268
+ const rootStat = fs.lstatSync(allowedRoot);
269
+ if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
270
+ return [invalid];
271
+ const rootReal = fs.realpathSync(allowedRoot);
272
+ if (snapshotReal !== path.join(rootReal, PACKAGE_SNAPSHOT_DIRECTORY))
273
+ return [invalid];
274
+ }
275
+ const entries = fs.readdirSync(snapshotReal, { withFileTypes: true });
276
+ if (entries.map((entry) => entry.name).sort().join("\0") !== ["extracted", "package.tgz", "snapshot.json"].join("\0")
277
+ || entries.some((entry) => entry.isSymbolicLink()))
278
+ return [invalid];
279
+ const markerBytes = readBoundedRegularFile(path.join(snapshotReal, "snapshot.json"), PACKAGE_SNAPSHOT_MARKER_MAX_BYTES);
280
+ const marker = JSON.parse(markerBytes.toString("utf8"));
281
+ const { snapshotDigest, ...unsignedMarker } = marker;
282
+ if (Object.keys(marker).sort().join("\0") !== ["packageArtifact", "schemaVersion", "snapshotDigest", "tarballTree"].join("\0")
283
+ || Object.keys(marker.packageArtifact ?? {}).sort().join("\0") !== ["filename", "integrity", "shasum", "tarballSha256"].join("\0")
284
+ || Object.keys(marker.tarballTree ?? {}).sort().join("\0") !== ["count", "digest", "fileCount", "totalBytes"].join("\0")
285
+ || marker.schemaVersion !== PACKAGE_SNAPSHOT_SCHEMA || snapshotDigest !== observationDigest(unsignedMarker))
286
+ return [invalid];
287
+ const tarballBytes = readBoundedRegularFile(path.join(snapshotReal, "package.tgz"), PACKAGE_SNAPSHOT_TARBALL_MAX_BYTES);
288
+ const artifact = packageArtifactIdentity(identity.packageArtifact.filename, tarballBytes);
289
+ const extractedTree = completeTreeObservation(path.join(snapshotReal, "extracted"), { allowSymlinks: false });
290
+ temporary = fs.mkdtempSync(path.join(process.env.TMPDIR ?? os.tmpdir(), "activation-snapshot-check-"));
291
+ const reextractedRoot = extractPackageBytes(tarballBytes, temporary);
292
+ const tarballTree = completeTreeObservation(reextractedRoot, { allowSymlinks: false });
293
+ const treeSummary = { count: tarballTree.entries.length, digest: tarballTree.digest };
294
+ if (canonicalObservationJson(artifact) !== canonicalObservationJson(identity.packageArtifact)
295
+ || canonicalObservationJson(treeSummary) !== canonicalObservationJson(identity.tarballTree)
296
+ || canonicalObservationJson(extractedTree.entries) !== canonicalObservationJson(tarballTree.entries)
297
+ || canonicalObservationJson(marker.packageArtifact) !== canonicalObservationJson(identity.packageArtifact)
298
+ || marker.tarballTree.count !== tarballTree.entries.length
299
+ || marker.tarballTree.digest !== tarballTree.digest
300
+ || marker.tarballTree.fileCount !== tarballTree.fileCount
301
+ || marker.tarballTree.totalBytes !== tarballTree.totalBytes)
302
+ return [invalid];
303
+ return [];
304
+ }
305
+ catch {
306
+ return [invalid];
307
+ }
308
+ finally {
309
+ if (temporary)
310
+ fs.rmSync(temporary, { recursive: true, force: true });
311
+ }
312
+ }
313
+ export function retainedPackageSnapshotViolations(generationRoot, expectedIdentity) {
314
+ return packageSnapshotRootViolations(path.join(path.resolve(generationRoot), PACKAGE_SNAPSHOT_DIRECTORY), expectedIdentity, generationRoot);
315
+ }
316
+ export function installRetainedPackageSnapshot(sourceSnapshot, generationRoot, expectedIdentity) {
317
+ const sourceViolations = packageSnapshotRootViolations(sourceSnapshot, expectedIdentity);
318
+ if (sourceViolations.length > 0)
319
+ throw new Error(sourceViolations[0]);
320
+ const generationStat = fs.lstatSync(generationRoot);
321
+ if (!generationStat.isDirectory() || generationStat.isSymbolicLink())
322
+ throw new Error("authoritative generation root is not a regular directory");
323
+ const generationReal = fs.realpathSync(generationRoot);
324
+ if (generationReal !== path.resolve(generationRoot))
325
+ throw new Error("authoritative generation root realpath drifted");
326
+ const target = path.join(generationReal, PACKAGE_SNAPSHOT_DIRECTORY);
327
+ if (!fs.existsSync(target)) {
328
+ const staging = `${target}.${process.pid}.tmp`;
329
+ fs.cpSync(sourceSnapshot, staging, { recursive: true, verbatimSymlinks: true, errorOnExist: true });
330
+ try {
331
+ const copiedViolations = packageSnapshotRootViolations(staging, expectedIdentity);
332
+ if (copiedViolations.length > 0)
333
+ throw new Error(copiedViolations[0]);
334
+ fs.renameSync(staging, target);
335
+ }
336
+ finally {
337
+ fs.rmSync(staging, { recursive: true, force: true });
338
+ }
339
+ }
340
+ const installedViolations = retainedPackageSnapshotViolations(generationReal, expectedIdentity);
341
+ if (installedViolations.length > 0)
342
+ throw new Error(installedViolations[0]);
343
+ return { schemaVersion: PACKAGE_SNAPSHOT_SCHEMA, path: PACKAGE_SNAPSHOT_DIRECTORY, identityDigest: expectedIdentity.identityDigest };
344
+ }
345
+ export function removeRetainedPackageSnapshot(generationRoot) {
346
+ const generationReal = fs.realpathSync(generationRoot);
347
+ const target = path.join(generationReal, PACKAGE_SNAPSHOT_DIRECTORY);
348
+ if (path.dirname(target) !== generationReal)
349
+ throw new Error("retained package snapshot cleanup escaped its generation root");
350
+ fs.rmSync(target, { recursive: true, force: true });
351
+ }
352
+ function bodyObservation(bodies) {
353
+ return {
354
+ identities: Object.keys(bodies).sort(),
355
+ bodies: Object.fromEntries(Object.entries(bodies).sort(([left], [right]) => left.localeCompare(right)).map(([id, body]) => [id, {
356
+ sha256: createHash("sha256").update(body, "utf8").digest("hex"),
357
+ bytes: Buffer.byteLength(body, "utf8"),
358
+ }])),
359
+ };
360
+ }
361
+ function registryCapabilities(file) {
362
+ const registry = JSON.parse(fs.readFileSync(file, "utf8"));
363
+ return [...(registry?.skills?.[0]?.capabilities ?? [])].sort();
364
+ }
365
+ function schemaCapabilities(root) {
366
+ return fs.readdirSync(root, { withFileTypes: true })
367
+ .filter((entry) => entry.isDirectory())
368
+ .filter((entry) => ["triggers.yaml", "artifacts.yaml", "validation.yaml", "exit.yaml"]
369
+ .every((file) => fs.existsSync(path.join(root, entry.name, "schemas", file))))
370
+ .map((entry) => entry.name)
371
+ .sort();
372
+ }
373
+ export function loadSourceCapabilityInstructions(root) {
374
+ const cacheKey = `${root}\0${activationSourceDigest(root)}`;
375
+ const cached = sourceCapabilityCache.get(cacheKey);
376
+ if (cached)
377
+ return structuredClone(cached);
378
+ const script = path.join(root, "packages/cli/scripts/observe-capability-source.mjs");
379
+ const result = spawnSync(process.execPath, [script, root], {
380
+ cwd: root,
381
+ env: process.env,
382
+ encoding: "utf8",
383
+ stdio: ["ignore", "pipe", "pipe"],
384
+ timeout: 30_000,
385
+ });
386
+ if (result.status !== 0)
387
+ throw new Error(`source capability observation failed: ${(result.stderr || result.stdout).trim()}`);
388
+ const observed = JSON.parse(result.stdout);
389
+ sourceCapabilityCache.set(cacheKey, observed);
390
+ return structuredClone(observed);
391
+ }
392
+ function sourceProjection(root) {
393
+ const parsed = loadSourceCapabilityInstructions(root);
394
+ const schemaRoot = path.join(root, "skills/agentera/capabilities");
395
+ const moduleFiles = CAPABILITY_IDS.map((id) => `packages/cli/src/capabilities/${id}/instructions.ts`);
396
+ const schemaFiles = filesBelow(root, "skills/agentera/capabilities");
397
+ return {
398
+ modules: bodyObservation(parsed.modules),
399
+ runtimeRegistry: bodyObservation(parsed.runtimeRegistry),
400
+ registry: registryCapabilities(path.join(root, "registry.json")),
401
+ routes: [...parsed.routes].sort(),
402
+ schemas: schemaCapabilities(schemaRoot),
403
+ artifacts: {
404
+ modules: artifactDigest(root, moduleFiles),
405
+ runtimeRegistry: artifactDigest(root, [...moduleFiles, "packages/cli/src/capabilities/index.ts"]),
406
+ registry: artifactDigest(root, ["registry.json"]),
407
+ routes: artifactDigest(root, ["packages/cli/src/cli/commands/capability.ts"]),
408
+ schemas: artifactDigest(root, schemaFiles),
409
+ },
410
+ };
411
+ }
412
+ function runtimeArtifactObservation(runtimeRoot, projectRoot, sourceRoot) {
413
+ const script = path.join(sourceRoot, "packages/cli/scripts/observe-runtime-artifact.mjs");
414
+ const result = spawnSync(process.execPath, [script, runtimeRoot, projectRoot], {
415
+ cwd: projectRoot,
416
+ env: process.env,
417
+ encoding: "utf8",
418
+ stdio: ["ignore", "pipe", "pipe"],
419
+ timeout: 120_000,
420
+ });
421
+ if (result.status !== 0)
422
+ throw new Error(`runtime artifact observation failed: ${(result.stderr || result.stdout).trim()}`);
423
+ const parsed = JSON.parse(result.stdout);
424
+ const registryFile = path.join(runtimeRoot, "bundle/registry.json");
425
+ const schemaRelative = "bundle/skills/agentera/capabilities";
426
+ const schemaRoot = path.join(runtimeRoot, schemaRelative);
427
+ const moduleFiles = CAPABILITY_IDS.map((id) => `dist/capabilities/${id}/instructions.js`);
428
+ return { bootstrap: parsed.bootstrap, projection: {
429
+ modules: bodyObservation(parsed.capabilities.modules),
430
+ runtimeRegistry: bodyObservation(parsed.capabilities.runtimeRegistry),
431
+ served: bodyObservation(parsed.capabilities.served),
432
+ registry: registryCapabilities(registryFile),
433
+ routes: [...parsed.capabilities.routes].sort(),
434
+ schemas: schemaCapabilities(schemaRoot),
435
+ startupProducers: parsed.capabilities.startupProducers,
436
+ artifacts: {
437
+ modules: artifactDigest(runtimeRoot, moduleFiles),
438
+ runtimeRegistry: artifactDigest(runtimeRoot, [...moduleFiles, "dist/capabilities/index.js"]),
439
+ served: artifactDigest(runtimeRoot, ["dist/bin/agentera.js"]),
440
+ registry: artifactDigest(runtimeRoot, ["bundle/registry.json"]),
441
+ routes: artifactDigest(runtimeRoot, ["dist/cli/commands/capability.js"]),
442
+ schemas: artifactDigest(runtimeRoot, filesBelow(runtimeRoot, schemaRelative)),
443
+ startupProducers: artifactDigest(runtimeRoot, ["dist/bin/agentera.js", "bundle/skills/agentera/SKILL.md"]),
444
+ },
445
+ } };
446
+ }
447
+ function runtimeProjection(runtimeRoot, projectRoot, sourceRoot) {
448
+ return runtimeArtifactObservation(runtimeRoot, projectRoot, sourceRoot).projection;
449
+ }
450
+ function createRecord(producerKind, artifactClass, artifactIdentity, artifactContentDigest, content, generation, packageIntegrity) {
451
+ return {
452
+ producerKind,
453
+ artifactClass,
454
+ artifactIdentity,
455
+ artifactContentDigest,
456
+ generation,
457
+ packageIntegrity,
458
+ content,
459
+ observationDigest: observationDigest(content),
460
+ };
461
+ }
462
+ function finishEvidence(value) {
463
+ return { ...value, evidenceDigest: observationDigest(value) };
464
+ }
465
+ function packageRecord(root) {
466
+ return loadRegistry(path.join(root, "references/adapters/package-registry.yaml"), root).get("agentera");
467
+ }
468
+ export function activationSourceDigest(root) {
469
+ const files = new Set([
470
+ "registry.json",
471
+ "references/adapters/package-registry.yaml",
472
+ "references/meta/retained-reference-authority.yaml",
473
+ "skills/agentera/capability_schema_contract.yaml",
474
+ ...ACTIVATION_CANONICAL_TUPLES.map((tuple) => tuple.owner_path),
475
+ ]);
476
+ return observationDigest([...files].sort().map((file) => ({ path: file, sha256: fs.existsSync(path.join(root, file)) ? fileSha256(path.join(root, file)) : "missing" })));
477
+ }
478
+ const runtimeAuthority = ["references", "adapters", "runtime-lifecycle-authority.yaml"].join("/");
479
+ const retiredAuthority = ["references", "adapters", "runtime-retired-resources.yaml"].join("/");
480
+ const GENERIC_SOURCE_ARTIFACTS = {
481
+ "cli.discovery": ["packages/cli/src/cli/dispatch/commands.ts"],
482
+ "cli.behavior": ["packages/cli/src/cli/dispatch/index.ts"],
483
+ "cli.diagnostics": ["packages/cli/src/cli/dispatch/projections.ts", "packages/cli/src/cli/dispatch/commands.ts"],
484
+ "cli.instructions": ["packages/cli/src/cli/help.ts"],
485
+ "cli.adversarial": ["packages/cli/src/cli/dispatch/commands.ts", "packages/cli/src/cli/errors.ts"],
486
+ "runtime.discovery": [runtimeAuthority, retiredAuthority],
487
+ "runtime.behavior": [runtimeAuthority, retiredAuthority, "packages/cli/src/runtime/nativeResourceCleanup.ts"],
488
+ "runtime.diagnostics": [retiredAuthority, "packages/cli/src/runtime/nativeResourceCleanup.ts"],
489
+ "runtime.instructions": [runtimeAuthority, retiredAuthority],
490
+ "runtime.adversarial": [runtimeAuthority, retiredAuthority],
491
+ "reference.discovery": ["references/meta/retained-reference-authority.yaml"],
492
+ "reference.behavior": ["references/meta/retained-reference-authority.yaml"],
493
+ "reference.diagnostics": ["references/meta/retained-reference-authority.yaml"],
494
+ "reference.instructions": ["references/meta/retained-reference-authority.yaml"],
495
+ "reference.adversarial": ["references/meta/retained-reference-authority.yaml"],
496
+ "state.discovery": ["packages/cli/src/state/entityListRuntimeRegistry.ts", "packages/cli/src/state/write/runtimeOperations.ts"],
497
+ "state.behavior": ["packages/cli/src/state/entityListRuntimeRegistry.ts", "packages/cli/src/state/write/runtimeOperations.ts"],
498
+ "state.diagnostics": ["packages/cli/src/state/write/runtimeOperations.ts", "packages/cli/src/state/entityListRuntimeRegistry.ts"],
499
+ "state.instructions": ["packages/cli/src/state/entityRetrievalHelp.ts", "packages/cli/src/state/write/runtimeOperations.ts"],
500
+ "state.adversarial": ["packages/cli/src/state/entityListRuntimeRegistry.ts", "packages/cli/src/state/write/runtimeOperations.ts"],
501
+ };
502
+ function genericDimensionObservation(classId, dimension, input) {
503
+ if (classId === "cli") {
504
+ if (dimension === "discovery")
505
+ return { commands: input.commands };
506
+ if (dimension === "behavior")
507
+ return { dispatchSourceDigest: observationDigest(input.dispatchSource), capabilityRoutes: input.capabilityRoutes };
508
+ if (dimension === "diagnostics")
509
+ return { diagnosticCommands: input.commands, runtimeCommands: input.runtimeDiagnosticCommands };
510
+ if (dimension === "instructions")
511
+ return { helpDigest: observationDigest(input.helpText), declaredCommands: input.declaredCommands };
512
+ return { commandClassifications: input.commands.map((command) => ({ command, safe: !/\s|[;&|]/.test(command) })) };
513
+ }
514
+ if (classId === "runtime") {
515
+ const resources = input.retired.resources;
516
+ const diagnostics = input.retired.diagnosticResources;
517
+ if (dimension === "discovery")
518
+ return { lifecycleSource: input.lifecycle.sourcePath, runtimeIds: input.lifecycle.runtimes.map((entry) => entry.id), resources: resources.map((entry) => ({ host: entry.host, id: entry.id })) };
519
+ if (dimension === "behavior")
520
+ return { hosts: resources.map((entry) => ({ host: entry.host, support: entry.hostSupportStatus, safety: entry.safetyNote })), diagnosticDestinations: diagnostics.map((entry) => ({ id: entry.id, destinations: entry.destinations })) };
521
+ if (dimension === "diagnostics")
522
+ return { durableProof: resources.map((entry) => ({ host: entry.host, proof: entry.durableProof })), diagnosticIds: diagnostics.map((entry) => ({ id: entry.id, names: entry.names })) };
523
+ if (dimension === "instructions")
524
+ return { canonicalSkillPath: input.lifecycle.canonicalSkillPath, safetyNotes: resources.map((entry) => ({ host: entry.host, safety: entry.safetyNote })) };
525
+ return { resourceShapes: resources.map((entry) => ({ host: entry.host, safe: /^[A-Za-z0-9._:-]+$/.test(entry.host) })), diagnosticShapes: diagnostics.map((entry) => ({ id: entry.id, bounded: !/[\0\r\n]/.test(entry.id) })) };
526
+ }
527
+ if (classId === "reference") {
528
+ const inventory = input.inventory;
529
+ if (dimension === "discovery")
530
+ return inventory.map((entry) => ({ path: entry.path, classification: entry.classification }));
531
+ if (dimension === "behavior")
532
+ return inventory.map((entry) => ({ path: entry.path, consumers: entry.consumers ?? null, command: entry.command ?? null }));
533
+ if (dimension === "diagnostics")
534
+ return inventory.map((entry) => ({ path: entry.path, owner: entry.production_owner ?? null, maintainer: entry.maintainer ?? null }));
535
+ if (dimension === "instructions")
536
+ return inventory.map((entry) => ({ path: entry.path, modules: (entry.consumers ?? []).map((consumer) => [consumer.module, consumer.symbol]), command: entry.command ?? null }));
537
+ return inventory.map((entry) => ({ path: entry.path, ownerShape: entry.production_owner ? [entry.production_owner.module, entry.production_owner.symbol] : null, commandSafe: entry.command ? !/[\0\r\n]/.test(entry.command) : true }));
538
+ }
539
+ const reads = input.readFamilies;
540
+ const writes = input.operations;
541
+ if (dimension === "discovery")
542
+ return { reads: reads.map((entry) => entry.key), writes: writes.map((entry) => `${entry.artifact}.${entry.verb}`) };
543
+ if (dimension === "behavior")
544
+ return { reads: reads.map((entry) => ({ key: entry.key, tokens: entry.commandTokens })), writes: writes.map((entry) => ({ id: `${entry.artifact}.${entry.verb}`, inputMode: entry.inputMode })) };
545
+ if (dimension === "diagnostics")
546
+ return { bounds: input.bounds, recovery: writes.map((entry) => ({ id: `${entry.artifact}.${entry.verb}`, recovery: entry.projection.recovery.runtime })) };
547
+ if (dimension === "instructions")
548
+ return { help: input.helpFamilies, examples: writes.map((entry) => ({ id: `${entry.artifact}.${entry.verb}`, examples: entry.projection.examples })) };
549
+ return { bounds: input.bounds, inputBounds: writes.map((entry) => ({ id: `${entry.artifact}.${entry.verb}`, bytes: entry.inputMaxBytes, formats: entry.projection.formatValues })) };
550
+ }
551
+ export function createSourceOwnerEvidence(root, productionInputs) {
552
+ const capabilities = sourceProjection(root);
553
+ const record = packageRecord(root);
554
+ const records = {
555
+ "capability.source-modules": createRecord("source-owner", "capability-source-modules", "packages/cli/src/capabilities/*/instructions.ts", capabilities.artifacts.modules, capabilities.modules, null, null),
556
+ "capability.source-runtime-registry": createRecord("source-owner", "capability-source-runtime-registry", "packages/cli/src/capabilities/index.ts#CAPABILITY_INSTRUCTIONS", capabilities.artifacts.runtimeRegistry, capabilities.runtimeRegistry, null, null),
557
+ "capability.source-registry": createRecord("source-owner", "capability-source-registry", "registry.json#skills[0].capabilities", capabilities.artifacts.registry, capabilities.registry, null, null),
558
+ "capability.source-routes": createRecord("source-owner", "capability-source-routes", "packages/cli/src/cli/commands/capability.ts#CAPABILITY_ROUTING_NAMES", capabilities.artifacts.routes, capabilities.routes, null, null),
559
+ "capability.source-schemas": createRecord("source-owner", "capability-source-schemas", "skills/agentera/capabilities/*/schemas", capabilities.artifacts.schemas, capabilities.schemas, null, null),
560
+ "package.source-registry": createRecord("source-owner", "package-source-registry", "references/adapters/package-registry.yaml#records[agentera]", artifactDigest(root, ["references/adapters/package-registry.yaml"]), packageDescriptorSemantics(packageDescriptors(record)), null, null),
561
+ "package.source-construction": createRecord("source-owner", "package-source-construction", "references/adapters/package-registry.yaml#records[agentera].bundle_surfaces", artifactDigest(root, ["references/adapters/package-registry.yaml", "packages/cli/scripts/package-construction.mjs"]), packageDescriptors(record).map(({ id, entry }) => ({ id, path: entry.path })), null, null),
562
+ "package.source-selectors": createRecord("source-owner", "package-source-selectors", "references/adapters/package-registry.yaml#records[agentera].semantic_fields", artifactDigest(root, ["references/adapters/package-registry.yaml"]), { semanticSelectors: packageDescriptorSemantics(packageDescriptors(record)) }, null, null),
563
+ "bootstrap.source-authority": createRecord("source-owner", "bootstrap-source-authority", "packages/cli/src/validate/bootstrapAuthority.ts#bootstrapMatrixAuthority", artifactDigest(root, ["packages/cli/src/validate/bootstrapAuthority.ts"]), bootstrapMatrixAuthority(), null, null),
564
+ };
565
+ if (productionInputs?.classes) {
566
+ for (const classId of ["cli", "runtime", "reference", "state"]) {
567
+ for (const dimension of ["discovery", "behavior", "diagnostics", "instructions", "adversarial"]) {
568
+ const content = productionInputs.classes[classId]?.dimensions?.[dimension];
569
+ records[`generic.${classId}.${dimension}`] = createRecord("source-owner", `${classId}-${dimension}-source-observation`, `${classId}.${dimension}`, artifactDigest(root, GENERIC_SOURCE_ARTIFACTS[`${classId}.${dimension}`] ?? []), genericDimensionObservation(classId, dimension, content), null, null);
570
+ }
571
+ }
572
+ }
573
+ return finishEvidence({
574
+ schemaVersion: SOURCE_OWNER_EVIDENCE_SCHEMA,
575
+ producerKind: "source-owner",
576
+ sourceDigest: activationSourceDigest(root),
577
+ generation: null,
578
+ packageIntegrity: null,
579
+ records,
580
+ });
581
+ }
582
+ function packageArtifactObservation(runtimeRoot, fixture, requiredFiles, snapshotDirectory) {
583
+ const tarball = path.join(fixture.root, fixture.manifest.filename);
584
+ const current = observeCurrentPackageArtifact(tarball, runtimeRoot, snapshotDirectory);
585
+ const { tarballTree, ...currentWithoutTarballEntries } = current;
586
+ const manifestFile = path.join(runtimeRoot, "package.json");
587
+ const manifestEntry = current.extractedTree.entries.find((entry) => entry.path === "package.json");
588
+ return {
589
+ ...currentWithoutTarballEntries,
590
+ tarballTree: { count: tarballTree.entries.length, digest: tarballTree.digest },
591
+ manifest: {
592
+ path: "package.json",
593
+ type: "file",
594
+ mode: manifestEntry?.mode ?? null,
595
+ contentDigest: fileSha256(manifestFile),
596
+ },
597
+ requiredSurfaces: requiredFiles.map((relative) => {
598
+ const file = path.join(runtimeRoot, relative);
599
+ const stat = fs.lstatSync(file);
600
+ return { path: relative, type: stat.isFile() ? "file" : stat.isDirectory() ? "directory" : stat.isSymbolicLink() ? "symlink" : "other", mode: stat.mode & 0o777, contentDigest: stat.isFile() ? fileSha256(file) : null };
601
+ }),
602
+ };
603
+ }
604
+ function seedObservationProject(project) {
605
+ fs.mkdirSync(path.join(project, ".agentera"), { recursive: true, mode: 0o700 });
606
+ fs.writeFileSync(path.join(project, ".agentera/state-mode.yaml"), "schemaVersion: agentera.stateMode.v1\nmode: entities\n", { flag: "wx", mode: 0o600 });
607
+ }
608
+ export async function finalizePackageOwnerEvidence(options) {
609
+ const { root, fixture, runtimeSummary } = options;
610
+ const runtimeRoot = fixture.packageRoot;
611
+ const capabilityProject = path.join(fixture.root, "activation-capability-project");
612
+ seedObservationProject(capabilityProject);
613
+ const capabilities = await runtimeProjection(runtimeRoot, capabilityProject, root);
614
+ const record = packageRecord(path.join(runtimeRoot, "bundle"));
615
+ const packageArtifact = packageArtifactObservation(runtimeRoot, fixture, options.requiredFiles, options.snapshotDirectory);
616
+ const integrity = packageArtifact.integrity;
617
+ const portability = {
618
+ constructionRootCount: fixture.pathIndependence.constructionRoots.length,
619
+ constructionRootsDistinct: new Set(fixture.pathIndependence.constructionRoots).size === fixture.pathIndependence.constructionRoots.length,
620
+ extractedRootCount: fixture.pathIndependence.extractedRoots.length,
621
+ extractedRootsDistinct: new Set(fixture.pathIndependence.extractedRoots).size === fixture.pathIndependence.extractedRoots.length,
622
+ regularFiles: fixture.pathIndependence.regularFiles,
623
+ contentSha256: fixture.pathIndependence.contentSha256,
624
+ forbiddenPathMatches: fixture.pathIndependence.forbiddenPathMatches,
625
+ pathNeedleClasses: fixture.pathIndependence.pathNeedleClasses,
626
+ secondManifest: {
627
+ filename: fixture.pathIndependence.secondManifest.filename,
628
+ integrity: fixture.pathIndependence.secondManifest.integrity,
629
+ shasum: fixture.pathIndependence.secondManifest.shasum,
630
+ files: fixture.pathIndependence.secondManifest.files,
631
+ },
632
+ };
633
+ const packageRows = runtimeSummary.rows.filter((row) => row.runtime === "package");
634
+ const rejectedRows = packageRows.filter((row) => !row.accepted);
635
+ const commandPolicy = {
636
+ rowCount: packageRows.length,
637
+ accepted: packageRows.filter((row) => row.accepted).length,
638
+ rejected: rejectedRows.length,
639
+ classifications: Object.fromEntries([...new Set(packageRows.map((row) => row.classification))].sort().map((classification) => [classification, packageRows.filter((row) => row.classification === classification).length])),
640
+ compositeIdentityDigest: observationDigest(packageRows.map((row) => `${row.runtime}/${row.projectState}/${row.id}`).sort()),
641
+ };
642
+ const adversarial = {
643
+ rowCount: rejectedRows.length,
644
+ allBlockedBeforeChildStart: rejectedRows.every((row) => row.childStarted === false),
645
+ classifications: Object.fromEntries([...new Set(rejectedRows.map((row) => row.classification))].sort().map((classification) => [classification, rejectedRows.filter((row) => row.classification === classification).length])),
646
+ };
647
+ const records = {
648
+ "capability.extracted-modules": createRecord("package-owner", "capability-extracted-modules", "package/dist/capabilities/*/instructions.js", capabilities.artifacts.modules, capabilities.modules, null, integrity),
649
+ "capability.extracted-runtime-registry": createRecord("package-owner", "capability-extracted-runtime-registry", "package/dist/capabilities/index.js#CAPABILITY_INSTRUCTIONS", capabilities.artifacts.runtimeRegistry, capabilities.runtimeRegistry, null, integrity),
650
+ "capability.extracted-served": createRecord("package-owner", "capability-extracted-served", "package/dist/bin/agentera.js#prime-context", capabilities.artifacts.served, capabilities.served, null, integrity),
651
+ "capability.extracted-registry": createRecord("package-owner", "capability-extracted-registry", "package/bundle/registry.json#skills[0].capabilities", capabilities.artifacts.registry, capabilities.registry, null, integrity),
652
+ "capability.extracted-routes": createRecord("package-owner", "capability-extracted-routes", "package/dist/cli/commands/capability.js#CAPABILITY_ROUTING_NAMES", capabilities.artifacts.routes, capabilities.routes, null, integrity),
653
+ "capability.extracted-schemas": createRecord("package-owner", "capability-extracted-schemas", "package/bundle/skills/agentera/capabilities/*/schemas", capabilities.artifacts.schemas, capabilities.schemas, null, integrity),
654
+ "package.extracted-artifact": createRecord("package-owner", "package-extracted-artifact", "npm-tarball/extracted-package", observationDigest(packageArtifact), packageArtifact, null, integrity),
655
+ "package.extracted-registry": createRecord("package-owner", "package-extracted-registry", "package/bundle/references/adapters/package-registry.yaml#records[agentera]", artifactDigest(runtimeRoot, ["bundle/references/adapters/package-registry.yaml"]), packageDescriptorSemantics(packageDescriptors(record)), null, integrity),
656
+ "package.command-policy": createRecord("package-owner", "package-command-policy", "package/runtime-matrix/classifications", observationDigest(packageRows), commandPolicy, null, integrity),
657
+ "package.portability": createRecord("package-owner", "package-portability", "npm-tarball/path-portability", fixture.pathIndependence.contentSha256, portability, null, integrity),
658
+ "package.adversarial": createRecord("package-owner", "package-adversarial", "package/runtime-matrix/rejections", observationDigest(rejectedRows), adversarial, null, integrity),
659
+ "bootstrap.extracted-classifications": createRecord("package-owner", "bootstrap-extracted-classifications", "package/runtime-matrix/rows", observationDigest(packageRows), packageRows, null, integrity),
660
+ "bootstrap.extracted-diagnostics": createRecord("package-owner", "bootstrap-extracted-diagnostics", "package/runtime-matrix/rejection-diagnostics", observationDigest(rejectedRows), rejectedRows, null, integrity),
661
+ "bootstrap.extracted-startup": createRecord("package-owner", "bootstrap-extracted-startup", "package/dist/bin/agentera.js#startup-producers", capabilities.artifacts.startupProducers, capabilities.startupProducers, null, integrity),
662
+ "bootstrap.extracted-declarations": createRecord("package-owner", "bootstrap-extracted-declarations", "package/bundle/references/adapters/package-registry.yaml#bootstrap_command_authority", artifactDigest(runtimeRoot, ["bundle/references/adapters/package-registry.yaml"]), packageCommandDeclarations(record), null, integrity),
663
+ "bootstrap.source-package-parity": createRecord("package-owner", "bootstrap-source-package-parity", "package/runtime-matrix/parity", observationDigest(runtimeSummary.runtimeObservationDigests ?? {}), runtimeSummary.runtimeObservationDigests ?? {}, null, integrity),
664
+ "bootstrap.missing-surface": createRecord("package-owner", "bootstrap-missing-surface", "package/runtime-matrix/missing-required-surfaces", observationDigest(options.missingSurfaceResults), options.missingSurfaceResults, null, integrity),
665
+ };
666
+ for (const classId of ["runtime", "reference", "state"]) {
667
+ const relative = classId === "runtime"
668
+ ? [["bundle", "references", "adapters", "runtime-lifecycle-authority.yaml"].join("/"), ["bundle", "references", "adapters", "runtime-retired-resources.yaml"].join("/")]
669
+ : classId === "reference"
670
+ ? ["bundle/references/meta/retained-reference-authority.yaml"]
671
+ : ["dist/state/entityListRuntimeRegistry.js", "dist/state/write/runtimeOperations.js", "dist/state/write/operations.js"];
672
+ records[`generic.${classId}.package_projection`] = createRecord("package-owner", `${classId}-package-projection`, `package/${classId}/projection`, artifactDigest(runtimeRoot, relative), relative.map((file) => ({ file, sha256: fs.existsSync(path.join(runtimeRoot, file)) ? fileSha256(path.join(runtimeRoot, file)) : "missing" })), null, integrity);
673
+ }
674
+ const evidence = finishEvidence({
675
+ schemaVersion: PACKAGE_OWNER_EVIDENCE_SCHEMA,
676
+ producerKind: "package-owner",
677
+ sourceDigest: activationSourceDigest(root),
678
+ generation: null,
679
+ packageIntegrity: integrity,
680
+ records,
681
+ });
682
+ const unsignedIdentity = {
683
+ schemaVersion: PACKAGE_IDENTITY_SCHEMA,
684
+ packageEvidenceDigest: evidence.evidenceDigest,
685
+ packageArtifact: {
686
+ filename: packageArtifact.filename,
687
+ integrity: packageArtifact.integrity,
688
+ shasum: packageArtifact.shasum,
689
+ tarballSha256: packageArtifact.tarballSha256,
690
+ },
691
+ packageArtifactObservationDigest: records["package.extracted-artifact"].observationDigest,
692
+ extractedTree: { count: packageArtifact.extractedTree.entries.length, digest: packageArtifact.extractedTree.digest },
693
+ tarballTree: { count: packageArtifact.tarballTree.count, digest: packageArtifact.tarballTree.digest },
694
+ };
695
+ return { evidence, packageIdentity: { ...unsignedIdentity, identityDigest: observationDigest(unsignedIdentity) } };
696
+ }
697
+ export function createGeneratedOwnerEvidence(options) {
698
+ const project = fs.mkdtempSync(path.join(process.env.TMPDIR ?? options.generationRoot, "activation-generated-project-"));
699
+ seedObservationProject(project);
700
+ let runtimeObservation;
701
+ try {
702
+ runtimeObservation = runtimeArtifactObservation(options.generationRoot, project, options.root);
703
+ }
704
+ finally {
705
+ fs.rmSync(project, { recursive: true, force: true });
706
+ }
707
+ const capabilities = runtimeObservation.projection;
708
+ const bundleRoot = path.join(options.generationRoot, "bundle");
709
+ const record = packageRecord(bundleRoot);
710
+ const bootstrap = runtimeObservation.bootstrap;
711
+ const generationFiles = [".agentera-generation.json", "dist/.agentera-generation.json", "bundle/.agentera-generation.json", "bundle/.agentera-npx-bundle.json", "bundle/extract-corpus-parity.json"]
712
+ .filter((file) => fs.existsSync(path.join(options.generationRoot, file)));
713
+ const records = {
714
+ "capability.generated-modules": createRecord("generated-owner", "capability-generated-modules", "generation/dist/capabilities/*/instructions.js", capabilities.artifacts.modules, capabilities.modules, options.generation, null),
715
+ "capability.generated-runtime-registry": createRecord("generated-owner", "capability-generated-runtime-registry", "generation/dist/capabilities/index.js#CAPABILITY_INSTRUCTIONS", capabilities.artifacts.runtimeRegistry, capabilities.runtimeRegistry, options.generation, null),
716
+ "capability.generated-served": createRecord("generated-owner", "capability-generated-served", "generation/dist/bin/agentera.js#prime-context", capabilities.artifacts.served, capabilities.served, options.generation, null),
717
+ "capability.generated-registry": createRecord("generated-owner", "capability-generated-registry", "generation/bundle/registry.json#skills[0].capabilities", capabilities.artifacts.registry, capabilities.registry, options.generation, null),
718
+ "capability.generated-routes": createRecord("generated-owner", "capability-generated-routes", "generation/dist/cli/commands/capability.js#CAPABILITY_ROUTING_NAMES", capabilities.artifacts.routes, capabilities.routes, options.generation, null),
719
+ "capability.generated-schemas": createRecord("generated-owner", "capability-generated-schemas", "generation/bundle/skills/agentera/capabilities/*/schemas", capabilities.artifacts.schemas, capabilities.schemas, options.generation, null),
720
+ "package.generated-construction": createRecord("generated-owner", "package-generated-construction", "generation/package-construction-markers", artifactDigest(options.generationRoot, generationFiles), generationFiles.map((file) => ({ file, sha256: fileSha256(path.join(options.generationRoot, file)) })), options.generation, null),
721
+ "package.generated-registry": createRecord("generated-owner", "package-generated-registry", "generation/bundle/references/adapters/package-registry.yaml#records[agentera]", artifactDigest(options.generationRoot, ["bundle/references/adapters/package-registry.yaml"]), packageDescriptorSemantics(packageDescriptors(record)), options.generation, null),
722
+ "package.generated-selectors": createRecord("generated-owner", "package-generated-selectors", "generation/bundle/references/adapters/package-registry.yaml#semantic_fields", artifactDigest(options.generationRoot, ["bundle/references/adapters/package-registry.yaml"]), { semanticSelectors: packageDescriptorSemantics(packageDescriptors(record)) }, options.generation, null),
723
+ "bootstrap.generated-binder": createRecord("generated-owner", "bootstrap-generated-binder", "generation/dist/core/developmentInvocation.js#bindDevelopmentInvocation", artifactDigest(options.generationRoot, ["dist/core/developmentInvocation.js", "dist/validate/bootstrapAuthority.js"]), bootstrap, options.generation, null),
724
+ "bootstrap.generated-diagnostics": createRecord("generated-owner", "bootstrap-generated-diagnostics", "generation/dist/core/developmentInvocation.js#DevelopmentInvocationError", artifactDigest(options.generationRoot, ["dist/core/developmentInvocation.js"]), bootstrap.rows.filter((row) => row.classification !== "accepted"), options.generation, null),
725
+ "bootstrap.generated-startup": createRecord("generated-owner", "bootstrap-generated-startup", "generation/dist/bin/agentera.js#startup-producers", capabilities.artifacts.startupProducers, capabilities.startupProducers, options.generation, null),
726
+ "bootstrap.generated-declarations": createRecord("generated-owner", "bootstrap-generated-declarations", "generation/bundle/references/adapters/package-registry.yaml#bootstrap_command_authority", artifactDigest(options.generationRoot, ["bundle/references/adapters/package-registry.yaml"]), packageCommandDeclarations(record), options.generation, null),
727
+ "generic.cli.package_projection": createRecord("generated-owner", "cli-package-projection", "generation/dist/cli/dispatch/projections.js", artifactDigest(options.generationRoot, ["dist/cli/dispatch/projections.js"]), options.productionInputs.classes.cli.dimensions.package_projection, options.generation, null),
728
+ };
729
+ return finishEvidence({
730
+ schemaVersion: GENERATED_OWNER_EVIDENCE_SCHEMA,
731
+ producerKind: "generated-owner",
732
+ sourceDigest: activationSourceDigest(options.root),
733
+ generation: options.generation,
734
+ packageIntegrity: null,
735
+ records,
736
+ });
737
+ }
738
+ export function writeContentAddressedOwnerEvidence(directory, evidence) {
739
+ const bytes = `${canonicalObservationJson(evidence)}\n`;
740
+ const byteLength = Buffer.byteLength(bytes, "utf8");
741
+ if (byteLength > OWNER_EVIDENCE_MAX_BYTES)
742
+ throw new Error(`activation owner evidence exceeds ${OWNER_EVIDENCE_MAX_BYTES} bytes`);
743
+ fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
744
+ const name = `${evidence.producerKind}-${evidence.evidenceDigest}.json`;
745
+ const target = path.join(directory, name);
746
+ const temporary = path.join(directory, `.${name}.${process.pid}.tmp`);
747
+ fs.writeFileSync(temporary, bytes, { flag: "wx", mode: 0o600 });
748
+ fs.renameSync(temporary, target);
749
+ return { path: target, digest: evidence.evidenceDigest, bytes: byteLength };
750
+ }
751
+ export function activationPackageIdentityViolations(identity, packageEvidence) {
752
+ if (!identity || typeof identity !== "object")
753
+ return ["trusted immutable package identity is missing or malformed"];
754
+ const actual = identity;
755
+ const { identityDigest, ...unsigned } = actual;
756
+ const violations = [];
757
+ if (Object.keys(actual).sort().join("\0") !== ["extractedTree", "identityDigest", "packageArtifact", "packageArtifactObservationDigest", "packageEvidenceDigest", "schemaVersion", "tarballTree"].join("\0")
758
+ || Object.keys(actual.packageArtifact ?? {}).sort().join("\0") !== ["filename", "integrity", "shasum", "tarballSha256"].join("\0")
759
+ || Object.keys(actual.extractedTree ?? {}).sort().join("\0") !== ["count", "digest"].join("\0")
760
+ || Object.keys(actual.tarballTree ?? {}).sort().join("\0") !== ["count", "digest"].join("\0")
761
+ || actual.schemaVersion !== PACKAGE_IDENTITY_SCHEMA
762
+ || !/^[a-f0-9]{64}$/.test(actual.packageEvidenceDigest ?? "")
763
+ || !/^[a-f0-9]{64}$/.test(actual.packageArtifactObservationDigest ?? "")
764
+ || !/^agentera-\d+\.\d+\.\d+(?:-dev\.\d+)?\.tgz$/.test(actual.packageArtifact?.filename ?? "")
765
+ || !/^sha512-[A-Za-z0-9+/]+={0,2}$/.test(actual.packageArtifact?.integrity ?? "")
766
+ || !/^[a-f0-9]{40}$/.test(actual.packageArtifact?.shasum ?? "")
767
+ || !/^[a-f0-9]{64}$/.test(actual.packageArtifact?.tarballSha256 ?? "")
768
+ || !Number.isInteger(actual.extractedTree?.count) || actual.extractedTree.count < 1
769
+ || !/^[a-f0-9]{64}$/.test(actual.extractedTree?.digest ?? "")
770
+ || !Number.isInteger(actual.tarballTree?.count) || actual.tarballTree.count < 1
771
+ || !/^[a-f0-9]{64}$/.test(actual.tarballTree?.digest ?? "")
772
+ || identityDigest !== observationDigest(unsigned)) {
773
+ violations.push("trusted immutable package identity is missing or malformed");
774
+ }
775
+ if (packageEvidence) {
776
+ const artifact = packageEvidence.records?.["package.extracted-artifact"];
777
+ const content = artifact?.content;
778
+ if (packageEvidence.evidenceDigest !== actual.packageEvidenceDigest
779
+ || artifact?.observationDigest !== actual.packageArtifactObservationDigest
780
+ || canonicalObservationJson({
781
+ filename: content?.filename,
782
+ integrity: content?.integrity,
783
+ shasum: content?.shasum,
784
+ tarballSha256: content?.tarballSha256,
785
+ }) !== canonicalObservationJson(actual.packageArtifact)
786
+ || content?.extractedTree?.entries?.length !== actual.extractedTree?.count
787
+ || content?.extractedTree?.digest !== actual.extractedTree?.digest
788
+ || content?.tarballTree?.count !== actual.tarballTree?.count
789
+ || content?.tarballTree?.digest !== actual.tarballTree?.digest) {
790
+ violations.push("package-owner evidence differs from the independently retained package identity");
791
+ }
792
+ }
793
+ return [...new Set(violations)];
794
+ }
795
+ export function writeContentAddressedPackageIdentity(directory, identity) {
796
+ const violations = activationPackageIdentityViolations(identity);
797
+ if (violations.length > 0)
798
+ throw new Error(violations[0]);
799
+ const bytes = `${canonicalObservationJson(identity)}\n`;
800
+ const byteLength = Buffer.byteLength(bytes, "utf8");
801
+ if (byteLength > PACKAGE_IDENTITY_MAX_BYTES)
802
+ throw new Error(`activation package identity exceeds ${PACKAGE_IDENTITY_MAX_BYTES} bytes`);
803
+ fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
804
+ const name = `package-identity-${identity.identityDigest}.json`;
805
+ const target = path.join(directory, name);
806
+ const temporary = path.join(directory, `.${name}.${process.pid}.tmp`);
807
+ fs.writeFileSync(temporary, bytes, { flag: "wx", mode: 0o600 });
808
+ fs.renameSync(temporary, target);
809
+ return { path: target, digest: identity.identityDigest, bytes: byteLength };
810
+ }
811
+ export function readContentAddressedPackageIdentity(directory) {
812
+ const entries = fs.existsSync(directory) ? fs.readdirSync(directory, { withFileTypes: true }) : [];
813
+ if (entries.length !== 1 || !entries[0]?.isFile() || entries[0].isSymbolicLink()) {
814
+ throw new Error("package identity is missing, duplicated, unknown, or not a regular file");
815
+ }
816
+ const file = path.join(directory, entries[0].name);
817
+ const stat = fs.statSync(file);
818
+ if (stat.size <= 0 || stat.size > PACKAGE_IDENTITY_MAX_BYTES)
819
+ throw new Error("package identity violates its byte bound");
820
+ const identity = JSON.parse(fs.readFileSync(file, "utf8"));
821
+ if (entries[0].name !== `package-identity-${identity.identityDigest}.json`
822
+ || activationPackageIdentityViolations(identity).length > 0) {
823
+ throw new Error("package identity has wrong content-addressed provenance");
824
+ }
825
+ return identity;
826
+ }
827
+ export function readContentAddressedOwnerEvidence(directory, producerKind) {
828
+ const entries = fs.existsSync(directory) ? fs.readdirSync(directory, { withFileTypes: true }) : [];
829
+ if (entries.length !== 1 || !entries[0]?.isFile() || entries[0].isSymbolicLink()) {
830
+ throw new Error(`${producerKind} evidence is missing, duplicated, unknown, or not a regular file`);
831
+ }
832
+ const file = path.join(directory, entries[0].name);
833
+ const stat = fs.statSync(file);
834
+ if (stat.size <= 0 || stat.size > OWNER_EVIDENCE_MAX_BYTES)
835
+ throw new Error(`${producerKind} evidence violates its byte bound`);
836
+ const evidence = JSON.parse(fs.readFileSync(file, "utf8"));
837
+ if (evidence.producerKind !== producerKind || entries[0].name !== `${producerKind}-${evidence.evidenceDigest}.json`) {
838
+ throw new Error(`${producerKind} evidence has wrong content-addressed provenance`);
839
+ }
840
+ const { evidenceDigest, ...unsigned } = evidence;
841
+ if (observationDigest(unsigned) !== evidenceDigest)
842
+ throw new Error(`${producerKind} evidence digest does not match its content`);
843
+ return evidence;
844
+ }