@unbrained/pm-cli 2026.8.21 → 2026.8.23
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +44 -0
- package/dist/cli/error-guidance.d.ts +22 -4
- package/dist/cli/error-guidance.js +73 -16
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +51 -9
- package/dist/cli/register-mutation.js +6 -6
- package/dist/cli/register-operations.d.ts +73 -0
- package/dist/cli/register-operations.js +39 -14
- package/dist/cli/register-setup.js +3 -3
- package/dist/cli/schema-registration-helpers.d.ts +8 -1
- package/dist/cli/schema-registration-helpers.js +14 -5
- package/dist/cli-bundle/bundle-manifest.json +149 -149
- package/dist/cli-bundle/chunks/chunk-3ENVHX6C.js +36 -0
- package/dist/cli-bundle/chunks/{chunk-LOVTQ52Z.js → chunk-DW2CGEMU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-EG6CLDZT.js +5 -0
- package/dist/cli-bundle/chunks/{chunk-LARJJ3RK.js → chunk-F3AI2JFL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-N3DSV4CH.js → chunk-HWZ6CELB.js} +8 -8
- package/dist/cli-bundle/chunks/chunk-HZBMLSZI.js +201 -0
- package/dist/cli-bundle/chunks/chunk-JB4KZWBF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-KPH73XXJ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-BKYB45NQ.js → chunk-KXPMB2YL.js} +50 -50
- package/dist/cli-bundle/chunks/{chunk-BUNIEJNE.js → chunk-QDVHNHAQ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TFI5V5N2.js +13 -0
- package/dist/cli-bundle/chunks/{register-list-query-F57EWDEF.js → register-list-query-UJB5FMV2.js} +2 -2
- package/dist/cli-bundle/chunks/register-mutation-NX5XE4VX.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-RXIJIYXC.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-HXU7IZZD.js → register-setup-GFUZEKRE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-F4YEW5I2.js → chunk-37Z4OEAP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3UPTYG44.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-5S7E72FY.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4ERLO7QD.js → chunk-AUFH5H35.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-E7X25GC3.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FQCSTBWE.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-FH6DYED3.js → chunk-FZS4H32O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IFLWKY2R.js +156 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YKBKIEAJ.js → chunk-JOWDB2MH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-LYVSW5VM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-MRCNF3U6.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UZE7XUZK.js → chunk-OFVUGTLJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FJ22HNRP.js → chunk-OGLQBL46.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-OY7QAV4Y.js +51 -0
- package/dist/cli-bundle/focused-chunks/chunk-QGFNI65N.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-KDNG7TKQ.js → chunk-R27IDGHD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UYRFYCDQ.js +5 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2NIY5NKG.js → chunk-ZHVA42R5.js} +9 -9
- package/dist/cli-bundle/main.js +13 -13
- 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 +40 -40
- 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 +33 -32
- 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 +5 -5
- package/dist/core/config/nested-settings.js +8 -2
- package/dist/core/config/positional-value.d.ts +1 -1
- package/dist/core/config/positional-value.js +5 -2
- package/dist/core/extensions/extension-hook-runtime.js +22 -20
- package/dist/core/extensions/extension-types.d.ts +8 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/loader.js +7 -3
- package/dist/core/extensions/service-ownership.d.ts +8 -0
- package/dist/core/extensions/service-ownership.js +20 -0
- package/dist/core/history/history.js +3 -3
- package/dist/core/item/id.js +20 -5
- package/dist/core/item/item-format.js +81 -2
- package/dist/core/reproducibility/context.d.ts +4 -0
- package/dist/core/reproducibility/context.js +14 -8
- package/dist/core/shared/author.d.ts +55 -1
- package/dist/core/shared/author.js +333 -16
- package/dist/core/shared/constants.js +3 -2
- package/dist/core/shared/errors.d.ts +4 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +6 -3
- package/dist/core/store/settings.js +5 -2
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +30 -9
- package/dist/sdk/agent/identity-config.d.ts +63 -0
- package/dist/sdk/agent/identity-config.js +107 -0
- package/dist/sdk/agent/refusal-corpus-contracts.d.ts +76 -0
- package/dist/sdk/agent/refusal-corpus-contracts.js +194 -0
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/authoring.d.ts +1 -1
- package/dist/sdk/authoring.js +2 -2
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +77 -0
- package/dist/sdk/cli-contracts/agent-output-contracts.js +326 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -3
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -0
- package/dist/sdk/cli-contracts/enum-contracts.js +9 -2
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +4 -4
- package/dist/sdk/cli-contracts/registration-helpers.js +5 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -2
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +14 -3
- package/dist/sdk/cli-contracts.d.ts +4 -4
- package/dist/sdk/cli-contracts.js +5 -5
- package/dist/sdk/config.d.ts +6 -1
- package/dist/sdk/config.js +119 -14
- package/dist/sdk/context-intent-contracts.js +4 -2
- package/dist/sdk/core-governance.d.ts +1 -1
- package/dist/sdk/core-governance.js +3 -3
- package/dist/sdk/extension/install-sources.d.ts +1 -1
- package/dist/sdk/extension/install-sources.js +6 -3
- package/dist/sdk/extension/output-ownership.d.ts +1 -0
- package/dist/sdk/extension/output-ownership.js +3 -2
- package/dist/sdk/extension/scaffold.js +11 -5
- package/dist/sdk/flag-invocation-contracts.js +4 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +74 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +87 -26
- package/dist/sdk/governance/assurance-action.js +30 -10
- package/dist/sdk/governance/health.d.ts +3 -0
- package/dist/sdk/governance/health.js +39 -7
- package/dist/sdk/governance/hierarchy-validation.d.ts +29 -0
- package/dist/sdk/governance/hierarchy-validation.js +109 -0
- package/dist/sdk/governance/validate.d.ts +3 -9
- package/dist/sdk/governance/validate.js +84 -111
- package/dist/sdk/graph/assembly.d.ts +6 -1
- package/dist/sdk/graph/assembly.js +16 -22
- package/dist/sdk/graph/governance-contracts.d.ts +1 -1
- package/dist/sdk/graph/governance-contracts.js +8 -2
- package/dist/sdk/graph/governance.js +46 -2
- package/dist/sdk/graph/hierarchy-integrity.d.ts +94 -0
- package/dist/sdk/graph/hierarchy-integrity.js +311 -0
- package/dist/sdk/graph/index.d.ts +2 -1
- package/dist/sdk/graph/index.js +3 -2
- package/dist/sdk/graph/remediation.js +32 -2
- package/dist/sdk/graph/run.d.ts +31 -2
- package/dist/sdk/graph/run.js +80 -31
- package/dist/sdk/graph/workspace-relationship-kind-registry.d.ts +8 -0
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +28 -0
- package/dist/sdk/index.d.ts +8 -3
- package/dist/sdk/index.js +9 -4
- package/dist/sdk/item-children.js +21 -8
- package/dist/sdk/lifecycle/create.js +129 -97
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.d.ts +15 -0
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +25 -0
- package/dist/sdk/lifecycle/update.d.ts +2 -0
- package/dist/sdk/lifecycle/update.js +174 -84
- package/dist/sdk/merge/three-way.js +105 -26
- package/dist/sdk/query/complete-list.d.ts +3 -3
- package/dist/sdk/query/complete-list.js +46 -3
- package/dist/sdk/query/list.d.ts +4 -3
- package/dist/sdk/query/list.js +89 -49
- package/dist/sdk/read-output-budget.d.ts +21 -0
- package/dist/sdk/read-output-budget.js +39 -2
- package/dist/sdk/read-output-contracts.d.ts +10 -4
- package/dist/sdk/read-output-contracts.js +105 -32
- package/dist/sdk/relationship-context.js +3 -4
- package/dist/sdk/relationships.js +17 -10
- package/dist/sdk/reproducibility/process.d.ts +19 -0
- package/dist/sdk/reproducibility/process.js +88 -0
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime.d.ts +3 -2
- package/dist/sdk/runtime.js +7 -5
- package/dist/sdk/test/batch.d.ts +6 -0
- package/dist/sdk/test/batch.js +26 -6
- package/dist/sdk/test/entry.d.ts +1 -1
- package/dist/sdk/test/entry.js +3 -2
- package/dist/sdk/test/execution.d.ts +28 -3
- package/dist/sdk/test/execution.js +201 -34
- package/dist/sdk/test/parsers.d.ts +6 -0
- package/dist/sdk/test/parsers.js +21 -2
- package/dist/sdk/test/trust.d.ts +33 -0
- package/dist/sdk/test/trust.js +207 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +2 -2
- package/docs/AGENT_PROVENANCE_ADR.md +41 -5
- package/docs/AGENT_UX_CONTRACTS.md +20 -4
- package/docs/COMMANDS.md +29 -14
- package/docs/CONFIGURATION.md +4 -0
- package/docs/DEPENDENCY_KIND_CONTRACT.md +31 -3
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +115 -0
- package/docs/EXTENSIONS.md +2 -1
- package/docs/MERGE_SAFETY.md +15 -1
- package/docs/README.md +1 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +19 -2
- package/docs/RELATIONSHIP_GRAPH.md +6 -3
- package/docs/REPRODUCIBLE_WORKSPACES.md +42 -8
- package/docs/SDK.md +9 -0
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +6 -4
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +1 -1
- package/docs/TESTING.md +83 -1
- package/docs/agent-task-token-baseline.json +2 -2
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
- package/marketplace.json +2 -2
- package/package.json +2 -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-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +1021 -53
- package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +0 -197
- package/dist/cli-bundle/chunks/chunk-3AFAUHUE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-7VHZS727.js +0 -5
- package/dist/cli-bundle/chunks/chunk-JSLOFXGA.js +0 -3
- package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +0 -35
- package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +0 -13
- package/dist/cli-bundle/chunks/register-mutation-7IY2D5KO.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-FALL3YTU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +0 -50
- package/dist/cli-bundle/focused-chunks/chunk-CKKQSJNN.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-F2A56DHV.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-JEAVFOWM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-TJ7EMJ46.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-ZOSEELYJ.js +0 -26
package/dist/mcp/server.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Runs the MCP server adapter that exposes pm actions and contracts to external agents.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="740314ae-4228-5187-a939-f438fea48415")}catch(e){}}();
|
|
9
9
|
import { realpathSync } from "node:fs";
|
|
10
10
|
import { readFile } from "node:fs/promises";
|
|
11
11
|
import path from "node:path";
|
|
@@ -20,6 +20,7 @@ import { PM_MCP_PROMPT_CONTRACTS, PM_MCP_RESOURCE_CONTRACTS, } from "../sdk/agen
|
|
|
20
20
|
import { commitItemMutations } from "../sdk/item-transaction.js";
|
|
21
21
|
import { isRuntimeRecord } from "../sdk/runtime-input.js";
|
|
22
22
|
import { attachOutputTokenAccounting } from "../sdk/output-token-accounting.js";
|
|
23
|
+
import { createReproducibleProcessRunner, runWithReproducibleProcessEnvironment, } from "../sdk/reproducibility/process.js";
|
|
23
24
|
import { parseAtomicMutationControls, resolveItemMutationDocument, } from "../sdk/structured-mutations.js";
|
|
24
25
|
import { resolveAuthor, resolvePmRoot } from "../sdk/runtime-primitives.js";
|
|
25
26
|
const PM_PACKAGE_ROOT_ENV = "PM_CLI_PACKAGE_ROOT";
|
|
@@ -227,17 +228,18 @@ function resultContent(result, warnings, tokenAccounting = false) {
|
|
|
227
228
|
function errorContent(error) {
|
|
228
229
|
const code = error instanceof PmCliError ? error.exitCode : 1;
|
|
229
230
|
const message = error instanceof Error ? error.message : String(error);
|
|
231
|
+
const details = error instanceof PmCliError ? error.context : undefined;
|
|
230
232
|
return {
|
|
231
233
|
isError: true,
|
|
232
234
|
content: [
|
|
233
235
|
{
|
|
234
236
|
type: "text",
|
|
235
|
-
text: JSON.stringify({ error: message, code }, null, 2),
|
|
237
|
+
text: JSON.stringify({ error: message, code, details }, null, 2),
|
|
236
238
|
},
|
|
237
239
|
],
|
|
238
240
|
// Keep `result` present on the error envelope so consumers can read
|
|
239
241
|
// `structuredContent.result` uniformly across success and failure (pm-l40h).
|
|
240
|
-
structuredContent: { result: null, error: message, code },
|
|
242
|
+
structuredContent: { result: null, error: message, code, details },
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
245
|
/** Retain at most 32 own, valid provenance values without cloning unbounded input. */
|
|
@@ -403,7 +405,7 @@ function renderWorkflowPrompt(params) {
|
|
|
403
405
|
};
|
|
404
406
|
}
|
|
405
407
|
/** Implements handle request for the public runtime surface of this module. */
|
|
406
|
-
|
|
408
|
+
async function handleRequestInReproducibleContext(request) {
|
|
407
409
|
if (!request.id && request.method?.startsWith("notifications/")) {
|
|
408
410
|
return undefined;
|
|
409
411
|
}
|
|
@@ -459,19 +461,24 @@ export async function handleRequest(request) {
|
|
|
459
461
|
}
|
|
460
462
|
throw new PmCliError(`Unsupported MCP method: ${request.method ?? "(missing)"}`, 64);
|
|
461
463
|
}
|
|
464
|
+
/** Dispatch one MCP request under supported process-level reproducibility settings. */
|
|
465
|
+
export async function handleRequest(request) {
|
|
466
|
+
return runWithReproducibleProcessEnvironment(process.env, () => handleRequestInReproducibleContext(request));
|
|
467
|
+
}
|
|
462
468
|
function writeResponse(id, payload) {
|
|
463
469
|
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, result: payload })}\n`);
|
|
464
470
|
}
|
|
465
471
|
function writeError(id, error) {
|
|
466
472
|
const code = error instanceof PmCliError ? error.exitCode : -32603;
|
|
467
473
|
const message = error instanceof Error ? error.message : String(error);
|
|
468
|
-
|
|
474
|
+
const data = error instanceof PmCliError ? error.context : undefined;
|
|
475
|
+
process.stdout.write(`${JSON.stringify({ jsonrpc: "2.0", id, error: { code, message, data } })}\n`);
|
|
469
476
|
}
|
|
470
477
|
// pm-3puw: parse one JSON-RPC line, dispatch it, and write the response. Kept
|
|
471
478
|
// as a standalone async unit so the stdio loop can enqueue it onto a serial
|
|
472
479
|
// queue (process lines in arrival order) and tests can drive it directly.
|
|
473
480
|
/** Implements process rpc line for the public runtime surface of this module. */
|
|
474
|
-
|
|
481
|
+
async function processRpcLineWithHandler(line, requestHandler) {
|
|
475
482
|
if (line.trim().length === 0) {
|
|
476
483
|
return;
|
|
477
484
|
}
|
|
@@ -492,7 +499,7 @@ export async function processRpcLine(line) {
|
|
|
492
499
|
}
|
|
493
500
|
const shouldRespond = Object.prototype.hasOwnProperty.call(request, "id");
|
|
494
501
|
try {
|
|
495
|
-
const result = await
|
|
502
|
+
const result = await requestHandler(request);
|
|
496
503
|
if (shouldRespond && result !== undefined) {
|
|
497
504
|
writeResponse(request.id, result);
|
|
498
505
|
}
|
|
@@ -509,6 +516,10 @@ export async function processRpcLine(line) {
|
|
|
509
516
|
}
|
|
510
517
|
}
|
|
511
518
|
}
|
|
519
|
+
/** Implements process rpc line for the public runtime surface of this module. */
|
|
520
|
+
export async function processRpcLine(line) {
|
|
521
|
+
await processRpcLineWithHandler(line, handleRequest);
|
|
522
|
+
}
|
|
512
523
|
/** Implements start mcp server for the public runtime surface of this module. */
|
|
513
524
|
export function startMcpServer() {
|
|
514
525
|
const rl = readline.createInterface({
|
|
@@ -520,8 +531,18 @@ export function startMcpServer() {
|
|
|
520
531
|
// concurrently, so a client that pipelined two mutations on the same item
|
|
521
532
|
// (without awaiting the first response) hit a lock conflict on the second.
|
|
522
533
|
const queue = createSerialQueue();
|
|
534
|
+
let processLine;
|
|
535
|
+
try {
|
|
536
|
+
const runInProcessContext = createReproducibleProcessRunner(process.env);
|
|
537
|
+
processLine = (line) => runInProcessContext(() => processRpcLineWithHandler(line, handleRequestInReproducibleContext));
|
|
538
|
+
}
|
|
539
|
+
catch {
|
|
540
|
+
// Preserve one typed JSON-RPC error per request when process configuration
|
|
541
|
+
// is invalid; processRpcLine resolves the same configuration fail-closed.
|
|
542
|
+
processLine = processRpcLine;
|
|
543
|
+
}
|
|
523
544
|
rl.on("line", (line) => {
|
|
524
|
-
void queue.enqueue(() =>
|
|
545
|
+
void queue.enqueue(() => processLine(line));
|
|
525
546
|
});
|
|
526
547
|
}
|
|
527
548
|
// npm bin entries are symlinks (node_modules/.bin/pm-mcp -> dist/mcp/server.js),
|
|
@@ -621,4 +642,4 @@ if (isInvokedAsMcpMainModule(process.argv[1], import.meta.url)) {
|
|
|
621
642
|
}
|
|
622
643
|
/* c8 ignore stop */
|
|
623
644
|
//# sourceMappingURL=server.js.map
|
|
624
|
-
//# debugId=
|
|
645
|
+
//# debugId=740314ae-4228-5187-a939-f438fea48415
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/agent-identity-config
|
|
3
|
+
*
|
|
4
|
+
* Pure and versioned mutation planning for legacy author interpretation. The
|
|
5
|
+
* public summaries deliberately expose counts and revisions, never alias
|
|
6
|
+
* spellings, so config discovery is useful without leaking historical names.
|
|
7
|
+
*/
|
|
8
|
+
/** Persisted legacy-author interpretation vocabulary. */
|
|
9
|
+
export interface AgentIdentityVocabulary {
|
|
10
|
+
/** Monotonic interpretation revision. */
|
|
11
|
+
version: number;
|
|
12
|
+
/** Exact legacy author spelling to canonical harness namespace. */
|
|
13
|
+
aliases: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
/** Privacy-safe vocabulary projection used by config get/list/export. */
|
|
16
|
+
export interface AgentIdentityVocabularySummary {
|
|
17
|
+
/** Current interpretation revision. */
|
|
18
|
+
version: number;
|
|
19
|
+
/** Number of exact legacy spellings configured. */
|
|
20
|
+
alias_count: number;
|
|
21
|
+
}
|
|
22
|
+
/** Supported vocabulary mutations. */
|
|
23
|
+
export type AgentIdentityVocabularyOperation = "add" | "remove" | "clear";
|
|
24
|
+
/** One typed vocabulary mutation and optional residual-coverage census. */
|
|
25
|
+
export interface AgentIdentityVocabularyMutationInput {
|
|
26
|
+
/** Exact operation applied to the vocabulary. */
|
|
27
|
+
operation: AgentIdentityVocabularyOperation;
|
|
28
|
+
/** Exact legacy spelling required by add/remove. */
|
|
29
|
+
legacy_author?: string;
|
|
30
|
+
/** Canonical lowercase harness namespace required by add. */
|
|
31
|
+
canonical_harness?: string;
|
|
32
|
+
/** Optional bounded author census used only to count still-unmapped values. */
|
|
33
|
+
observed_authors?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/** Privacy-safe dry-run or committed mutation preview. */
|
|
36
|
+
export interface AgentIdentityVocabularyMutationPreview {
|
|
37
|
+
/** Operation that was evaluated. */
|
|
38
|
+
operation: AgentIdentityVocabularyOperation;
|
|
39
|
+
/** Whether persistence would change. */
|
|
40
|
+
changed: boolean;
|
|
41
|
+
/** Revision before the operation. */
|
|
42
|
+
version_before: number;
|
|
43
|
+
/** Revision after the operation, equal when idempotent. */
|
|
44
|
+
version_after: number;
|
|
45
|
+
/** Alias count after the operation. */
|
|
46
|
+
alias_count: number;
|
|
47
|
+
/** Unique non-canonical authors not covered after the operation. */
|
|
48
|
+
residual_author_count: number;
|
|
49
|
+
}
|
|
50
|
+
/** Planned vocabulary plus a privacy-safe result preview. */
|
|
51
|
+
export interface AgentIdentityVocabularyMutationPlan {
|
|
52
|
+
/** Complete value suitable for settings persistence. */
|
|
53
|
+
vocabulary: AgentIdentityVocabulary;
|
|
54
|
+
/** Public mutation result with no alias spellings. */
|
|
55
|
+
preview: AgentIdentityVocabularyMutationPreview;
|
|
56
|
+
}
|
|
57
|
+
/** Return only the revision and count suitable for config discovery surfaces. */
|
|
58
|
+
export declare function summarizeAgentIdentityVocabulary(vocabulary: AgentIdentityVocabulary | undefined): AgentIdentityVocabularySummary;
|
|
59
|
+
/**
|
|
60
|
+
* Validate and plan one exact mutation. A real change increments the revision
|
|
61
|
+
* exactly once; identical adds and absent removes are idempotent.
|
|
62
|
+
*/
|
|
63
|
+
export declare function planAgentIdentityVocabularyMutation(current: AgentIdentityVocabulary | undefined, input: AgentIdentityVocabularyMutationInput): AgentIdentityVocabularyMutationPlan;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/agent-identity-config
|
|
3
|
+
*
|
|
4
|
+
* Pure and versioned mutation planning for legacy author interpretation. The
|
|
5
|
+
* public summaries deliberately expose counts and revisions, never alias
|
|
6
|
+
* spellings, so config discovery is useful without leaking historical names.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="09703f32-9491-5d3a-9f90-f038d9982e17")}catch(e){}}();
|
|
10
|
+
const HARNESS_NAMESPACE_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
11
|
+
const MAX_AUTHOR_LENGTH = 128;
|
|
12
|
+
const MAX_OBSERVED_AUTHORS = 10_000;
|
|
13
|
+
function requireLegacyAuthor(value) {
|
|
14
|
+
const author = value?.trim();
|
|
15
|
+
if (!author || author === "__proto__" || author.length > MAX_AUTHOR_LENGTH) {
|
|
16
|
+
throw new Error(`A legacy author must contain 1-${MAX_AUTHOR_LENGTH} characters.`);
|
|
17
|
+
}
|
|
18
|
+
return author;
|
|
19
|
+
}
|
|
20
|
+
function requireCanonicalHarness(value) {
|
|
21
|
+
const harness = value?.trim().toLowerCase();
|
|
22
|
+
if (!harness || !HARNESS_NAMESPACE_PATTERN.test(harness)) {
|
|
23
|
+
throw new Error("A canonical harness must be a lowercase dash-separated namespace.");
|
|
24
|
+
}
|
|
25
|
+
return harness;
|
|
26
|
+
}
|
|
27
|
+
function orderedAliases(aliases) {
|
|
28
|
+
return Object.fromEntries(Object.entries(aliases).sort(([left], [right]) => left.localeCompare(right)));
|
|
29
|
+
}
|
|
30
|
+
function countResidualAuthors(observed, aliases) {
|
|
31
|
+
const residual = new Set();
|
|
32
|
+
for (const raw of (observed ?? []).slice(0, MAX_OBSERVED_AUTHORS)) {
|
|
33
|
+
const author = raw.trim().slice(0, MAX_AUTHOR_LENGTH);
|
|
34
|
+
if (author.length === 0 ||
|
|
35
|
+
author.startsWith("harness:") ||
|
|
36
|
+
Object.hasOwn(aliases, author)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
residual.add(author);
|
|
40
|
+
}
|
|
41
|
+
return residual.size;
|
|
42
|
+
}
|
|
43
|
+
function applyAddOperation(aliases, input) {
|
|
44
|
+
const legacyAuthor = requireLegacyAuthor(input.legacy_author);
|
|
45
|
+
const canonicalHarness = requireCanonicalHarness(input.canonical_harness);
|
|
46
|
+
if (legacyAuthor === canonicalHarness ||
|
|
47
|
+
legacyAuthor === `harness:${canonicalHarness}` ||
|
|
48
|
+
legacyAuthor.startsWith("harness:")) {
|
|
49
|
+
throw new Error(`The legacy author "${legacyAuthor}" is already canonical and must not be aliased.`);
|
|
50
|
+
}
|
|
51
|
+
if (aliases[legacyAuthor] === canonicalHarness)
|
|
52
|
+
return false;
|
|
53
|
+
aliases[legacyAuthor] = canonicalHarness;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
function applyVocabularyOperation(aliases, input) {
|
|
57
|
+
if (input.operation === "add")
|
|
58
|
+
return applyAddOperation(aliases, input);
|
|
59
|
+
if (input.operation === "remove") {
|
|
60
|
+
const legacyAuthor = requireLegacyAuthor(input.legacy_author);
|
|
61
|
+
if (!Object.hasOwn(aliases, legacyAuthor))
|
|
62
|
+
return false;
|
|
63
|
+
delete aliases[legacyAuthor];
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (input.operation === "clear") {
|
|
67
|
+
const changed = Object.keys(aliases).length > 0;
|
|
68
|
+
for (const key of Object.keys(aliases))
|
|
69
|
+
delete aliases[key];
|
|
70
|
+
return changed;
|
|
71
|
+
}
|
|
72
|
+
const exhaustive = input.operation;
|
|
73
|
+
throw new Error(`Unsupported vocabulary operation: ${String(exhaustive)}`);
|
|
74
|
+
}
|
|
75
|
+
/** Return only the revision and count suitable for config discovery surfaces. */
|
|
76
|
+
export function summarizeAgentIdentityVocabulary(vocabulary) {
|
|
77
|
+
return {
|
|
78
|
+
version: vocabulary?.version ?? 1,
|
|
79
|
+
alias_count: Object.keys(vocabulary?.aliases ?? {}).length,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Validate and plan one exact mutation. A real change increments the revision
|
|
84
|
+
* exactly once; identical adds and absent removes are idempotent.
|
|
85
|
+
*/
|
|
86
|
+
export function planAgentIdentityVocabularyMutation(current, input) {
|
|
87
|
+
const versionBefore = current?.version ?? 1;
|
|
88
|
+
const aliases = { ...current?.aliases };
|
|
89
|
+
const changed = applyVocabularyOperation(aliases, input);
|
|
90
|
+
const vocabulary = {
|
|
91
|
+
version: changed ? versionBefore + 1 : versionBefore,
|
|
92
|
+
aliases: orderedAliases(aliases),
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
vocabulary,
|
|
96
|
+
preview: {
|
|
97
|
+
operation: input.operation,
|
|
98
|
+
changed,
|
|
99
|
+
version_before: versionBefore,
|
|
100
|
+
version_after: vocabulary.version,
|
|
101
|
+
alias_count: Object.keys(vocabulary.aliases).length,
|
|
102
|
+
residual_author_count: countResidualAuthors(input.observed_authors, vocabulary.aliases),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=identity-config.js.map
|
|
107
|
+
//# debugId=09703f32-9491-5d3a-9f90-f038d9982e17
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type PmCommandPositionalContract } from "../cli-contracts/grammar-contracts.js";
|
|
2
|
+
/** Shared executable shape for a refusal that must not mutate tracker state. */
|
|
3
|
+
export interface PmGrammarRefusalContract {
|
|
4
|
+
/** Stable probe identity used by ratchets and evidence. */
|
|
5
|
+
probe_id: string;
|
|
6
|
+
/** Canonical command path under test. */
|
|
7
|
+
command: string;
|
|
8
|
+
/** Exact argv expected to refuse. */
|
|
9
|
+
refusal_args: readonly string[];
|
|
10
|
+
/** Exact help argv that must execute successfully after the refusal. */
|
|
11
|
+
recovery_args: readonly string[];
|
|
12
|
+
/** Stable problem-envelope code expected from the refusal. */
|
|
13
|
+
error_code: "invalid_argument_value" | "missing_lifecycle_target" | "missing_required_argument" | "unknown_subcommand";
|
|
14
|
+
}
|
|
15
|
+
/** One required positional omission derived from the grammar declaration. */
|
|
16
|
+
export interface PmRequiredArgumentRefusalContract extends PmGrammarRefusalContract {
|
|
17
|
+
/** Stable positional name deliberately omitted by the probe. */
|
|
18
|
+
missing_argument: string;
|
|
19
|
+
/** Zero-based slot index in the command's declared positional signature. */
|
|
20
|
+
missing_argument_index: number;
|
|
21
|
+
}
|
|
22
|
+
/** One invalid action probe for a closed positional subcommand family. */
|
|
23
|
+
export interface PmSubcommandRefusalContract extends PmGrammarRefusalContract {
|
|
24
|
+
/** Invalid action token used to reach the refusal. */
|
|
25
|
+
rejected_value: string;
|
|
26
|
+
/** Complete authoritative action domain expected in recovery. */
|
|
27
|
+
allowed_values: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/** Runtime evidence for one grammar-derived refusal probe. */
|
|
30
|
+
export interface PmGrammarRefusalObservation {
|
|
31
|
+
/** Probe identity matching a declared contract. */
|
|
32
|
+
probe_id: string;
|
|
33
|
+
/** Machine-readable code emitted by the refusal. */
|
|
34
|
+
error_code: string;
|
|
35
|
+
/** Process exit code emitted by the refusal. */
|
|
36
|
+
exit_code: number;
|
|
37
|
+
/** Allowed values emitted for a closed action family. */
|
|
38
|
+
allowed_values: readonly string[];
|
|
39
|
+
/** Whether the advertised help recovery exited successfully. */
|
|
40
|
+
recovery_succeeded: boolean;
|
|
41
|
+
/** Whether any tracker state changed while executing the refusal. */
|
|
42
|
+
refusal_mutated_state: boolean;
|
|
43
|
+
/** Repository-relative tracker paths changed by the refusal, when measured. */
|
|
44
|
+
mutated_paths?: readonly string[];
|
|
45
|
+
}
|
|
46
|
+
/** Stable reason a grammar-derived refusal failed closure. */
|
|
47
|
+
export type PmGrammarRefusalFindingCode = "refusal_allowed_values_mismatch" | "refusal_error_code_mismatch" | "refusal_exit_code_mismatch" | "refusal_mutated_state" | "refusal_probe_missing" | "refusal_recovery_failed" | "unexpected_refusal_probe";
|
|
48
|
+
/** One actionable grammar-derived refusal closure failure. */
|
|
49
|
+
export interface PmGrammarRefusalFinding {
|
|
50
|
+
/** Stable machine-readable failure category. */
|
|
51
|
+
code: PmGrammarRefusalFindingCode;
|
|
52
|
+
/** Probe associated with the finding. */
|
|
53
|
+
probe_id: string;
|
|
54
|
+
/** Human-readable failure detail. */
|
|
55
|
+
detail: string;
|
|
56
|
+
}
|
|
57
|
+
/** Aggregate closure receipt for the grammar-derived refusal corpus. */
|
|
58
|
+
export interface PmGrammarRefusalClosureReport {
|
|
59
|
+
/** Whether every declared probe refused safely and recovered. */
|
|
60
|
+
ok: boolean;
|
|
61
|
+
/** Number of declared probes. */
|
|
62
|
+
probe_count: number;
|
|
63
|
+
/** Number of probes without findings. */
|
|
64
|
+
closed_probe_count: number;
|
|
65
|
+
/** Stable actionable failures. */
|
|
66
|
+
findings: PmGrammarRefusalFinding[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Return one omission probe for every required slot in the declared grammar.
|
|
70
|
+
* Earlier positionals receive deterministic, non-mutating placeholder values.
|
|
71
|
+
*/
|
|
72
|
+
export declare function listPmRequiredArgumentRefusalContracts(contracts?: readonly PmCommandPositionalContract[]): PmRequiredArgumentRefusalContract[];
|
|
73
|
+
/** Return one invalid-action probe for every required positional action family. */
|
|
74
|
+
export declare function listPmSubcommandRefusalContracts(contracts?: readonly PmCommandPositionalContract[]): PmSubcommandRefusalContract[];
|
|
75
|
+
/** Score exact code, exit, domain, state-safety, and recovery closure. */
|
|
76
|
+
export declare function scorePmGrammarRefusalClosure(contracts: readonly (PmRequiredArgumentRefusalContract | PmSubcommandRefusalContract)[], observations: readonly PmGrammarRefusalObservation[]): PmGrammarRefusalClosureReport;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/agent/refusal-corpus-contracts
|
|
3
|
+
*
|
|
4
|
+
* Derives executable refusal probes from the public CLI grammar. The corpus is
|
|
5
|
+
* fail-closed: adding a required positional slot or action-dispatching command
|
|
6
|
+
* automatically adds a probe, while an action family without an authoritative
|
|
7
|
+
* value domain throws during contract construction.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2e90ea29-2708-5af8-b390-599be97718e7")}catch(e){}}();
|
|
11
|
+
import { PLAN_SUBCOMMANDS } from "../lifecycle/plan.js";
|
|
12
|
+
import { PROFILE_SUBCOMMANDS } from "../profile.js";
|
|
13
|
+
import { SCHEMA_SUBCOMMANDS } from "../schema.js";
|
|
14
|
+
import { GRAPH_SUBCOMMAND_VALUES, MERGE_SUBCOMMAND_VALUES, } from "../cli-contracts/enum-contracts.js";
|
|
15
|
+
import { PM_COMMAND_DESTINATION_CONTRACTS, PM_COMMAND_POSITIONAL_CONTRACTS, PM_POSITIONAL_ACTION_CONTRACTS, } from "../cli-contracts/grammar-contracts.js";
|
|
16
|
+
import { resolveSubcommandFlagContractsForCommand } from "../cli-contracts/flag-contracts.js";
|
|
17
|
+
const REJECTED_ACTION = "not-a-declared-action";
|
|
18
|
+
function positionalPlaceholder(command, slot) {
|
|
19
|
+
if (command.startsWith("assurance ") && slot.name === "kind") {
|
|
20
|
+
return "measurement";
|
|
21
|
+
}
|
|
22
|
+
switch (slot.value_kind) {
|
|
23
|
+
case "integer":
|
|
24
|
+
return "1";
|
|
25
|
+
case "item_id":
|
|
26
|
+
return "pm-domain";
|
|
27
|
+
case "action":
|
|
28
|
+
throw new Error(`Cannot synthesize a preceding action value for positional slot ${slot.name}.`);
|
|
29
|
+
default:
|
|
30
|
+
return "example";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function probeSlug(value) {
|
|
34
|
+
return value.replaceAll(/[^a-z0-9]+/gu, "-").replaceAll(/^-|-$/gu, "");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Return one omission probe for every required slot in the declared grammar.
|
|
38
|
+
* Earlier positionals receive deterministic, non-mutating placeholder values.
|
|
39
|
+
*/
|
|
40
|
+
export function listPmRequiredArgumentRefusalContracts(contracts = PM_COMMAND_POSITIONAL_CONTRACTS.filter((contract) => PM_COMMAND_DESTINATION_CONTRACTS.some((destination) => destination.command === contract.command &&
|
|
41
|
+
destination.disposition !== "package_owned"))) {
|
|
42
|
+
return contracts
|
|
43
|
+
.flatMap((contract) => contract.slots.flatMap((slot, index) => {
|
|
44
|
+
if (!slot.required)
|
|
45
|
+
return [];
|
|
46
|
+
const commandArguments = contract.command.split(" ");
|
|
47
|
+
const requiredFlagArguments = resolveSubcommandFlagContractsForCommand(contract.command).flatMap((flagContract) => flagContract.required
|
|
48
|
+
? [
|
|
49
|
+
flagContract.flag,
|
|
50
|
+
...(flagContract.value_name ? ["example"] : []),
|
|
51
|
+
]
|
|
52
|
+
: []);
|
|
53
|
+
const isVirtualAction = PM_POSITIONAL_ACTION_CONTRACTS.some((actionContract) => actionContract.command === contract.command);
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
probe_id: `required-argument-${probeSlug(contract.command)}-${probeSlug(slot.name)}`,
|
|
57
|
+
command: contract.command,
|
|
58
|
+
refusal_args: [
|
|
59
|
+
...commandArguments,
|
|
60
|
+
...contract.slots
|
|
61
|
+
.slice(0, index)
|
|
62
|
+
.map((priorSlot) => positionalPlaceholder(contract.command, priorSlot)),
|
|
63
|
+
...requiredFlagArguments,
|
|
64
|
+
],
|
|
65
|
+
recovery_args: [...commandArguments, "--help"],
|
|
66
|
+
error_code: isVirtualAction && !contract.command.startsWith("assurance ")
|
|
67
|
+
? "invalid_argument_value"
|
|
68
|
+
: /^extension (?:activate|adopt|deactivate|uninstall)$/u.test(contract.command)
|
|
69
|
+
? "missing_lifecycle_target"
|
|
70
|
+
: "missing_required_argument",
|
|
71
|
+
missing_argument: slot.name,
|
|
72
|
+
missing_argument_index: index,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}))
|
|
76
|
+
.sort((left, right) => left.probe_id.localeCompare(right.probe_id));
|
|
77
|
+
}
|
|
78
|
+
function positionalActionValues(command) {
|
|
79
|
+
switch (command) {
|
|
80
|
+
case "assurance":
|
|
81
|
+
case "workspace snapshot":
|
|
82
|
+
return PM_POSITIONAL_ACTION_CONTRACTS.filter(({ parent }) => parent === command).map(({ action }) => action);
|
|
83
|
+
case "graph":
|
|
84
|
+
return GRAPH_SUBCOMMAND_VALUES;
|
|
85
|
+
case "merge":
|
|
86
|
+
return MERGE_SUBCOMMAND_VALUES;
|
|
87
|
+
case "plan":
|
|
88
|
+
return PLAN_SUBCOMMANDS;
|
|
89
|
+
case "profile":
|
|
90
|
+
return PROFILE_SUBCOMMANDS;
|
|
91
|
+
case "schema":
|
|
92
|
+
return SCHEMA_SUBCOMMANDS;
|
|
93
|
+
default:
|
|
94
|
+
throw new Error(`Required positional action family ${command} has no authoritative value domain.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** Return one invalid-action probe for every required positional action family. */
|
|
98
|
+
export function listPmSubcommandRefusalContracts(contracts = PM_COMMAND_POSITIONAL_CONTRACTS) {
|
|
99
|
+
return contracts
|
|
100
|
+
.filter(({ slots }) => slots[0]?.required === true && slots[0].value_kind === "action")
|
|
101
|
+
.map(({ command }) => {
|
|
102
|
+
const commandArguments = command.split(" ");
|
|
103
|
+
return {
|
|
104
|
+
probe_id: `unknown-subcommand-${probeSlug(command)}`,
|
|
105
|
+
command,
|
|
106
|
+
refusal_args: [...commandArguments, REJECTED_ACTION],
|
|
107
|
+
recovery_args: [...commandArguments, "--help"],
|
|
108
|
+
error_code: "unknown_subcommand",
|
|
109
|
+
rejected_value: REJECTED_ACTION,
|
|
110
|
+
allowed_values: [...positionalActionValues(command)].sort(),
|
|
111
|
+
};
|
|
112
|
+
})
|
|
113
|
+
.sort((left, right) => left.probe_id.localeCompare(right.probe_id));
|
|
114
|
+
}
|
|
115
|
+
function sameValues(left, right) {
|
|
116
|
+
const sortedRight = [...right].sort();
|
|
117
|
+
return (left.length === right.length &&
|
|
118
|
+
[...left].sort().every((value, index) => value === sortedRight[index]));
|
|
119
|
+
}
|
|
120
|
+
function scoreGrammarRefusalObservation(contract, observation) {
|
|
121
|
+
if (!observation) {
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
code: "refusal_probe_missing",
|
|
125
|
+
probe_id: contract.probe_id,
|
|
126
|
+
detail: `${contract.probe_id} has no runtime observation.`,
|
|
127
|
+
},
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
const findings = [];
|
|
131
|
+
if (observation.error_code !== contract.error_code) {
|
|
132
|
+
findings.push({
|
|
133
|
+
code: "refusal_error_code_mismatch",
|
|
134
|
+
probe_id: contract.probe_id,
|
|
135
|
+
detail: `${contract.probe_id} emitted ${observation.error_code || "<none>"}; expected ${contract.error_code}.`,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (observation.exit_code !== 2) {
|
|
139
|
+
findings.push({
|
|
140
|
+
code: "refusal_exit_code_mismatch",
|
|
141
|
+
probe_id: contract.probe_id,
|
|
142
|
+
detail: `${contract.probe_id} exited ${observation.exit_code}; expected usage exit 2.`,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
if ("allowed_values" in contract &&
|
|
146
|
+
!sameValues(observation.allowed_values, contract.allowed_values)) {
|
|
147
|
+
findings.push({
|
|
148
|
+
code: "refusal_allowed_values_mismatch",
|
|
149
|
+
probe_id: contract.probe_id,
|
|
150
|
+
detail: `${contract.probe_id} did not expose its complete action domain.`,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (!observation.recovery_succeeded) {
|
|
154
|
+
findings.push({
|
|
155
|
+
code: "refusal_recovery_failed",
|
|
156
|
+
probe_id: contract.probe_id,
|
|
157
|
+
detail: `${contract.probe_id} help recovery did not succeed.`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (observation.refusal_mutated_state) {
|
|
161
|
+
findings.push({
|
|
162
|
+
code: "refusal_mutated_state",
|
|
163
|
+
probe_id: contract.probe_id,
|
|
164
|
+
detail: `${contract.probe_id} changed tracker state while refusing input${observation.mutated_paths?.length ? `: ${observation.mutated_paths.join(", ")}` : "."}`,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
return findings;
|
|
168
|
+
}
|
|
169
|
+
/** Score exact code, exit, domain, state-safety, and recovery closure. */
|
|
170
|
+
export function scorePmGrammarRefusalClosure(contracts, observations) {
|
|
171
|
+
const contractsById = new Map(contracts.map((contract) => [contract.probe_id, contract]));
|
|
172
|
+
const observationsById = new Map(observations.map((observation) => [observation.probe_id, observation]));
|
|
173
|
+
const findings = [
|
|
174
|
+
...contracts.flatMap((contract) => scoreGrammarRefusalObservation(contract, observationsById.get(contract.probe_id))),
|
|
175
|
+
...observations
|
|
176
|
+
.filter((observation) => !contractsById.has(observation.probe_id))
|
|
177
|
+
.map((observation) => ({
|
|
178
|
+
code: "unexpected_refusal_probe",
|
|
179
|
+
probe_id: observation.probe_id,
|
|
180
|
+
detail: `${observation.probe_id} has no declared grammar refusal contract.`,
|
|
181
|
+
})),
|
|
182
|
+
];
|
|
183
|
+
findings.sort((left, right) => left.probe_id.localeCompare(right.probe_id) ||
|
|
184
|
+
left.code.localeCompare(right.code));
|
|
185
|
+
const failedProbeIds = new Set(findings.map(({ probe_id: probeId }) => probeId));
|
|
186
|
+
return {
|
|
187
|
+
ok: findings.length === 0,
|
|
188
|
+
probe_count: contracts.length,
|
|
189
|
+
closed_probe_count: contracts.filter(({ probe_id: probeId }) => !failedProbeIds.has(probeId)).length,
|
|
190
|
+
findings,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=refusal-corpus-contracts.js.map
|
|
194
|
+
//# debugId=2e90ea29-2708-5af8-b390-599be97718e7
|
|
@@ -37,7 +37,7 @@ export type PmRecoveryReferenceKind = (typeof PM_RECOVERY_REFERENCE_KINDS)[numbe
|
|
|
37
37
|
/** Behavioral promise attached to a recovery reference. */
|
|
38
38
|
export type PmRecoveryReferenceSemantics = "recovery" | "replacement" | "behavior_preserving";
|
|
39
39
|
/** Literal envelope fields recognized as recovery-reference producers. */
|
|
40
|
-
export declare const PM_RECOVERY_REFERENCE_FIELDS: readonly ("
|
|
40
|
+
export declare const PM_RECOVERY_REFERENCE_FIELDS: readonly ("suggested_retry" | "next_best_command" | "candidate_commands" | "next_steps" | "examples" | "restore_with" | "migration_hint" | "migration_hints" | "fallback_candidates" | "suggested_next_steps" | "example" | "candidate_command" | "next_step" | "retry_command")[];
|
|
41
41
|
/** One source file supplied to the producer-census analyzer. */
|
|
42
42
|
export interface PmRecoveryProducerSource {
|
|
43
43
|
/** Repository-relative source path. */
|
package/dist/sdk/authoring.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ export { planProfileApplication, type ProfileApplicationPlan, type ProfileChange
|
|
|
15
15
|
export { EXTENSION_CAPABILITY_REGISTRATION_SURFACES, collectUsedExtensionCapabilities, reconcileExtensionCapabilityUsage, type CollectUsedExtensionCapabilitiesOptions, type ExtensionCapabilityUsageReconciliation, } from "../core/extensions/capability-usage.js";
|
|
16
16
|
export { renderExtensionSurfaceMarkdown, type ExtensionSurfaceMarkdownOptions, } from "../core/extensions/activation-summary-markdown.js";
|
|
17
17
|
export { createExtensionContributionInventory, normalizeExtensionContributionInventory, } from "../core/extensions/contribution-inventory.js";
|
|
18
|
-
export type { AfterCommandAffectedItem, AfterCommandHook, AfterCommandHookContext, BeforeCommandHook, BeforeCommandHookContext, BeforeMutationHook, BeforeMutationHookContext, BeforeMutationHookDecision, CommandDefinition, ExtensionCommandArgumentDefinition, CommandHandler, CommandHandlerContext, CommandHandlerResult, ExtensionCommandSdk, CommandOverride, CommandOverrideContext, ExtensionServiceName, Exporter, ExporterArtifactOutputContract, ExporterRegistrationOptions, ExtensionActivationResult, ExtensionApi, ExtensionCommandRegistry, ExtensionDeactivationFailure, ExtensionDeactivationOptions, ExtensionDeactivationResult, ExtensionDiagnostic, ExtensionContributionInventory, ExtensionDiscoveryResult, ExtensionHookRegistry, ExtensionSelfIdentity, ExtensionLoadResult, ExtensionManifest, ExtensionManifestEngines, ExtensionMutationGuardSdk, ExtensionGovernancePolicy, ExtensionPolicyOverride, ExtensionProvenanceMetadata, ExtensionRuntimePermissionDeclaration, ExtensionSearchMode, ExtensionParserRegistry, ExtensionPreflightRegistry, ExtensionRegistrationRegistry, ExtensionRendererRegistry, ExtensionServiceRegistry, FlagValueType, FlagDefinition, ImportExportContext, ImportExportRegistrationOptions, Importer, OnIndexHook, OnIndexHookContext, OnReadHook, OnReadHookContext, OnWriteHook, OnWriteHookContext, OutputRendererFormat, ParserOverride, ParserOverrideContext, ParserOverrideDelta, PreflightOverride, PreflightOverrideContext, PreflightOverrideDelta, PreflightRuntimeDecision, RegisteredExtensionExporter, RegisteredExporterArtifactOutputContract, RegisteredExtensionFlagDefinitions, RegisteredExtensionHook, RegisteredExtensionImporter, RegisteredExtensionProjectProfile, RegisteredExtensionSchemaMigrationDefinition, RegisteredExtensionSearchProvider, RegisteredExtensionServiceOverride, RegisteredExtensionVectorStoreAdapter, RendererOverride, RendererOverrideContext, SchemaFieldDefinition, SchemaItemTypeCommandOptionPolicyDefinition, SchemaItemTypeOptionDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SchemaMigrationRunContext, SchemaMigrationRunner, SearchProviderEmbedBatchContext, SearchProviderEmbedContext, SearchProviderDefinition, SearchProviderHit, SearchProviderQueryContext, SearchProviderQueryResult, ServiceOverride, ServiceOverrideContext, ServiceOverrideDecision, VectorStoreAdapterDefinition, VectorStoreDeleteContext, VectorStoreQueryContext, VectorStoreQueryHit, VectorStoreUpsertContext, VectorStoreUpsertPoint, } from "../core/extensions/loader.js";
|
|
18
|
+
export type { AfterCommandAffectedItem, AfterCommandHook, AfterCommandHookContext, BeforeCommandHook, BeforeCommandHookContext, BeforeMutationHook, BeforeMutationHookContext, BeforeMutationHookDecision, CommandDefinition, ExtensionCommandArgumentDefinition, CommandHandler, CommandHandlerContext, CommandHandlerResult, ExtensionCommandSdk, CommandOverride, CommandOverrideContext, ExtensionServiceName, Exporter, ExporterArtifactOutputContract, ExporterRegistrationOptions, ExtensionActivationResult, ExtensionApi, ExtensionCommandRegistry, ExtensionDeactivationFailure, ExtensionDeactivationOptions, ExtensionDeactivationResult, ExtensionDiagnostic, ExtensionContributionInventory, ExtensionDiscoveryResult, ExtensionHookRegistry, ExtensionSelfIdentity, ExtensionLoadResult, ExtensionManifest, ExtensionManifestEngines, ExtensionMutationGuardSdk, ExtensionGovernancePolicy, ExtensionPolicyOverride, ExtensionProvenanceMetadata, ExtensionRuntimePermissionDeclaration, ExtensionSearchMode, ExtensionParserRegistry, ExtensionPreflightRegistry, ExtensionRegistrationRegistry, ExtensionRendererRegistry, ExtensionServiceRegistry, FlagValueType, FlagDefinition, ImportExportContext, ImportExportRegistrationOptions, Importer, OnIndexHook, OnIndexHookContext, OnReadHook, OnReadHookContext, OnWriteHook, OnWriteHookContext, OutputRendererFormat, ParserOverride, ParserOverrideContext, ParserOverrideDelta, PreflightOverride, PreflightOverrideContext, PreflightOverrideDelta, PreflightRuntimeDecision, RegisteredExtensionExporter, RegisteredExporterArtifactOutputContract, RegisteredExtensionFlagDefinitions, RegisteredExtensionHook, RegisteredExtensionImporter, RegisteredExtensionProjectProfile, RegisteredExtensionSchemaMigrationDefinition, RegisteredExtensionSearchProvider, RegisteredExtensionServiceOverride, RegisteredExtensionVectorStoreAdapter, RendererOverride, RendererOverrideContext, SchemaFieldDefinition, SchemaItemTypeCommandOptionPolicyDefinition, SchemaItemTypeOptionDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SchemaMigrationRunContext, SchemaMigrationRunner, SearchProviderEmbedBatchContext, SearchProviderEmbedContext, SearchProviderDefinition, SearchProviderHit, SearchProviderQueryContext, SearchProviderQueryResult, ServiceOverride, ServiceOverrideContext, ServiceOverrideDecision, ServiceOverrideOwnership, VectorStoreAdapterDefinition, VectorStoreDeleteContext, VectorStoreQueryContext, VectorStoreQueryHit, VectorStoreUpsertContext, VectorStoreUpsertPoint, } from "../core/extensions/loader.js";
|
package/dist/sdk/authoring.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Provides the focused extension and package authoring surface.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bca95ba2-258c-5be2-8428-dcb8dbc87ef0")}catch(e){}}();
|
|
8
8
|
export * from "./compose.js";
|
|
9
9
|
export * from "./define.js";
|
|
10
10
|
export * from "./extension-contracts.js";
|
|
@@ -18,4 +18,4 @@ export { EXTENSION_CAPABILITY_REGISTRATION_SURFACES, collectUsedExtensionCapabil
|
|
|
18
18
|
export { renderExtensionSurfaceMarkdown, } from "../core/extensions/activation-summary-markdown.js";
|
|
19
19
|
export { createExtensionContributionInventory, normalizeExtensionContributionInventory, } from "../core/extensions/contribution-inventory.js";
|
|
20
20
|
//# sourceMappingURL=authoring.js.map
|
|
21
|
-
//# debugId=
|
|
21
|
+
//# debugId=bca95ba2-258c-5be2-8428-dcb8dbc87ef0
|