@unbrained/pm-cli 2026.11.21 → 2026.11.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/pm-developer/SKILL.md +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/register-history-maintenance.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +9 -0
- package/dist/cli-bundle/chunks/{chunk-PJXKA4QU.js → chunk-4TB5D6HL.js} +37 -37
- package/dist/cli-bundle/chunks/{chunk-WELSVDPU.js → chunk-5ZMVLWE3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +33 -0
- package/dist/cli-bundle/chunks/{chunk-JVGRFU5H.js → chunk-AR4NP5HI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XHJ3H5PL.js → chunk-B4PPFOPY.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-5647LU3A.js → chunk-B76TFRO2.js} +47 -45
- package/dist/cli-bundle/chunks/{chunk-YJEBK7HU.js → chunk-CAR2L5NW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-D6ILFXZY.js → chunk-EIGUKEV6.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XWHJIRNV.js → chunk-GTPCAJMZ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CASX6SFI.js → chunk-HC2OPETM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NCFCBKIP.js → chunk-HKUV74K3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +115 -0
- package/dist/cli-bundle/chunks/{chunk-S6HB3WL2.js → chunk-J2LABXBL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BKSVHOWI.js → chunk-J52BEBSS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NT5AKFE5.js → chunk-OJTMGDON.js} +31 -31
- package/dist/cli-bundle/chunks/{chunk-SRVTCYAU.js → chunk-TC6XLIYO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AHQB7W2H.js → chunk-U7EL3AYA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-CIKGG34F.js → chunk-X6MIWTTT.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RMIRNYRG.js → chunk-XFHPKXAE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-6QLEXRUG.js → chunk-YHVLVSEZ.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-4QBMZXKX.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-3TG636XG.js → mutation-actor-FWLYWJ37.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-LICSDNNO.js → mutation-admission-7ZDCK3G2.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-RR5KACJ3.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-WWVECKFQ.js → register-mutation-57AJQWFV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-L6HFJNWD.js → register-operations-RKWST7CU.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-K7UFG5TD.js → register-setup-CMI23PC5.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-57KH3KAC.js → stage-4KDVXC5Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YOAYY3HE.js → chunk-2ZD7275J.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-532WZV65.js → chunk-324AHXJO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +91 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QGKLRXP7.js → chunk-4JZITIJB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-CU2BRAOX.js → chunk-4KTFKSS3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +78 -0
- package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MKM5NKD7.js → chunk-BRZV7BFV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RPE6IX26.js → chunk-HDEKFSOK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LNHUE4VV.js → chunk-IWOXAUDU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-J63D6QST.js → chunk-ML3JHCC6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JMQJBZQ5.js → chunk-OPGOOP25.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XCJSHNXK.js → chunk-RE7ZWT7D.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WXMI4AV5.js → chunk-RQ252B6V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7A4QWNZX.js → chunk-URGHTTT3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IQK5NPMG.js → chunk-USPYKWQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +102 -0
- package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UOC6257J.js → chunk-WZWXGDYY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-NP72ZDXE.js → chunk-YKSLZPLT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +2 -0
- package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-2O6MLPEX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{mutation-actor-62HKR5IO.js → mutation-actor-TCYDPUGG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-X4PF2SG3.js → mutation-admission-LY73EJWM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-O7T7CXBB.js → stage-DQ7RQQ52.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +70 -58
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/fs/atomic-create.js +1 -1
- package/dist/core/fs/file-glob.js +1 -1
- package/dist/core/history/bridge.js +2 -0
- package/dist/core/history/drift-scan.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/history/history.d.ts +12 -0
- package/dist/core/history/history.js +2 -2
- package/dist/core/history/projection.js +1 -1
- package/dist/core/history/read.d.ts +9 -0
- package/dist/core/history/read.js +1 -1
- package/dist/core/history/replay.d.ts +46 -5
- package/dist/core/history/replay.js +2 -2
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
- package/dist/sdk/completion/fish.js +3 -2
- package/dist/sdk/completion/zsh.js +3 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/history/append-only-repair.d.ts +30 -0
- package/dist/sdk/history/append-only-repair.js +6 -0
- package/dist/sdk/history/maintenance.d.ts +8 -2
- package/dist/sdk/history/maintenance.js +1 -1
- package/dist/sdk/history/reanchor-refusal.js +2 -0
- package/dist/sdk/history/reseed.d.ts +15 -0
- package/dist/sdk/history/reseed.js +2 -0
- package/dist/sdk/history/salvage.d.ts +19 -8
- package/dist/sdk/history/salvage.js +5 -3
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-redact.js +1 -1
- package/dist/sdk/history-repair.d.ts +8 -2
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/item-transaction.d.ts +33 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/merge/three-way.d.ts +22 -3
- package/dist/sdk/merge/three-way.js +8 -2
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime-input.d.ts +6 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.d.ts +7 -0
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -5
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/transactions/item-finalization.js +2 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
- package/docs/COMMANDS.md +6 -2
- package/docs/HISTORY_RECOVERY.md +229 -5
- package/docs/README.md +2 -2
- package/docs/SDK.md +103 -4
- package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
- package/marketplace.json +1 -1
- package/node_modules/tar/package.json +2 -3
- package/package.json +30 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
- package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
- package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
- package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
- package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
- package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
- package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
- package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
- package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
- package/dist/sdk/agent/refusal-closure.js +0 -2
- package/dist/sdk/agent/refusal-reachability.js +0 -4
- package/dist/sdk/agent/task-transcript-contracts.js +0 -2
- package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
- package/dist/sdk/authoring.js +0 -2
- package/dist/sdk/compose.js +0 -2
- package/dist/sdk/contracts.js +0 -2
- package/dist/sdk/core-governance.js +0 -2
- package/dist/sdk/core.js +0 -2
- package/dist/sdk/corpus-shape.js +0 -2
- package/dist/sdk/define.js +0 -2
- package/dist/sdk/environment/agent-environment.js +0 -2
- package/dist/sdk/governance/artifact-ledgers.js +0 -2
- package/dist/sdk/governance/coverage-assurance.js +0 -2
- package/dist/sdk/governance/reliability.js +0 -2
- package/dist/sdk/governance.js +0 -2
- package/dist/sdk/graph/adapter.js +0 -2
- package/dist/sdk/graph/conformance.js +0 -2
- package/dist/sdk/graph/index.js +0 -2
- package/dist/sdk/graph.js +0 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/query.js +0 -2
- package/dist/sdk/relationship-migration.js +0 -2
- package/dist/sdk/testing.js +0 -8
- package/dist/sdk/workspace-recipe.js +0 -2
- package/docs/AGENT_PROVENANCE_ADR.md +0 -206
- package/docs/DEFECT_RECURRENCE.md +0 -257
- package/docs/PERFORMANCE.md +0 -204
package/dist/sdk/testing.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dbbb4176-3bf3-57b0-877f-f413dd5dcc52")}catch{}})();import{activateExtensions,deactivateExtensions,runAfterCommandHooks,runBeforeCommandHooks,runBeforeMutationHooks,runCommandHandler,runCommandOverride,runOnIndexHooks,runOnReadHooks,runOnWriteHooks,runParserOverride,runPreflightOverride,runRendererOverride,runServiceOverride}from"../core/extensions/loader.js";import{createDefaultExtensionGovernancePolicy}from"../core/extensions/extension-types.js";import{getMigrationRuntimeDefinition,resolveRegisteredSearchProvider,resolveRegisteredVectorStoreAdapter}from"../core/extensions/runtime-registrations.js";import{collectUsedExtensionCapabilities}from"../core/extensions/capability-usage.js";import{normalizeKnownExtensionCapability}from"../core/extensions/extension-capability-aliases.js";import{checkExtensionManifestCompatibility,describeExtensionBlueprint,lintExtensionBlueprint,preflightExtension}from"./compose.js";import{describeExtensionActivation}from"../core/extensions/activation-summary.js";import{lintProjectProfile}from"../core/profile/profile-lint.js";import{renderExtensionSurfaceMarkdown}from"../core/extensions/activation-summary-markdown.js";import{asPropertyRecord,resolveActivatablePropertyRecord}from"../core/shared/primitives.js";import{createExtensionCommandSdk}from"./extension-command-context.js";import{collectExtensionFlagDefinitionsForCommand,normalizeDirectExtensionCommandOptions}from"./extension/command-options.js";import{resolveDirectExtensionOptionPolicy}from"./extension/native-command-options.js";import{formatOutput,projectPrintedResult}from"../core/output/output.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolvePortableWorkspaceContext,runWithIsolatedExtensionRuntime,setActiveCommandContext,setActiveExtensionCommands,setActiveExtensionRegistrations,setActiveExtensionRenderers,setActiveExtensionServices}from"../core/extensions/index.js";import{PmClient}from"./runtime.js";import{decode,encode}from"@toon-format/toon";const ACTIVATED_COMMAND_FLAG_REGISTRATIONS=Symbol.for("pm.sdk.testing.activatedFlagRegistrations");function readActivatedFlagRegistrations(commands){return commands[ACTIVATED_COMMAND_FLAG_REGISTRATIONS]}const ACTIVATED_COMMAND_SERVICES=Symbol.for("pm.sdk.testing.activatedServices"),ACTIVATED_COMMAND_RENDERERS=Symbol.for("pm.sdk.testing.activatedRenderers");function readActivatedRenderers(commands){return commands[ACTIVATED_COMMAND_RENDERERS]}function readActivatedServices(commands){return commands[ACTIVATED_COMMAND_SERVICES]}async function admitRegisteredReadOutputResult(registrations,commands,context,outcome){if(registrations===void 0||!outcome.handled||[...registrations.commands].reverse().find(entry=>entry.command===context.command)?.read_output===void 0)return outcome;const exitCode=process.exitCode;let omittedForBudget=!1;return await runWithIsolatedExtensionRuntime(async()=>{setActiveExtensionCommands(commands),setActiveExtensionServices(readActivatedServices(commands)??null),setActiveExtensionRenderers(readActivatedRenderers(commands)??null),setActiveExtensionRegistrations(registrations),setActiveCommandContext({command:context.command,args:context.args,options:context.options,global:context.global,pm_root:context.pm_root});const global2=context.global;process.exitCode=0;try{formatOutput(projectPrintedResult(outcome.result,global2),{...global2,command:context.command,commandArgs:context.args,commandOptions:context.options,pmRoot:context.pm_root}),omittedForBudget=process.exitCode===EXIT_CODE.USAGE}finally{process.exitCode=exitCode}}),omittedForBudget&&refuseOmittedForBudget(context.command),outcome}function refuseOmittedForBudget(command){throw new PmCliError(`Read output for extension command '${command}' does not fit the requested output budget; native delivery omits the result and exits 2.`,EXIT_CODE.USAGE,{code:"output_budget_exceeded",required:"Raise outputBudget, or return fewer or smaller rows so the delivered output fits.",why:"The delivered output, including any output_format or renderer string, answers to the caller's output budget, and an infeasible budget omits the result natively.",nextSteps:["Re-run with a larger outputBudget, or without one, to inspect the full result."]})}function registeredExpectationName(expectation,legacyValue){return expectation.name??legacyValue??""}const HOOK_KIND_TO_REGISTRY_FIELD={before_command:"beforeCommand",before_mutation:"beforeMutation",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"},RUNNABLE_HOOK_KIND_TO_REGISTRY_FIELD={before_command:"beforeCommand",after_command:"afterCommand",on_read:"onRead",on_write:"onWrite",on_index:"onIndex"};function normalizeSdkIdentifier(value){return value.trim().toLowerCase()}function normalizeSdkProfileMatchKey(value){return normalizeSdkIdentifier(value).replaceAll("-","_")}function extensionNameSuffix(extensionName){return extensionName?` from extension "${extensionName}"`:""}function sortedUnique(values){return[...new Set(values)].sort((left,right)=>left.localeCompare(right))}function normalizeSdkCommandName(command){if(typeof command!="string")throw new Error('A command name string is required. Pass it via the options object, e.g. runRegisteredCommandForTest(activation, { command: "my command" }) \u2014 positional command arguments are not supported.');return command.trim().toLowerCase().split(/\s+/).filter(part=>part.length>0).join(" ")}function formatAvailable(values){return values.length>0?values.join(", "):"(none)"}function assertStringSetIncludes(actual,expected,label){const actualValues=new Set(actual??[]),missing=sortedUnique(expected.filter(value=>!actualValues.has(value)));if(missing.length>0)throw new Error(`Expected package manifest ${label} to include ${missing.join(", ")}; available: ${formatAvailable(sortedUnique(actual??[]))}`)}function collectFlagLabels(flags){const labels=new Set;for(const flag of flags)typeof flag.long=="string"&&flag.long.trim().length>0&&labels.add(flag.long.trim()),typeof flag.short=="string"&&flag.short.trim().length>0&&labels.add(flag.short.trim());return labels}function readTestExtensionManifest(module){const moduleRecord=asPropertyRecord(module);if(!moduleRecord)return{};const manifest=asPropertyRecord(moduleRecord.manifest);if(manifest)return manifest;const defaultExport=asPropertyRecord(moduleRecord.default);return asPropertyRecord(defaultExport?.manifest)||(defaultExport&&typeof moduleRecord.default!="function"&&("name"in defaultExport||"capabilities"in defaultExport)?defaultExport:typeof module!="function"&&("name"in moduleRecord||"capabilities"in moduleRecord)?moduleRecord:{})}function resolveTestExtensionName(manifest,explicitName){return explicitName??(typeof manifest.name=="string"&&manifest.name.trim().length>0?manifest.name.trim():"test-extension")}function readTestExtensionCapabilities(manifest,options){return Array.isArray(options.capabilities)?[...options.capabilities]:Array.isArray(manifest.capabilities)?manifest.capabilities.filter(capability=>typeof capability=="string"):[]}function buildSingleExtensionLoadResult(module,manifest,identity){return{disabled_by_flag:!1,roots:{global:"",project:""},configured_enabled:[],configured_disabled:[],discovered:[],effective:[],warnings:[],policy:identity.policy,failed:[],loaded:[{layer:identity.layer,directory:"",manifest_path:"",name:identity.name,version:typeof manifest.version=="string"?manifest.version:"0.0.0",entry:typeof manifest.entry=="string"?manifest.entry:"./index.js",priority:typeof manifest.priority=="number"?manifest.priority:0,entry_path:"",capabilities:identity.capabilities,manifest_version:typeof manifest.manifest_version=="number"?manifest.manifest_version:void 0,pm_min_version:typeof manifest.pm_min_version=="string"?manifest.pm_min_version:void 0,pm_max_version:typeof manifest.pm_max_version=="string"?manifest.pm_max_version:void 0,engines:manifest.engines,trusted:manifest.trusted,provenance:manifest.provenance,sandbox_profile:manifest.sandbox_profile,permissions:manifest.permissions,activation:manifest.activation,module}]}}async function activateExtensionForTest(module,options={}){const manifest=readTestExtensionManifest(module),activation=await activateExtensions(buildSingleExtensionLoadResult(module,manifest,{name:resolveTestExtensionName(manifest,options.name),layer:options.layer??"project",capabilities:readTestExtensionCapabilities(manifest,options),policy:options.policy??createDefaultExtensionGovernancePolicy()}));return Object.defineProperty(activation.commands,ACTIVATED_COMMAND_FLAG_REGISTRATIONS,{value:activation.registrations,enumerable:!1}),Object.defineProperty(activation.commands,ACTIVATED_COMMAND_SERVICES,{value:activation.services,enumerable:!1}),Object.defineProperty(activation.commands,ACTIVATED_COMMAND_RENDERERS,{value:activation.renderers,enumerable:!1}),activation}async function deactivateExtensionForTest(module,options={}){const manifest=readTestExtensionManifest(module);return deactivateExtensions(buildSingleExtensionLoadResult(module,manifest,{name:resolveTestExtensionName(manifest,options.name),layer:options.layer??"project",capabilities:readTestExtensionCapabilities(manifest,{}),policy:createDefaultExtensionGovernancePolicy()}),options.activation,options.deactivateTimeoutMs===void 0?{}:{deactivate_timeout_ms:options.deactivateTimeoutMs})}async function runRegisteredCommandForTest(commands,options){const command=normalizeSdkCommandName(options.command);if(command.length===0)throw new Error("Expected command name must be a non-empty string");if(!commands.handlers.some(entry=>entry.command===command)){const available=sortedUnique(commands.handlers.map(entry=>entry.command));throw new Error(`Expected a registered command handler for "${command}" to invoke. Available command handlers: ${formatAvailable(available)}`)}if(options.sdk!==void 0&&options.sdkFactory!==void 0)throw new TypeError("runRegisteredCommandForTest accepts sdk or sdkFactory, not both");const pmRoot=options.pmRoot??"",global2={json:!0,quiet:!0,noPager:!0,...options.global},sdk=options.sdk??options.sdkFactory?.({pmRoot,global:global2})??(pmRoot.length>0?createExtensionCommandSdk(pmRoot,new PmClient({pmRoot}),void 0,command):void 0),registrations=readActivatedFlagRegistrations(commands),handlerOptions=options.options?{...options.options}:{},context={command,args:options.args?[...options.args]:[],options:registrations===void 0?handlerOptions:normalizeDirectExtensionCommandOptions(handlerOptions,collectExtensionFlagDefinitionsForCommand(registrations,command),command,resolveDirectExtensionOptionPolicy(command)),global:global2,pm_root:pmRoot,...resolvePortableWorkspaceContext(pmRoot.length>0?pmRoot:void 0),...sdk===void 0?{}:{sdk}},outcome=await runCommandHandler(commands,context);return await admitRegisteredReadOutputResult(registrations,commands,context,outcome)}async function runRegisteredMutationGuardForTest(hooks,options){if((hooks.beforeMutation?.length??0)===0)throw new Error("Expected a registered before_mutation hook to invoke");const{actor,author,dry_run:dryRun,compensation,...context}=options.context,{resolveMutationActor}=await import("../core/extensions/mutation-actor.js"),overrides=await runBeforeMutationHooks(hooks,{...context,actor:actor??resolveMutationActor(author??"unknown"),dry_run:dryRun===!0,...compensation===void 0||dryRun===!0?{}:{compensation}});return compensation===void 0?void 0:overrides}async function runRegisteredHookForTest(hooks,options){const kind=options.kind;if(kind==="before_mutation")throw new Error("Invoke before_mutation hooks with runRegisteredMutationGuardForTest so denials and failures retain fail-closed semantics.");if((hooks[RUNNABLE_HOOK_KIND_TO_REGISTRY_FIELD[kind]]?.length??0)===0){const populatedKinds=sortedUnique(Object.keys(RUNNABLE_HOOK_KIND_TO_REGISTRY_FIELD).filter(candidateKind=>(hooks[RUNNABLE_HOOK_KIND_TO_REGISTRY_FIELD[candidateKind]]?.length??0)>0));throw new Error(`Expected a registered "${kind}" hook to invoke. Hook kinds with registrations: ${formatAvailable(populatedKinds)}`)}switch(options.kind){case"before_command":return runBeforeCommandHooks(hooks,options.context);case"after_command":return runAfterCommandHooks(hooks,options.context);case"on_read":return runOnReadHooks(hooks,options.context);case"on_write":return runOnWriteHooks(hooks,options.context);case"on_index":return runOnIndexHooks(hooks,options.context)}}async function runRegisteredParserOverrideForTest(parsers,context){const command=normalizeSdkCommandName(context.command);if(!parsers.overrides.some(entry=>entry.command===command))throw new Error(`Expected a registered parser override for command "${command}" to invoke. Available parser override commands: ${formatAvailable(sortedUnique(parsers.overrides.map(entry=>entry.command)))}`);return runParserOverride(parsers,context)}async function runRegisteredPreflightOverrideForTest(preflight,context){if(preflight.overrides.length===0)throw new Error("Expected a registered preflight override to invoke, but none are registered.");return runPreflightOverride(preflight,context)}async function runRegisteredCommandOverrideForTest(commands,context){const command=normalizeSdkCommandName(context.command);if(!commands.overrides.some(entry=>entry.command===command))throw new Error(`Expected a registered command override for command "${command}" to invoke. Available command override commands: ${formatAvailable(sortedUnique(commands.overrides.map(entry=>entry.command)))}`);return runCommandOverride(commands,context)}async function runRegisteredRendererOverrideForTest(renderers,context){if(!renderers.overrides.some(entry=>entry.format===context.format))throw new Error(`Expected a registered renderer override for format "${context.format}" to invoke. Available renderer override formats: ${formatAvailable(sortedUnique(renderers.overrides.map(entry=>entry.format)))}`);return runRendererOverride(renderers,context)}async function runRegisteredServiceOverrideForTest(services,context){if(!services.overrides.some(entry=>entry.service===context.service))throw new Error(`Expected a registered service override for service "${context.service}" to invoke. Available service override services: ${formatAvailable(sortedUnique(services.overrides.map(entry=>entry.service)))}`);return runServiceOverride(services,context)}const SEARCH_PROVIDER_OPERATION_DEFINITION_KEYS={query:["query"],embed:["embed"],embedBatch:["embedBatch","embed_batch"],queryExpansion:["queryExpansion","query_expansion"],rerank:["rerank"]};async function runRegisteredSearchProviderForTest(registrations,options){const registration=resolveRegisteredSearchProvider(registrations,options.provider);if(!registration){const available=sortedUnique(registrations.search_providers.map(entry=>entry.definition.name));throw new Error(`Expected a registered search provider "${options.provider}" to invoke. Available search providers: ${formatAvailable(available)}`)}const runtimeDefinition=registration.runtime_definition,operationFn=SEARCH_PROVIDER_OPERATION_DEFINITION_KEYS[options.operation].map(key=>runtimeDefinition[key]).find(value=>typeof value=="function");if(typeof operationFn!="function")throw new Error(`Registered search provider "${options.provider}" does not implement the "${options.operation}" operation.`);return await operationFn(options.context)}async function runRegisteredVectorStoreAdapterForTest(registrations,options){const registration=resolveRegisteredVectorStoreAdapter(registrations,options.adapter);if(!registration){const available=sortedUnique(registrations.vector_store_adapters.map(entry=>entry.definition.name));throw new Error(`Expected a registered vector store adapter "${options.adapter}" to invoke. Available vector store adapters: ${formatAvailable(available)}`)}const operationFn=registration.runtime_definition[options.operation];if(typeof operationFn!="function")throw new Error(`Registered vector store adapter "${options.adapter}" does not implement the "${options.operation}" operation.`);return await operationFn(options.context)}async function runRegisteredMigrationForTest(registrations,options){const migration=assertRegisteredMigration(registrations,{migration:options.migration,extensionName:options.extensionName}),run=getMigrationRuntimeDefinition(migration).run;if(typeof run!="function")throw new Error(`Registered migration "${options.migration}" does not implement a run function to invoke.`);const declaredStatus=migration.definition.status,context={id:migration.definition.id,command:"migration",layer:migration.layer,extension:migration.name,pm_root:options.pmRoot??"",status:(typeof declaredStatus=="string"?declaredStatus.trim().toLowerCase():"")||"pending"};return await run(context)}async function runRegisteredImporterForTest(activation,options){const importer=assertRegisteredImporter(activation.registrations,{importer:options.importer,extensionName:options.extensionName});return runRegisteredCommandForTest(activation.commands,{command:`${importer.importer} import`,args:options.args,options:options.options,global:options.global,pmRoot:options.pmRoot})}async function runRegisteredExporterForTest(activation,options){const exporter=assertRegisteredExporter(activation.registrations,{exporter:options.exporter,extensionName:options.extensionName});return runRegisteredCommandForTest(activation.commands,{command:`${exporter.exporter} export`,args:options.args,options:options.options,global:options.global,pmRoot:options.pmRoot})}function assertExtensionDeactivated(result,expectation={}){const expectedDeactivated=expectation.deactivated??1;if(result.deactivated!==expectedDeactivated)throw new Error(`Expected ${expectedDeactivated} extension${expectedDeactivated===1?"":"s"} to deactivate cleanly, but ${result.deactivated} did.`);const expectedFailed=expectation.failed??0;if(result.failed.length!==expectedFailed){const detail=result.failed.map(failure=>`${failure.layer}:${failure.name} (${failure.error})`).join(", ");throw new Error(`Expected ${expectedFailed} teardown failure${expectedFailed===1?"":"s"}, but observed ${result.failed.length}${detail.length>0?`: ${detail}`:""}.`)}return result}function assertPackageManifest(manifest,expectation){if(expectation.packageName!==void 0&&manifest.package_name!==expectation.packageName)throw new Error(`Expected package manifest package_name to be "${expectation.packageName}"; received "${manifest.package_name??"(none)"}"`);if(expectation.aliases!==void 0&&assertStringSetIncludes(manifest.aliases,expectation.aliases,"aliases"),expectation.resources!==void 0)for(const[kind,expectedPaths]of Object.entries(expectation.resources))assertStringSetIncludes(manifest.resources[kind],expectedPaths,`pm.${kind}`);return manifest}function assertRegisteredCommandContract(registrations,expectation){const expectedCommand=normalizeSdkCommandName(registeredExpectationName(expectation,expectation.command));if(expectedCommand.length===0)throw new Error("Expected command name must be a non-empty string");const commandCandidates=registrations.commands.filter(entry=>entry.command===expectedCommand),command=expectation.extensionName?commandCandidates.find(entry=>entry.name===expectation.extensionName):commandCandidates[0];if(!command){const available=registrations.commands.map(entry=>entry.command).sort((left,right)=>left.localeCompare(right)),extensionSuffix=expectation.extensionName?` from extension "${expectation.extensionName}"`:"";throw new Error(`Expected extension command "${expectedCommand}"${extensionSuffix} to be registered. Available commands: ${formatAvailable(available)}`)}if(expectation.action!==void 0&&command.action!==expectation.action)throw new Error(`Expected extension command "${expectedCommand}" action "${expectation.action}", received "${command.action}"`);if(expectation.arguments!==void 0){const actualArguments=(command.arguments??[]).map(argument=>argument.name),missingArguments=expectation.arguments.filter(argument=>!actualArguments.includes(argument));if(missingArguments.length>0)throw new Error(`Expected extension command "${expectedCommand}" arguments ${formatAvailable(expectation.arguments)}; missing ${formatAvailable(missingArguments)}; available ${formatAvailable(actualArguments)}`)}const flags=registrations.flags.filter(entry=>entry.target_command===expectedCommand&&(expectation.extensionName===void 0||entry.name===expectation.extensionName)).flatMap(entry=>entry.flags);if(expectation.flags!==void 0){const actualFlagLabels=collectFlagLabels(flags),missingFlags=expectation.flags.filter(flag=>!actualFlagLabels.has(flag));if(missingFlags.length>0)throw new Error(`Expected extension command "${expectedCommand}" flags ${formatAvailable(expectation.flags)}; missing ${formatAvailable(missingFlags)}; available ${formatAvailable([...actualFlagLabels].sort((left,right)=>left.localeCompare(right)))}`)}return{command,flags}}function assertRegisteredFlags(registrations,expectation){const expectedCommand=normalizeSdkCommandName(registeredExpectationName(expectation,expectation.targetCommand));if(expectedCommand.length===0)throw new Error("Expected target command name must be a non-empty string");const candidates=registrations.flags.filter(entry=>entry.target_command===expectedCommand);let registration;if(expectation.extensionName)registration=candidates.find(entry=>entry.name===expectation.extensionName);else if(candidates.length===1)registration=candidates[0];else if(candidates.length>1){const availableExtensions=sortedUnique(candidates.map(entry=>entry.name));throw new Error(`Expected flags for target command "${expectedCommand}" matched multiple extensions: ${formatAvailable(availableExtensions)}. Specify extensionName to choose one registration.`)}if(!registration){const available=sortedUnique(registrations.flags.map(entry=>entry.target_command)),availableExtensions=sortedUnique(candidates.map(entry=>entry.name));throw new Error(`Expected flags for target command "${expectedCommand}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available flag target commands: ${formatAvailable(available)}; matching extensions: ${formatAvailable(availableExtensions)}`)}if(expectation.flags!==void 0){const actualFlagLabels=collectFlagLabels(registration.flags),missingFlags=expectation.flags.filter(flag=>!actualFlagLabels.has(flag));if(missingFlags.length>0)throw new Error(`Expected flags for target command "${expectedCommand}" to include ${formatAvailable(expectation.flags)}; missing ${formatAvailable(missingFlags)}; available ${formatAvailable([...actualFlagLabels].sort((left,right)=>left.localeCompare(right)))}`)}return registration}function assertRegisteredHook(hooks,expectation){const field=HOOK_KIND_TO_REGISTRY_FIELD[expectation.kind],candidates=hooks[field]??[],hook=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!hook){const available=sortedUnique(candidates.map(entry=>entry.name));throw new Error(`Expected a "${expectation.kind}" hook${extensionNameSuffix(expectation.extensionName)} to be registered. Available "${expectation.kind}" hooks: ${formatAvailable(available)}`)}return hook}function assertRegisteredSearchProvider(registrations,expectation){const expectedProvider=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.provider));if(expectedProvider.length===0)throw new Error("Expected search provider name must be a non-empty string");const candidates=registrations.search_providers.filter(entry=>normalizeSdkIdentifier(entry.definition.name)===expectedProvider),provider=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!provider){const available=sortedUnique(registrations.search_providers.map(entry=>entry.definition.name));throw new Error(`Expected search provider "${expectedProvider}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available search providers: ${formatAvailable(available)}`)}return provider}function assertRegisteredVectorStoreAdapter(registrations,expectation){const expectedAdapter=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.adapter));if(expectedAdapter.length===0)throw new Error("Expected vector store adapter name must be a non-empty string");const candidates=registrations.vector_store_adapters.filter(entry=>normalizeSdkIdentifier(entry.definition.name)===expectedAdapter),adapter=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!adapter){const available=sortedUnique(registrations.vector_store_adapters.map(entry=>entry.definition.name));throw new Error(`Expected vector store adapter "${expectedAdapter}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available vector store adapters: ${formatAvailable(available)}`)}return adapter}function assertRegisteredImporter(registrations,expectation){const expectedImporter=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.importer));if(expectedImporter.length===0)throw new Error("Expected importer name must be a non-empty string");const candidates=registrations.importers.filter(entry=>normalizeSdkIdentifier(entry.importer)===expectedImporter),importer=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!importer){const available=sortedUnique(registrations.importers.map(entry=>entry.importer));throw new Error(`Expected importer "${expectedImporter}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available importers: ${formatAvailable(available)}`)}return importer}function assertRegisteredExporter(registrations,expectation){const expectedExporter=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.exporter));if(expectedExporter.length===0)throw new Error("Expected exporter name must be a non-empty string");const candidates=registrations.exporters.filter(entry=>normalizeSdkIdentifier(entry.exporter)===expectedExporter),exporter=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!exporter){const available=sortedUnique(registrations.exporters.map(entry=>entry.exporter));throw new Error(`Expected exporter "${expectedExporter}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available exporters: ${formatAvailable(available)}`)}return exporter}function assertRegisteredItemField(registrations,expectation){const expectedField=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.field));if(expectedField.length===0)throw new Error("Expected item field name must be a non-empty string");const match=registrations.item_fields.filter(entry=>expectation.extensionName===void 0||entry.name===expectation.extensionName).map(registration=>({registration,field:registration.fields.find(field=>normalizeSdkIdentifier(field.name)===expectedField)})).filter(entry=>entry.field!==void 0).find(entry=>expectation.type===void 0||entry.field.type===expectation.type);if(!match){const available=sortedUnique(registrations.item_fields.flatMap(entry=>entry.fields.map(field=>`${field.name}:${field.type}`)));throw new Error(`Expected item field "${expectedField}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available item fields: ${formatAvailable(available)}`)}return match}function assertRegisteredItemType(registrations,expectation){const expectedType=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.itemType));if(expectedType.length===0)throw new Error("Expected item type name must be a non-empty string");const match=registrations.item_types.filter(entry=>expectation.extensionName===void 0||entry.name===expectation.extensionName).map(registration=>({registration,itemType:registration.types.find(itemType=>normalizeSdkIdentifier(itemType.name)===expectedType)})).filter(entry=>entry.itemType!==void 0).find(entry=>expectation.folder===void 0||entry.itemType.folder===expectation.folder);if(!match){const available=sortedUnique(registrations.item_types.flatMap(entry=>entry.types.map(itemType=>`${itemType.name}:${itemType.folder}`)));throw new Error(`Expected item type "${expectedType}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available item types: ${formatAvailable(available)}`)}return match}function assertRegisteredProfile(registrations,expectation){const expectedProfile=normalizeSdkProfileMatchKey(registeredExpectationName(expectation,expectation.profile));if(expectedProfile.length===0)throw new Error("Expected profile name must be a non-empty string");const match=registrations.profiles.filter(entry=>expectation.extensionName===void 0||entry.name===expectation.extensionName).find(entry=>normalizeSdkProfileMatchKey(entry.profile.name)===expectedProfile);if(!match){const available=sortedUnique(registrations.profiles.map(entry=>entry.profile.name));throw new Error(`Expected profile "${expectedProfile}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available profiles: ${formatAvailable(available)}`)}return{registration:match,profile:match.profile}}function assertRegisteredCommandOverride(commands,expectation){const expectedCommand=normalizeSdkCommandName(registeredExpectationName(expectation,expectation.command));if(expectedCommand.length===0)throw new Error("Expected command name must be a non-empty string");const candidates=commands.overrides.filter(entry=>entry.command===expectedCommand),override=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!override){const available=sortedUnique(commands.overrides.map(entry=>entry.command));throw new Error(`Expected command override "${expectedCommand}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available command overrides: ${formatAvailable(available)}`)}return override}function assertRegisteredParserOverride(parsers,expectation){const expectedCommand=normalizeSdkCommandName(registeredExpectationName(expectation,expectation.command));if(expectedCommand.length===0)throw new Error("Expected command name must be a non-empty string");const candidates=parsers.overrides.filter(entry=>entry.command===expectedCommand),override=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!override){const available=sortedUnique(parsers.overrides.map(entry=>entry.command));throw new Error(`Expected parser override "${expectedCommand}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available parser overrides: ${formatAvailable(available)}`)}return override}function assertRegisteredPreflightOverride(preflight,expectation={}){const override=expectation.extensionName?preflight.overrides.find(entry=>entry.name===expectation.extensionName):preflight.overrides[0];if(!override){const available=sortedUnique(preflight.overrides.map(entry=>entry.name));throw new Error(`Expected a preflight override${extensionNameSuffix(expectation.extensionName)} to be registered. Available preflight overrides: ${formatAvailable(available)}`)}return override}function assertRegisteredRendererOverride(renderers,expectation){const expectedFormat=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.format));if(expectedFormat.length===0)throw new Error("Expected renderer format must be a non-empty string");const candidates=renderers.overrides.filter(entry=>entry.format===expectedFormat),override=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!override){const available=sortedUnique(renderers.overrides.map(entry=>entry.format));throw new Error(`Expected renderer override "${expectedFormat}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available renderer overrides: ${formatAvailable(available)}`)}return override}function assertRegisteredServiceOverride(services,expectation){const expectedService=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.service));if(expectedService.length===0)throw new Error("Expected service name must be a non-empty string");const candidates=services.overrides.filter(entry=>normalizeSdkIdentifier(entry.service)===expectedService),override=expectation.extensionName?candidates.find(entry=>entry.name===expectation.extensionName):candidates[0];if(!override){const available=sortedUnique(services.overrides.map(entry=>entry.service));throw new Error(`Expected service override "${expectedService}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available service overrides: ${formatAvailable(available)}`)}return override}function assertRegisteredMigration(registrations,expectation){const expectedMigration=normalizeSdkIdentifier(registeredExpectationName(expectation,expectation.migration));if(expectedMigration.length===0)throw new Error("Expected migration id must be a non-empty string");const candidates=registrations.migrations.filter(entry=>(expectation.extensionName===void 0||entry.name===expectation.extensionName)&&typeof entry.definition.id=="string"&&normalizeSdkIdentifier(entry.definition.id)===expectedMigration),match=candidates.find(entry=>expectation.mandatory===void 0||(entry.definition.mandatory??!1)===expectation.mandatory);if(match)return match;const idMatch=candidates[0];if(idMatch!==void 0)throw new Error(`Expected migration "${expectedMigration}"${extensionNameSuffix(expectation.extensionName)} to have mandatory=${expectation.mandatory}, but it is mandatory=${idMatch.definition.mandatory??!1}.`);const available=sortedUnique(registrations.migrations.map(entry=>`${typeof entry.definition.id=="string"&&entry.definition.id.trim().length>0?entry.definition.id.trim():"(unnamed)"}:${entry.definition.mandatory===!0}`));throw new Error(`Expected migration "${expectedMigration}"${extensionNameSuffix(expectation.extensionName)} to be registered. Available migrations: ${formatAvailable(available)}`)}function assertExtensionCapabilityUsage(activation,expectation){const toKnownCapabilitySet=(capabilities,field)=>{const known=new Set;for(const capability of capabilities){const normalized=normalizeKnownExtensionCapability(capability);if(normalized===null)throw new Error(`Expected ${field} capability "${capability}" to be a known extension capability. Use canonical capability names (see manifest.capabilities).`);known.add(normalized)}return known},declared=[...toKnownCapabilitySet(expectation.declared,"declared")].sort((left,right)=>left.localeCompare(right)),allowUnused=toKnownCapabilitySet(expectation.allowUnused??[],"allowUnused"),used=collectUsedExtensionCapabilities(activation,{extensionName:expectation.extensionName}),usedSet=new Set(used),unused=declared.filter(capability=>!usedSet.has(capability)&&!allowUnused.has(capability));if(unused.length>0){const scopeSuffix=extensionNameSuffix(expectation.extensionName);throw new Error(`Expected every declared capability${scopeSuffix} to be exercised, but [${unused.join(", ")}] ${unused.length===1?"is":"are"} declared yet never registered against. Remove ${unused.length===1?"it":"them"} from manifest.capabilities for least privilege, or pass allowUnused for capabilities registered only behind a runtime flag.`)}return{declared,used,unused}}function assertExtensionBlueprint(blueprint,options={}){const result=lintExtensionBlueprint(blueprint,options);if(!result.ok){const errors=result.findings.filter(finding=>finding.severity==="error");throw new Error(`Extension blueprint failed preflight with ${errors.length} ${errors.length===1?"error":"errors"}:
|
|
2
|
-
`+errors.map(finding=>` - [${finding.code}] ${finding.message}`).join(`
|
|
3
|
-
`))}return result}function assertProjectProfile(profile,options={}){const report=lintProjectProfile(profile),blocking=report.findings.filter(finding=>finding.severity==="error"||options.strict===!0&&finding.severity==="warning");if(blocking.length>0)throw new Error(`Project profile "${report.profile}" failed lint with ${blocking.length} ${blocking.length===1?"issue":"issues"}:
|
|
4
|
-
`+blocking.map(finding=>` - ${finding.severity} [${finding.code}] ${finding.message}`).join(`
|
|
5
|
-
`));return report}function assertExtensionManifestMatchesBlueprint(manifest,blueprint){const declaredCapabilities=Array.isArray(manifest.capabilities)?manifest.capabilities:[],result=lintExtensionBlueprint(blueprint,{declaredCapabilities}),declared=result.declared,declaredSet=new Set(declared),usedSet=new Set(result.used),missing=result.used.filter(capability=>!declaredSet.has(capability)),unused=declared.filter(capability=>!usedSet.has(capability));if(missing.length>0||unused.length>0){const parts=[];throw missing.length>0&&parts.push(`missing [${missing.join(", ")}] (the blueprint registers ${missing.length===1?"a surface":"surfaces"} requiring ${missing.length===1?"it":"them"}; activation throws extension_capability_missing)`),unused.length>0&&parts.push(`unused [${unused.join(", ")}] (declared but no surface exercises ${unused.length===1?"it":"them"}; drop for least privilege)`),new Error(`Manifest capabilities do not match the blueprint: ${parts.join("; ")}. Set capabilities to synthesizeExtensionManifest(blueprint, identity).capabilities to stay in sync.`)}return{used:result.used,declared,missing,unused,findings:result.findings}}function assertExtensionManifestCompatible(manifest,target){const result=checkExtensionManifestCompatibility(manifest,target),blocking=result.findings.filter(finding=>finding.severity==="error");if(blocking.length>0)throw new Error(`Extension manifest is not compatible with pm ${result.pmVersion}: ${blocking.map(finding=>finding.message).join("; ")}`);return result}function assertExtensionPreflight(blueprint,options={}){const report=preflightExtension(blueprint,options);if(!report.ok){const errors=report.findings.filter(finding=>finding.severity==="error");throw new Error(`Extension failed preflight with ${errors.length} ${errors.length===1?"error":"errors"}:
|
|
6
|
-
`+errors.map(finding=>` - [${finding.source}:${finding.code}] ${finding.message}`).join(`
|
|
7
|
-
`))}return report}function assertTestModuleHasActivateExport(module){if(!resolveActivatablePropertyRecord(module))throw new Error("createExtensionTestHarness received a module with no activate export. Pass the extension module (with an activate(api) function on the module or its default export) as the first argument, and options second.")}async function createExtensionTestHarness(module,options={}){assertTestModuleHasActivateExport(module);const manifest=readTestExtensionManifest(module),name=resolveTestExtensionName(manifest,options.name),layer=options.layer??"project",activation=await activateExtensionForTest(module,options);if(activation.failed.length>0){const detail=activation.failed.map(failure=>{const missingCapability=failure.trace?.missing_capability,reason=missingCapability?`${failure.error}; missing capability "${missingCapability}"`:failure.error;return`${failure.layer}:${failure.name} (${reason})`}).join(", ");throw new Error(`createExtensionTestHarness could not activate the extension cleanly: ${detail}. Declare the required capability in the manifest (or pass it via options.capabilities), or use activateExtensionForTest directly to inspect a failed activation.`)}return{module,name,layer,activation,activationSummary(describeOptions){return describeExtensionActivation(activation,describeOptions)},renderMarkdown(markdownOptions={}){const{extensionName,...renderOptions}=markdownOptions??{};return renderExtensionSurfaceMarkdown(describeExtensionActivation(activation,{extensionName}),renderOptions)},assertCommandContract(expectation){return assertRegisteredCommandContract(activation.registrations,expectation)},assertFlags(expectation){return assertRegisteredFlags(activation.registrations,expectation)},assertItemField(expectation){return assertRegisteredItemField(activation.registrations,expectation)},assertItemType(expectation){return assertRegisteredItemType(activation.registrations,expectation)},assertProfile(expectation){return assertRegisteredProfile(activation.registrations,expectation)},assertHook(expectation){return assertRegisteredHook(activation.hooks,expectation)},assertCommandOverride(expectation){return assertRegisteredCommandOverride(activation.commands,expectation)},assertParserOverride(expectation){return assertRegisteredParserOverride(activation.parsers,expectation)},assertPreflightOverride(expectation){return assertRegisteredPreflightOverride(activation.preflight,expectation)},assertRendererOverride(expectation){return assertRegisteredRendererOverride(activation.renderers,expectation)},assertServiceOverride(expectation){return assertRegisteredServiceOverride(activation.services,expectation)},assertSearchProvider(expectation){return assertRegisteredSearchProvider(activation.registrations,expectation)},assertVectorStoreAdapter(expectation){return assertRegisteredVectorStoreAdapter(activation.registrations,expectation)},assertImporter(expectation){return assertRegisteredImporter(activation.registrations,expectation)},assertExporter(expectation){return assertRegisteredExporter(activation.registrations,expectation)},assertMigration(expectation){return assertRegisteredMigration(activation.registrations,expectation)},assertCapabilityUsage(expectation){return assertExtensionCapabilityUsage(activation,expectation)},runCommand(runOptions){return runRegisteredCommandForTest(activation.commands,runOptions)},runHook(runOptions){return runRegisteredHookForTest(activation.hooks,runOptions)},runMutationGuard:(runOptions=>runRegisteredMutationGuardForTest(activation.hooks,runOptions)),runCommandOverride(context){return runRegisteredCommandOverrideForTest(activation.commands,context)},runParserOverride(context){return runRegisteredParserOverrideForTest(activation.parsers,context)},runPreflightOverride(context){return runRegisteredPreflightOverrideForTest(activation.preflight,context)},runRendererOverride(context){return runRegisteredRendererOverrideForTest(activation.renderers,context)},runServiceOverride(context){return runRegisteredServiceOverrideForTest(activation.services,context)},runSearchProvider(runOptions){return runRegisteredSearchProviderForTest(activation.registrations,runOptions)},runVectorStoreAdapter(runOptions){return runRegisteredVectorStoreAdapterForTest(activation.registrations,runOptions)},runMigration(runOptions){return runRegisteredMigrationForTest(activation.registrations,runOptions)},runImporter(runOptions){return runRegisteredImporterForTest(activation,runOptions)},runExporter(runOptions){return runRegisteredExporterForTest(activation,runOptions)},deactivate(deactivateOptions={}){return deactivateExtensionForTest(module,{name,layer,activation,deactivateTimeoutMs:deactivateOptions.deactivateTimeoutMs})}}}export{activateExtensionForTest,assertExtensionBlueprint,assertExtensionCapabilityUsage,assertExtensionDeactivated,assertExtensionManifestCompatible,assertExtensionManifestMatchesBlueprint,assertExtensionPreflight,assertPackageManifest,assertProjectProfile,assertRegisteredCommandContract,assertRegisteredCommandOverride,assertRegisteredExporter,assertRegisteredFlags,assertRegisteredHook,assertRegisteredImporter,assertRegisteredItemField,assertRegisteredItemType,assertRegisteredMigration,assertRegisteredParserOverride,assertRegisteredPreflightOverride,assertRegisteredProfile,assertRegisteredRendererOverride,assertRegisteredSearchProvider,assertRegisteredServiceOverride,assertRegisteredVectorStoreAdapter,createExtensionTestHarness,deactivateExtensionForTest,decode as decodeToon,describeExtensionActivation,describeExtensionBlueprint,encode as encodeToon,lintExtensionBlueprint,renderExtensionSurfaceMarkdown,runRegisteredCommandForTest,runRegisteredCommandOverrideForTest,runRegisteredExporterForTest,runRegisteredHookForTest,runRegisteredImporterForTest,runRegisteredMigrationForTest,runRegisteredMutationGuardForTest,runRegisteredParserOverrideForTest,runRegisteredPreflightOverrideForTest,runRegisteredRendererOverrideForTest,runRegisteredSearchProviderForTest,runRegisteredServiceOverrideForTest,runRegisteredVectorStoreAdapterForTest};
|
|
8
|
-
//# sourceMappingURL=testing.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="619dbd55-b854-5e69-b5a5-c0bcada81629")}catch{}})();import{runWithReproducibleExecution,validateReproducibleExecutionSettings}from"../core/reproducibility/context.js";const PM_WORKSPACE_RECIPE_SCHEMA="https://schema.unbrained.dev/pm/workspace-recipe/v1";function cloneAndFreezeRecipeJson(value,location){if(value===null||typeof value=="boolean"||typeof value=="string")return value;if(typeof value=="number"){if(!Number.isFinite(value))throw new Error(`Workspace recipe JSON number must be finite at ${location}`);return value}if(Array.isArray(value))return Object.freeze(value.map((entry,index)=>cloneAndFreezeRecipeJson(entry,`${location}[${index}]`)));if(typeof value!="object"||Object.getPrototypeOf(value)!==Object.prototype&&Object.getPrototypeOf(value)!==null)throw new Error(`Workspace recipe input must contain JSON values at ${location}`);return Object.freeze(Object.fromEntries(Object.entries(value).map(([key,entry])=>[key,cloneAndFreezeRecipeJson(entry,`${location}.${key}`)])))}function defineWorkspaceRecipe(recipe){if(recipe.schema!==PM_WORKSPACE_RECIPE_SCHEMA)throw new Error(`Unsupported workspace recipe schema: ${recipe.schema}`);const normalized=validateReproducibleExecutionSettings(recipe);if(recipe.operations.some(operation=>operation.action.trim().length===0||operation.input===null||Array.isArray(operation.input)))throw new Error("Workspace recipe operations require an action and object input");return Object.freeze({...normalized,operations:Object.freeze(recipe.operations.map((operation,index)=>Object.freeze({action:operation.action,input:cloneAndFreezeRecipeJson(operation.input,`operations[${index}].input`)})))})}async function runWithWorkspaceRecipe(recipe,operation){const defined=defineWorkspaceRecipe(recipe);return runWithReproducibleExecution(defined,operation)}async function executeWorkspaceRecipe(recipe,execute){return runWithWorkspaceRecipe(recipe,async()=>{const results=[];for(const[index,operation]of recipe.operations.entries())results.push(await execute(operation,index));return results})}export{PM_WORKSPACE_RECIPE_SCHEMA,defineWorkspaceRecipe,executeWorkspaceRecipe,runWithWorkspaceRecipe};
|
|
2
|
-
//# sourceMappingURL=workspace-recipe.js.map
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
# Agent Provenance ADR Amendment
|
|
2
|
-
|
|
3
|
-
Tracker reference: [pm-oskdmu](../.agents/pm/decisions/pm-oskdmu.toon).
|
|
4
|
-
Implementation lineage:
|
|
5
|
-
[pm-itsjf0](../.agents/pm/features/pm-itsjf0.toon),
|
|
6
|
-
[pm-0zcwz6](../.agents/pm/issues/pm-0zcwz6.toon),
|
|
7
|
-
[pm-1zhfls](../.agents/pm/issues/pm-1zhfls.toon),
|
|
8
|
-
[pm-pwq0g5](../.agents/pm/issues/pm-pwq0g5.toon), and
|
|
9
|
-
[pm-te6elw](../.agents/pm/tasks/pm-te6elw.toon), with bounded automatic
|
|
10
|
-
resolution and patch-free historical reads implemented by
|
|
11
|
-
[pm-ffz0a9](../.agents/pm/issues/pm-ffz0a9.toon),
|
|
12
|
-
[pm-v8gfi7](../.agents/pm/issues/pm-v8gfi7.toon), and
|
|
13
|
-
[pm-3yxwv5](../.agents/pm/issues/pm-3yxwv5.toon). Stable Claude session
|
|
14
|
-
discovery across child working directories is tracked by
|
|
15
|
-
[pm-l7m7k5](../.agents/pm/issues/pm-l7m7k5.toon). Cross-harness adapters and
|
|
16
|
-
operator-managed probe/vocabulary controls are tracked by
|
|
17
|
-
[pm-c0lrdm](../.agents/pm/features/pm-c0lrdm.toon) and
|
|
18
|
-
[pm-yds9dt](../.agents/pm/chores/pm-yds9dt.toon).
|
|
19
|
-
|
|
20
|
-
Status: accepted amendment to
|
|
21
|
-
[pm-qwuber](../.agents/pm/decisions/pm-qwuber.toon). The original stable-author
|
|
22
|
-
contract remains authoritative; this amendment replaces only its fixed
|
|
23
|
-
model-only provenance shape.
|
|
24
|
-
|
|
25
|
-
## Decision
|
|
26
|
-
|
|
27
|
-
Mutation history may retain bounded descriptive agent provenance independently
|
|
28
|
-
from the stable mutation author. `agent_provenance` is a string-keyed map whose
|
|
29
|
-
values are either `{ value, source }` observations or `null` when a detected
|
|
30
|
-
harness declares a dimension but cannot expose a value.
|
|
31
|
-
|
|
32
|
-
The default runtime understands `model`, `effort`, `role`, `topic`, and
|
|
33
|
-
`version`. Harness
|
|
34
|
-
descriptors and trusted embedded hosts may add dimensions such as `topic`
|
|
35
|
-
without a storage migration. The legacy `agent_model` and
|
|
36
|
-
`agent_model_source` fields remain populated from `agent_provenance.model` for
|
|
37
|
-
backward-compatible readers.
|
|
38
|
-
|
|
39
|
-
The precedence for each dimension is:
|
|
40
|
-
|
|
41
|
-
1. explicit `PM_AGENT_<DIMENSION>` override;
|
|
42
|
-
2. the selected harness descriptor's environment keys;
|
|
43
|
-
3. MCP client provenance;
|
|
44
|
-
4. trusted embedding-host provenance;
|
|
45
|
-
5. bounded argv values.
|
|
46
|
-
6. an explicitly declared bounded local resolver.
|
|
47
|
-
|
|
48
|
-
`detectAgentIdentity()` and `detectHarnessIdentity()` use ambient invocation
|
|
49
|
-
signals when called with no argument. An explicitly supplied signal object
|
|
50
|
-
remains isolated from ambient state. SDK hosts that need async-safe scoping use
|
|
51
|
-
`runWithHarnessDetectionSignals()`.
|
|
52
|
-
|
|
53
|
-
## Privacy and security boundary
|
|
54
|
-
|
|
55
|
-
Provenance values are descriptive context, never authentication or
|
|
56
|
-
authorization principals. Values are trimmed, length-bounded, and obtained only
|
|
57
|
-
from literal descriptor keys, trusted caller data, or a named bounded resolver.
|
|
58
|
-
Detection does not spawn processes, traverse process trees, evaluate user
|
|
59
|
-
regexes, or access the network. The built-in Claude and Codex resolvers read
|
|
60
|
-
only bounded windows of the current session's harness-owned JSONL file. Claude
|
|
61
|
-
resolves an explicitly supplied transcript first, then the direct workspace
|
|
62
|
-
coordinate, then performs a deterministic scan of at most 512 immediate
|
|
63
|
-
project directories for the unique stable session id. This keeps provenance
|
|
64
|
-
attached when the invocation cwd moves into a child package. No match is
|
|
65
|
-
reported as `resolver_input_missing`; multiple matches are ambiguous and remain
|
|
66
|
-
`resolver_failed` instead of selecting an arbitrary transcript. Claude uses the
|
|
67
|
-
bounded session window to recover its recorded model/version. Codex uses the
|
|
68
|
-
recent tail plus a bounded initial-head fallback for oversized sessions to
|
|
69
|
-
recover allow-listed `turn_context.model` and `turn_context.effort` values.
|
|
70
|
-
Both cap traversal, file bytes, lines, and line length, ignore all other fields,
|
|
71
|
-
never follow symlinks, and fail closed. `agent_identity.probes_enabled` or
|
|
72
|
-
`PM_AGENT_PROBES=off` disables every local resolver without disabling ordinary
|
|
73
|
-
environment, argv, client, or host detection.
|
|
74
|
-
|
|
75
|
-
Raw session identifiers remain transient and are never written to history or
|
|
76
|
-
telemetry. When a harness and session are both present, history may retain only
|
|
77
|
-
the existing domain-separated, truncated `agent_instance` digest. Public
|
|
78
|
-
telemetry continues to use installation-scoped hashes or presence booleans; it
|
|
79
|
-
does not export raw provenance values.
|
|
80
|
-
|
|
81
|
-
Health counts resolvers with an available input, plus failed or ambiguous
|
|
82
|
-
resolution attempts, as attempts. A sustained attempted-but-zero-success series
|
|
83
|
-
remains advisory: it truthfully identifies parser, filesystem, ambiguity, or
|
|
84
|
-
provider-shape drift without treating missing descriptive metadata as
|
|
85
|
-
authorization or item-state corruption. Missing-input and probes-disabled
|
|
86
|
-
events are classified separately and do not inflate that warning.
|
|
87
|
-
|
|
88
|
-
## Compatibility
|
|
89
|
-
|
|
90
|
-
All new history fields are optional. Readers must accept:
|
|
91
|
-
|
|
92
|
-
- legacy entries with no agent fields;
|
|
93
|
-
- model-only entries using `agent_model` and `agent_model_source`;
|
|
94
|
-
- new entries with `agent_provenance`;
|
|
95
|
-
- explicit `model: null`, `effort: null`, or `role: null` observations meaning
|
|
96
|
-
the dimension was declared but unavailable for a detected harness.
|
|
97
|
-
|
|
98
|
-
Modern MCP clients may supply a bounded
|
|
99
|
-
`io.modelcontextprotocol/clientInfo.provenance` map in each request's `_meta`.
|
|
100
|
-
The server retains only valid dimension names and trimmed values, then resolves
|
|
101
|
-
that map inside the invocation-scoped identity context for that request. The
|
|
102
|
-
bounded initialize-era adapter accepts the same map during legacy `initialize`.
|
|
103
|
-
A missing MCP signal is recorded as explicit `null`; it is never confused with
|
|
104
|
-
a legacy entry that predates the dimension.
|
|
105
|
-
|
|
106
|
-
Unknown provenance dimensions are preserved as data and do not change author
|
|
107
|
-
resolution. Removing a dimension from a descriptor never rewrites existing
|
|
108
|
-
history.
|
|
109
|
-
|
|
110
|
-
## Historical disposition
|
|
111
|
-
|
|
112
|
-
The repository snapshot measured at the start of the 2026-08-01 migration
|
|
113
|
-
contains 42,679 immutable history entries. Privacy-safe aggregation by the
|
|
114
|
-
presence and shape of `agent_provenance.effort` found 549 observed values, 166
|
|
115
|
-
explicitly unavailable values, and 41,964 entries with no effort key. No raw
|
|
116
|
-
provenance value, session identifier, or instance digest was exported during
|
|
117
|
-
that measurement.
|
|
118
|
-
|
|
119
|
-
The missing group is retained as `legacy_missing`; it is never backfilled from
|
|
120
|
-
nearby mutations or inferred from another surface. The unavailable group
|
|
121
|
-
means the dimension was declared at write time but could not be observed. The
|
|
122
|
-
observed group remains the only group suitable for effort-based evaluation.
|
|
123
|
-
Repository history does not persist the CLI-versus-MCP transport as an
|
|
124
|
-
identity field, and the current snapshot contains no committed
|
|
125
|
-
`agent_instance` group mixing an observed effort with a legacy-missing effort.
|
|
126
|
-
Historical MCP records from the original isolated reproduction therefore keep
|
|
127
|
-
the same immutable disposition: missing means unknown, not a change in effort.
|
|
128
|
-
|
|
129
|
-
Consumers grouping one session must treat `legacy_missing`, explicit
|
|
130
|
-
unavailability, and an observed value as three distinct states. Rewriting the
|
|
131
|
-
hash chain would erase the evidence that motivated this amendment and could
|
|
132
|
-
fabricate precision that was never captured.
|
|
133
|
-
|
|
134
|
-
## SDK and completeness contracts
|
|
135
|
-
|
|
136
|
-
The aggregate and core SDK entrypoints export:
|
|
137
|
-
|
|
138
|
-
- `AGENT_PROVENANCE_DIMENSIONS`;
|
|
139
|
-
- `BUILTIN_AGENT_PROVENANCE_ADAPTERS`,
|
|
140
|
-
`listAgentProvenanceAdapters()`, and
|
|
141
|
-
`registerAgentProvenanceAdapters()`;
|
|
142
|
-
- `normalizeAgentProvenanceAdapterValue()` for stable model-family and effort
|
|
143
|
-
vocabulary projections that retain the bounded raw observation;
|
|
144
|
-
- `detectAgentIdentity()` and `detectHarnessIdentity()`;
|
|
145
|
-
- `analyzeAgentProvenanceDescriptorCoverage()` for the descriptor capability
|
|
146
|
-
matrix and negative controls;
|
|
147
|
-
- `summarizeAgentModelProvenance()` for observed, unavailable, legacy-missing,
|
|
148
|
-
and inert-capture reporting;
|
|
149
|
-
- `analyzeSdkCliParameterCompleteness()` for a derived bidirectional CLI flag
|
|
150
|
-
and strict SDK parameter matrix.
|
|
151
|
-
- `projectHistoryProvenance()`, `compileHistoryProvenanceMatcher()`, and
|
|
152
|
-
`summarizeHistoryProvenance()` for immutable, patch-free reads and bounded
|
|
153
|
-
completeness reporting.
|
|
154
|
-
|
|
155
|
-
`pm history <id>`, `pm activity`, and `pm events` share `--provenance`,
|
|
156
|
-
`--provenance-summary`, repeatable `--harness`, repeatable `--agent-instance`,
|
|
157
|
-
and repeatable `--provenance-filter dimension=value`. The provenance projection
|
|
158
|
-
never returns JSON Patch operations or document hashes. History rows retain
|
|
159
|
-
their original one-based stream version after filtering. Events use the same
|
|
160
|
-
predicates in the durable derived index, so consumers do not need to scan raw
|
|
161
|
-
history payloads.
|
|
162
|
-
|
|
163
|
-
Legacy author interpretation is workspace-owned data under
|
|
164
|
-
`agent_identity.identity_vocabulary`. It contains a monotonically managed
|
|
165
|
-
`version` and exact literal-to-harness `aliases`. Reads disclose both the
|
|
166
|
-
version and whether a harness was `recorded`, resolved by `vocabulary`, or
|
|
167
|
-
remains `unresolved`; immutable authors and hashes are never rewritten.
|
|
168
|
-
|
|
169
|
-
`pm config get agent-identity-vocabulary`, `config list`, and `config export`
|
|
170
|
-
publish only its `version` and `alias_count`. Typed mutations use the existing
|
|
171
|
-
config transport:
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
pm config set agent-identity-probes-enabled false
|
|
175
|
-
pm config set agent-identity-vocabulary --policy preview-add \
|
|
176
|
-
--value "Legacy Codex=codex" --criterion "Legacy Codex" --criterion "Alice"
|
|
177
|
-
pm config set agent-identity-vocabulary --policy add \
|
|
178
|
-
--value "Legacy Codex=codex"
|
|
179
|
-
pm config set agent-identity-vocabulary --policy remove --value "Legacy Codex"
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
`preview-*` policies perform no write and report the exact residual unique
|
|
183
|
-
author count without returning author spellings. Real add/remove/clear changes
|
|
184
|
-
bump the vocabulary revision once; identical adds and absent removes are
|
|
185
|
-
idempotent. Aliases for already canonical `harness:<name>` authors fail closed.
|
|
186
|
-
|
|
187
|
-
Every built-in interactive harness has a contract-versioned adapter with an
|
|
188
|
-
implementation version, priority, covered dimensions, source classes,
|
|
189
|
-
normalization revisions, confidence, waivers, and immutable probe bounds.
|
|
190
|
-
Packages may register a new namespace or explicitly replace a built-in only at
|
|
191
|
-
a higher priority. Equal-priority ambiguity and descriptor mismatch fail
|
|
192
|
-
closed, and the disposer restores the prior adapter.
|
|
193
|
-
|
|
194
|
-
The SDK/CLI matrix classifies every input as shared, positional, transport,
|
|
195
|
-
presentation, local adapter, scope selector, compatibility alias, or SDK-native.
|
|
196
|
-
An unknown CLI flag fails closed as `unclassified`. Committed test baselines cap
|
|
197
|
-
every waiver category and the representative behavioral-envelope corpus, so
|
|
198
|
-
coverage may expand and waivers may shrink without returning to a curated
|
|
199
|
-
hand-picked list.
|
|
200
|
-
|
|
201
|
-
## Operational guidance
|
|
202
|
-
|
|
203
|
-
Use provenance to answer context questions such as which harness/model/effort
|
|
204
|
-
performed a mutation or whether a capture source is inert. Do not use it to
|
|
205
|
-
decide who is allowed to mutate an item. Use `author`, ownership, and explicit
|
|
206
|
-
project policy for authorization and coordination.
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# Defect Recurrence and Boundary Evidence
|
|
2
|
-
|
|
3
|
-
Tracked by [pm-1qkivy](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/features/pm-1qkivy.toon), [pm-rtn5h6](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/tasks/pm-rtn5h6.toon), [pm-0pzgit](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/tasks/pm-0pzgit.toon), [pm-7c27ep](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-7c27ep.toon), [pm-h8tpeh](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/features/pm-h8tpeh.toon), [pm-003j](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/tasks/pm-003j.toon), and [pm-xcndcu](https://github.com/unbraind/pm-cli/blob/main/.agents/pm/issues/pm-xcndcu.toon). These tracker records are repository-only and excluded from npm.
|
|
4
|
-
|
|
5
|
-
## Agent Quick Context
|
|
6
|
-
|
|
7
|
-
`pm` treats project management as context management. A resolved defect is therefore not only a closed item: it is durable context that should select the checks most likely to prevent the same failure from recurring.
|
|
8
|
-
|
|
9
|
-
The public SDK provides four composable contracts:
|
|
10
|
-
|
|
11
|
-
- a captured-boundary registry that rejects self-generated fixtures, unsafe samples, missing samples, and expired waivers;
|
|
12
|
-
- a defect-evidence ratchet that requires a typed escape class plus a gate improvement or reviewed, expiring waiver on new terminal defects;
|
|
13
|
-
- a versioned recurrence index that maps proposed files, packages, PM items, tags, and error codes to shared local and hosted checks;
|
|
14
|
-
- a complete-population recurrence coverage report with bounded, resumable evidence rows.
|
|
15
|
-
|
|
16
|
-
The CLI and MCP use the same SDK action path. Repository policy can be replaced by a package or workspace policy without changing the analyzer.
|
|
17
|
-
|
|
18
|
-
## Public SDK
|
|
19
|
-
|
|
20
|
-
Import the governance surface from the package root or the narrow governance entrypoint:
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import {
|
|
24
|
-
analyzeDefectChangeRisk,
|
|
25
|
-
buildDefectRecurrenceIndex,
|
|
26
|
-
evaluateBoundaryFixtures,
|
|
27
|
-
evaluateDefectGateEvidence,
|
|
28
|
-
parseDefectRecurrencePolicy,
|
|
29
|
-
type DefectChangeRiskInput,
|
|
30
|
-
type DefectRecurrencePolicy,
|
|
31
|
-
} from "@unbrained/pm-cli/sdk/governance";
|
|
32
|
-
|
|
33
|
-
const policy: DefectRecurrencePolicy =
|
|
34
|
-
parseDefectRecurrencePolicy(serializedPolicy);
|
|
35
|
-
const index = buildDefectRecurrenceIndex(policy, pmItems, {
|
|
36
|
-
previous_index: previousIndex,
|
|
37
|
-
changed_item_ids: changedItemIds,
|
|
38
|
-
});
|
|
39
|
-
const change: DefectChangeRiskInput = {
|
|
40
|
-
files: ["src/sdk/governance/assurance-action.ts"],
|
|
41
|
-
item_ids: ["pm-1qkivy"],
|
|
42
|
-
};
|
|
43
|
-
const report = analyzeDefectChangeRisk(index, change, { limit: 25 });
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
The index and report are deterministic. `policy_fingerprint` identifies the versioned policy; `index_fingerprint` also covers the sparse PM item-to-family contributions. Continuation cursors bind to the latter, so a cursor cannot silently continue against changed context.
|
|
47
|
-
|
|
48
|
-
Each report explains its exact matching signals, returns deduplicated local and hosted checks, and includes a small cost receipt. Package authors may keep their own recurrence policy and feed the same SDK from a custom command, extension, CI adapter, or application.
|
|
49
|
-
|
|
50
|
-
File-pattern evaluation is tracked by [pm-0vqbl5](../.agents/pm/tasks/pm-0vqbl5.toon).
|
|
51
|
-
Patterns treat punctuation and literal NUL characters literally, `*` matches any characters except `/`, and
|
|
52
|
-
`**` also crosses separators while excluding line terminators. Matching covers
|
|
53
|
-
the complete trimmed path; `**/` still requires its slash. A finite-state matcher
|
|
54
|
-
uses at most pattern length times path length work and memory proportional to
|
|
55
|
-
pattern length. The existing 256-character policy limit and bounded compiled
|
|
56
|
-
pattern cache remain in force, including for custom SDK policy consumers.
|
|
57
|
-
|
|
58
|
-
## CLI and MCP Action
|
|
59
|
-
|
|
60
|
-
`assurance risk` accepts one JSON request through the same `definition` transport already used by SDK and MCP hosts:
|
|
61
|
-
|
|
62
|
-
Discovery recovery is tracked by [pm-assurance-risk-help-policy](../.agents/pm/issues/pm-assurance-risk-help-policy.toon).
|
|
63
|
-
Both `policy` and `change` are required. Help includes an executable minimal
|
|
64
|
-
example with an explicitly empty family list; it demonstrates the request
|
|
65
|
-
shape and makes no project coverage claim. Use the project's declared policy
|
|
66
|
-
for real decisions, as below. A missing or invalid policy object returns
|
|
67
|
-
structured help recovery without choosing a policy on the caller's behalf.
|
|
68
|
-
SDK policy parsing throws `DefectRecurrencePolicyParseError`, a `TypeError`
|
|
69
|
-
subclass exported by the root and governance entrypoints. This identifies
|
|
70
|
-
policy validation without depending on message text; its stable `code` is
|
|
71
|
-
`defect_recurrence_policy_invalid`. Change and lineage
|
|
72
|
-
validation retain their separate error contracts.
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
risk_request=$(jq -cn \
|
|
76
|
-
--slurpfile policy config/defect-recurrence-policy.json \
|
|
77
|
-
'{policy:$policy[0],change:{files:["src/sdk/governance/assurance-action.ts"],item_ids:["pm-1qkivy"]},limit:25}')
|
|
78
|
-
pm assurance risk --definition "$risk_request" --json
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
The result uses `items` as its bounded row collection and publishes `.items[]` as the stable selector. When `next_cursor` is present, submit it in the next request. A stale or malformed cursor fails rather than restarting from an ambiguous offset.
|
|
82
|
-
|
|
83
|
-
Use `pm assurance risk` for an operator or agent decision. Use the pure SDK functions when a package already owns the item projection, wants to preserve an incremental index, or needs to combine risk with another domain model.
|
|
84
|
-
|
|
85
|
-
### TypeScript compatibility
|
|
86
|
-
|
|
87
|
-
The exported `ASSURANCE_ACTIONS` tuple and `AssuranceActionResult` union include `risk`, `lineages`,
|
|
88
|
-
`DefectChangeRiskReport`, and `DefectRecurrenceCoverageReport`. This is additive at runtime, but TypeScript consumers with an exhaustive action or result switch must add the new branch. The SDK surface snapshot records that source-compatibility change explicitly.
|
|
89
|
-
|
|
90
|
-
## Policy Model
|
|
91
|
-
|
|
92
|
-
The repository example is [config/defect-recurrence-policy.json](../config/defect-recurrence-policy.json). Every family declares:
|
|
93
|
-
|
|
94
|
-
- a stable id, monotonic version, title, and accountable PM item;
|
|
95
|
-
- one of `production_defect`, `nightly_regression`, `scanner_finding`, or `review_caught_late`;
|
|
96
|
-
- file, package, item, tag, or error-code triggers;
|
|
97
|
-
- local and hosted checks selected from the same policy;
|
|
98
|
-
- a negative-control change that must select the family;
|
|
99
|
-
- historical PM items that justify the family;
|
|
100
|
-
- maximum escape-rate and false-positive-rate budgets.
|
|
101
|
-
|
|
102
|
-
Repository policy validation rejects duplicate ids, absent historical examples, missing family negative controls, invalid taxonomy values, and budgets outside zero through one. Deterministic sorting makes the serialized policy merge-friendly.
|
|
103
|
-
|
|
104
|
-
Register a semantic family seed using its owner, trigger item ids, or historical
|
|
105
|
-
item ids. The SDK follows every recorded local `recurs_from` edge in either
|
|
106
|
-
direction to derive family membership for the complete connected lineage.
|
|
107
|
-
Cycles and deep chains do not impose a traversal cutoff. Related, parent, and
|
|
108
|
-
external edges never establish recurrence coverage; tags and matching file
|
|
109
|
-
globs select change risk but cannot certify lineage registration.
|
|
110
|
-
|
|
111
|
-
Derived members inherit the family's checks. Changes naming a member or one of
|
|
112
|
-
its exact project-scoped linked files select those checks even when the policy
|
|
113
|
-
never named that member. Incremental indexes retain sparse direct evidence so
|
|
114
|
-
removing or changing an edge also removes obsolete inherited matches.
|
|
115
|
-
|
|
116
|
-
### Complete-population coverage
|
|
117
|
-
|
|
118
|
-
Tracked by [pm-7c27ep](../.agents/pm/issues/pm-7c27ep.toon).
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
import { analyzeDefectRecurrenceCoverage } from "@unbrained/pm-cli/sdk/governance";
|
|
122
|
-
|
|
123
|
-
const coverage = analyzeDefectRecurrenceCoverage(policy, allStatusItems, {
|
|
124
|
-
limit: 25,
|
|
125
|
-
uncoveredOnly: true,
|
|
126
|
-
});
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
Supply an authoritative complete item corpus. The workspace action loads it
|
|
130
|
-
with strict read semantics. Unreadable item documents or directories refuse
|
|
131
|
-
both workspace analyses and the repository gate with `list_source_incomplete`.
|
|
132
|
-
Embedding hosts can request the same policy with
|
|
133
|
-
`createAssuranceWorkspaceContext(pmRoot, { strict_read: true })`.
|
|
134
|
-
Duplicate ids are rejected. Missing local targets
|
|
135
|
-
remain in the population and produce `missing_recurrence_item`; an unregistered
|
|
136
|
-
component produces `unregistered_recurrence_item`. The complete verdict is
|
|
137
|
-
computed before filtering or pagination, so a covered first page cannot hide
|
|
138
|
-
an uncovered member later in the graph.
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
lineage_request=$(jq -cn --slurpfile policy config/defect-recurrence-policy.json \
|
|
142
|
-
'{policy:$policy[0],limit:25,uncoveredOnly:true}')
|
|
143
|
-
pm assurance lineages --definition "$lineage_request" --json
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
SDK, CLI, and MCP accept the same `definition`. Use `limit` from 1 through 100,
|
|
147
|
-
`cursor`, and `uncoveredOnly` inside that object. Continuations bind the policy,
|
|
148
|
-
complete recurrence evidence, item presence, and filter; changing page size is
|
|
149
|
-
allowed. `total`, `has_more`, and `next_cursor` describe the selected rows;
|
|
150
|
-
`population` always describes every recorded recurrence member. The CLI analysis
|
|
151
|
-
returns a report; the repository gate makes its `ok` predicate blocking.
|
|
152
|
-
|
|
153
|
-
The denominator includes covered, uncovered, and missing recurrence ids across
|
|
154
|
-
all lifecycle states. Recorded recognized `escape_class` values produce class
|
|
155
|
-
counts; unclassified members are never silently counted as non-escapes.
|
|
156
|
-
`escape_rate` is null for an empty or incompletely classified population.
|
|
157
|
-
`escape_rate_lower_bound` separately reports known production defects divided by
|
|
158
|
-
the entire population. Family labels never backfill item classifications, and
|
|
159
|
-
`budget_scope: "registered_families_only"` prevents policy budgets from being
|
|
160
|
-
mistaken for proof about an unknown population.
|
|
161
|
-
|
|
162
|
-
Registration means checks are selected, not that the defect is fixed or a
|
|
163
|
-
hosted check has passed. The policy includes domain seeds for all current
|
|
164
|
-
recorded components, while future disconnected recurrences fail the gate until
|
|
165
|
-
a justified family is registered. Future edges within a registered lineage
|
|
166
|
-
inherit protection automatically.
|
|
167
|
-
|
|
168
|
-
## Defect Evidence on PM Items
|
|
169
|
-
|
|
170
|
-
Projects can register the structured fields without changing the SDK:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
pm schema add-field escape_class \
|
|
174
|
-
--type string \
|
|
175
|
-
--commands create,update,list,search,context \
|
|
176
|
-
--description "Defect escape taxonomy"
|
|
177
|
-
pm schema add-field gate_evidence \
|
|
178
|
-
--type object \
|
|
179
|
-
--commands create,update,list,search,context \
|
|
180
|
-
--description "Gate improvement or explicit waiver evidence"
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
`gate_evidence` accepts one of these dispositions:
|
|
184
|
-
|
|
185
|
-
- `gate_added` and `gate_strengthened` require `gate_id`, a runnable `negative_control`, non-empty `local_checks` and `hosted_checks`, and an accountable `owner`;
|
|
186
|
-
- `explicit_waiver` requires an accountable `owner`, a concrete `waiver_reason`, and a future `waiver_expires_at` timestamp.
|
|
187
|
-
|
|
188
|
-
The evidence epoch lets an adopting project ratchet new closures immediately while backfilling historical items deliberately. A valid `completed_at` is authoritative, `closed_at` is the compatibility fallback, and timestamp-less items created after the epoch fail closed; timestamp-less items created before the epoch remain explicitly grandfathered. Reports keep historical escape-class and disposition counts visible even before those older items become closure blockers.
|
|
189
|
-
|
|
190
|
-
## Captured Boundary Fixtures
|
|
191
|
-
|
|
192
|
-
The repository inventory is [config/boundary-fixtures.json](../config/boundary-fixtures.json). Each externally produced or consumed value must carry either:
|
|
193
|
-
|
|
194
|
-
- a committed JSON sample with `capture_source` set to `captured_redacted` or `captured_verbatim`, capture provenance, explicit redactions, input, and observed output; or
|
|
195
|
-
- an explicit reason, owner, and future expiry for a boundary that cannot yet be captured safely.
|
|
196
|
-
|
|
197
|
-
The evaluator rejects a `self_generated` source because a fixture created by the same implementation cannot reveal disagreement with an external format. It also scans committed JSON for common home-directory, package-token, GitHub-token, and private-key patterns.
|
|
198
|
-
|
|
199
|
-
The Claude Code directory-slug fixture is consumed directly by the author-provenance test. The npm, GitHub Actions, Git commit, and Sentry samples preserve real field shapes while replacing identifiers, paths, URLs, and user data.
|
|
200
|
-
|
|
201
|
-
## Waiver Notice Window
|
|
202
|
-
|
|
203
|
-
An expiring waiver is a forcing function: once `waiver_expires_at` passes, the gate fails closed until someone renews or retires it. Without notice, that failure lands on whatever runs first after midnight UTC, which is usually the daily release. Both registries therefore declare a notice window as data:
|
|
204
|
-
|
|
205
|
-
- `waiver_notice_days` in the recurrence policy (`config/defect-recurrence-policy.json`) covers `explicit_waiver` gate evidence on governed terminal defects;
|
|
206
|
-
- `waiver_notice_days` in the boundary registry (`config/boundary-fixtures.json`) covers boundary waivers;
|
|
207
|
-
- `waiver_notice_days` in the dependency advisory waiver registry (`config/dependency-advisory-waivers.json`, 0 to 30 days) covers recorded advisory waivers. See [Time-bounded advisory waivers](https://github.com/unbraind/pm-cli/blob/main/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md#time-bounded-advisory-waivers) (repository documentation, not shipped in the npm package).
|
|
208
|
-
|
|
209
|
-
The value is a whole number of days from `0` to `366`; absent means `0`. `evaluateDefectGateEvidence` and `evaluateBoundaryFixtures` return each valid live waiver whose expiry falls inside the window under `waiver_notices` (`subject_id`, `owner`, `expires_at`, `days_remaining`). Notices never change `ok`: the evidence gate, pull-request CI and the release keep passing, and the text output lists every notice under the findings. `isWaiverNoticeDays`, `waiverNoticeFor` and `sortWaiverNotices` are exported so a package can apply the same window to its own waiver registry.
|
|
210
|
-
|
|
211
|
-
The early warning is a separate scheduled assurance gate:
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
node scripts/release/defect-evidence-gate.mjs --waiver-notice
|
|
215
|
-
node scripts/release/defect-evidence-gate.mjs --waiver-notice --negative-control
|
|
216
|
-
node scripts/release/repository-assurance.mjs repository-waiver-notice --trigger scheduled
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
`--waiver-notice` fails while any waiver is inside its window and on every boundary, defect-evidence or advisory-waiver finding, because a malformed or duplicate record can hide an expiry; recurrence-policy findings do not affect it. Its third check, `dependency_advisory`, also fails when an advisory waiver's owner is not an open tracker item. The negative control seeds one boundary waiver, one defect waiver and one advisory waiver an hour from expiry and must exit `1`. The `repository-waiver-notice` gate (assertion `repository-waiver-notice-clear`, trigger `scheduled`) runs this provider in the nightly quality job, so a scheduled run opens the nightly alert issue, listing every waiver it names, before an expiry could block a release. How much earlier depends on each registry's `waiver_notice_days`: 14 days for boundary and defect waivers, 3 days for the dependency advisory waivers. Renew a waiver only after re-verifying its reason, and record that verification on the owning item.
|
|
220
|
-
|
|
221
|
-
## Repository Gate
|
|
222
|
-
|
|
223
|
-
Run the complete local gate after building:
|
|
224
|
-
|
|
225
|
-
```bash
|
|
226
|
-
pnpm quality:defect-evidence
|
|
227
|
-
node scripts/release/defect-evidence-gate.mjs --negative-control --json
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
The first command must pass. The negative control must exit `1` after replacing a captured sample with a forbidden source and adding a terminal defect without evidence. The policy-only negative control
|
|
231
|
-
adds a disconnected, unregistered recurrence pair and must also exit `1`. Focused provider modes are available as `--boundary-only`, `--evidence-only`, and `--policy-only`.
|
|
232
|
-
|
|
233
|
-
`repository-defect-evidence-required` is part of the blocking `repository-static-quality` assurance composition. That makes local and CI behavior share the same provider result, assertion negative control, enforcement, and immutable verdict semantics.
|
|
234
|
-
|
|
235
|
-
The static quality pipeline also runs `node scripts/check-workflow-permissions.mjs`.
|
|
236
|
-
It parses every GitHub workflow and requires an explicit read-only default token;
|
|
237
|
-
write scopes belong on jobs that use them. Run its `--negative-control` mode to
|
|
238
|
-
confirm a workflow-scope `contents: write` grant exits with status 1. This
|
|
239
|
-
protects the least-privilege workflow policy that [pm-003j](../.agents/pm/tasks/pm-003j.toon)
|
|
240
|
-
tracks, even between Scorecard scans.
|
|
241
|
-
|
|
242
|
-
The mandatory `gate-registry` check also compares each recurrence family's `checks.hosted` values with concrete names derived from the repository workflows. It expands static matrix axes and applies exclusions before inclusions according to [GitHub's matrix rules](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstrategymatrixinclude). Renamed or removed checks produce named findings. Runtime expressions, unnamed matrix jobs, and static expansions beyond 256 combinations cannot certify a required check name. The public SDK policy parser remains provider-neutral; this workflow binding belongs to the repository gate.
|
|
243
|
-
|
|
244
|
-
Assurance request schemas declare each family's required identity, triggers,
|
|
245
|
-
checks, historical IDs, budgets, and negative-control input. Runtime policy
|
|
246
|
-
validation additionally verifies unique family IDs and that each negative control
|
|
247
|
-
actually selects its family; structural JSON Schema validation alone cannot prove
|
|
248
|
-
those relationships. Risk reasons are sorted after direct and inherited matches
|
|
249
|
-
are combined, using signal, value, then matched evidence as stable ordering keys.
|
|
250
|
-
|
|
251
|
-
## Recovery Producer Census
|
|
252
|
-
|
|
253
|
-
`censusPmRecoveryReferenceProducers` scans complete source files for static object-literal recovery fields. It ignores type literals, destructuring patterns, labels, comments, strings, templates, and regular expressions. Aliases such as `candidate_commands`, nested `fallback_candidates[].command`, `next_best_command`, `retry_command`, and `suggested_next_steps` normalize to the same six public recovery kinds used by executable reachability verification.
|
|
254
|
-
|
|
255
|
-
The census fails when a kind has no producer or when a recovery-like envelope field lacks a typed contract. The integration gate scans every `src/**/*.ts` producer; the existing real-entrypoint corpus then executes or resolves every normalized kind and proves recovery, replacement, or behavior-preserving semantics.
|
|
256
|
-
|
|
257
|
-
This separation is intentional: the producer census prevents silent omissions as source grows, while entrypoint execution proves that a reference is not merely syntactically present.
|