@unbrained/pm-cli 2026.8.11 → 2026.8.13
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 +74 -21
- package/dist/cli/commander-usage.js +37 -11
- package/dist/cli/error-guidance.d.ts +2 -0
- package/dist/cli/error-guidance.js +82 -19
- package/dist/cli/main.js +35 -19
- package/dist/cli/register-annotations.js +56 -3
- package/dist/cli/register-assurance.js +28 -17
- package/dist/cli/register-list-query.js +10 -7
- package/dist/cli/register-operations.js +16 -6
- package/dist/cli-bundle/bundle-manifest.json +163 -163
- package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
- package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
- package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
- package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
- package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
- package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
- package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
- package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
- package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
- package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
- package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
- package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
- package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +42 -41
- 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 +1 -1
- 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 +2 -2
- package/dist/core/checkpoint/checkpoint-gc.js +7 -12
- package/dist/core/extensions/activation-summary-markdown.js +5 -4
- package/dist/core/extensions/activation-summary.d.ts +2 -0
- package/dist/core/extensions/activation-summary.js +6 -2
- package/dist/core/extensions/capability-usage.d.ts +1 -1
- package/dist/core/extensions/capability-usage.js +4 -3
- package/dist/core/extensions/contribution-inventory.d.ts +1 -0
- package/dist/core/extensions/contribution-inventory.js +6 -2
- package/dist/core/extensions/extension-registries.js +3 -2
- package/dist/core/extensions/extension-types.d.ts +83 -1
- package/dist/core/extensions/extension-types.js +3 -2
- package/dist/core/extensions/loader.d.ts +2 -8
- package/dist/core/extensions/loader.js +53 -144
- package/dist/core/extensions/registration-values.d.ts +43 -0
- package/dist/core/extensions/registration-values.js +210 -0
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/extensions/runtime-registrations.d.ts +3 -1
- package/dist/core/extensions/runtime-registrations.js +12 -2
- package/dist/core/fs/fs-utils.d.ts +2 -0
- package/dist/core/fs/fs-utils.js +7 -3
- package/dist/core/history/drift-cache.js +4 -3
- package/dist/core/history/drift-scan.js +16 -17
- package/dist/core/history/history.d.ts +8 -0
- package/dist/core/history/history.js +57 -7
- package/dist/core/history/replay.d.ts +9 -1
- package/dist/core/history/replay.js +48 -13
- package/dist/core/lock/lock-gc.js +8 -13
- package/dist/core/lock/lock.js +5 -4
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +46 -14
- package/dist/core/search/vector-stores.js +6 -11
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/errors.d.ts +5 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/item-metadata-cache.d.ts +1 -1
- package/dist/core/store/item-metadata-cache.js +16 -9
- package/dist/core/telemetry/runtime.d.ts +6 -0
- package/dist/core/telemetry/runtime.js +101 -30
- package/dist/sdk/agent/command-recovery.d.ts +2 -0
- package/dist/sdk/agent/command-recovery.js +10 -2
- package/dist/sdk/annotations.js +4 -4
- package/dist/sdk/cli-bootstrap.d.ts +2 -0
- package/dist/sdk/cli-bootstrap.js +6 -2
- package/dist/sdk/cli-contracts/completeness.js +10 -3
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
- package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
- package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
- package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
- package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
- package/dist/sdk/cli-contracts/tool-schema.js +22 -4
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/comments.js +4 -3
- package/dist/sdk/compile-cache.js +4 -3
- package/dist/sdk/completion.js +16 -7
- package/dist/sdk/compose.d.ts +3 -1
- package/dist/sdk/compose.js +16 -2
- package/dist/sdk/context-intent-contracts.js +45 -4
- package/dist/sdk/context-signal-store.js +4 -3
- package/dist/sdk/core.d.ts +1 -0
- package/dist/sdk/core.js +3 -2
- package/dist/sdk/extension/install-runtime.js +4 -4
- package/dist/sdk/extension/managed-state.js +4 -3
- package/dist/sdk/extension-contracts.d.ts +1 -1
- package/dist/sdk/flag-invocation-contracts.js +5 -6
- package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
- package/dist/sdk/generated-error-code-catalog.js +6 -3140
- package/dist/sdk/governance/assurance-action.d.ts +27 -3
- package/dist/sdk/governance/assurance-action.js +117 -31
- package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
- package/dist/sdk/governance/assurance-mutation-error.js +58 -0
- package/dist/sdk/governance/assurance-presets.d.ts +54 -0
- package/dist/sdk/governance/assurance-presets.js +136 -0
- package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
- package/dist/sdk/governance/assurance-runtime.js +118 -14
- package/dist/sdk/governance/assurance.d.ts +51 -6
- package/dist/sdk/governance/assurance.js +321 -67
- package/dist/sdk/governance/gc.js +5 -11
- package/dist/sdk/governance/health.d.ts +3 -1
- package/dist/sdk/governance/health.js +24 -7
- package/dist/sdk/governance/validate-item-reader.js +3 -3
- package/dist/sdk/governance/validate.d.ts +2 -0
- package/dist/sdk/governance/validate.js +15 -5
- package/dist/sdk/graph/durable-cache.d.ts +1 -1
- package/dist/sdk/graph/durable-cache.js +156 -29
- package/dist/sdk/graph/governance-contracts.d.ts +12 -0
- package/dist/sdk/graph/governance-contracts.js +27 -0
- package/dist/sdk/graph/governance.d.ts +44 -2
- package/dist/sdk/graph/governance.js +156 -12
- package/dist/sdk/guide.js +4 -4
- package/dist/sdk/index.d.ts +3 -2
- package/dist/sdk/index.js +5 -4
- package/dist/sdk/lifecycle/claim.js +10 -3
- package/dist/sdk/linked-artifacts.d.ts +2 -0
- package/dist/sdk/linked-artifacts.js +29 -4
- package/dist/sdk/merge/driver.d.ts +2 -2
- package/dist/sdk/merge/driver.js +3 -3
- package/dist/sdk/merge/install.js +5 -4
- package/dist/sdk/merge/receipts.d.ts +6 -4
- package/dist/sdk/merge/receipts.js +7 -5
- package/dist/sdk/merge/three-way.d.ts +2 -2
- package/dist/sdk/merge/three-way.js +3 -3
- package/dist/sdk/output-projection.d.ts +9 -1
- package/dist/sdk/output-projection.js +45 -9
- package/dist/sdk/query/activity.d.ts +49 -2
- package/dist/sdk/query/activity.js +185 -38
- package/dist/sdk/query/get.js +19 -2
- package/dist/sdk/read-output-contracts.d.ts +5 -1
- package/dist/sdk/read-output-contracts.js +17 -2
- package/dist/sdk/read-output-session.d.ts +2 -0
- package/dist/sdk/read-output-session.js +12 -5
- package/dist/sdk/relationship-history.js +5 -5
- package/dist/sdk/runtime-primitives.d.ts +3 -3
- package/dist/sdk/runtime-primitives.js +5 -5
- package/dist/sdk/runtime-stats-options.js +3 -2
- package/dist/sdk/runtime.js +5 -9
- package/dist/sdk/schema-migration.js +4 -4
- package/dist/sdk/stats.d.ts +36 -3
- package/dist/sdk/stats.js +55 -15
- package/dist/sdk/test/execution.d.ts +4 -0
- package/dist/sdk/test/execution.js +88 -23
- package/dist/sdk/workspace-memory.js +4 -4
- package/dist/sdk/workspace-snapshot.js +8 -14
- package/dist/sdk/workspace-transaction-gc.js +4 -9
- package/dist/sdk/workspace-transaction.js +4 -4
- package/dist/sdk/workspace.js +4 -3
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -2
- package/docs/ASSURANCE.md +170 -14
- package/docs/COMMANDS.md +29 -8
- package/docs/CONFIGURATION.md +9 -0
- package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
- package/docs/EXTENSIONS.md +11 -12
- package/docs/MERGE_SAFETY.md +3 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
- package/docs/README.md +2 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
- package/docs/RELATIONSHIP_GRAPH.md +15 -0
- package/docs/SDK.md +17 -3
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
- package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
- package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
- package/docs/TESTING.md +24 -15
- package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
- package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
- package/marketplace.json +2 -2
- package/package.json +6 -6
- 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 +384 -83
- package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
- package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
- package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
- package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
- package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
- package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
- package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
|
@@ -5,26 +5,101 @@
|
|
|
5
5
|
* and verdict semantics in the host-neutral assurance module.
|
|
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]="7c99dfd8-2fa4-56c4-8191-229701eab251")}catch(e){}}();
|
|
9
9
|
import { execFile } from "node:child_process";
|
|
10
10
|
import { promisify } from "node:util";
|
|
11
11
|
import { runGraph } from "../graph/run.js";
|
|
12
12
|
import { runHealth } from "./health.js";
|
|
13
13
|
import { runValidate } from "./validate.js";
|
|
14
|
-
import {
|
|
14
|
+
import { getActiveExtensionRegistrations, resolvePortableWorkspaceContext, } from "../../core/extensions/index.js";
|
|
15
|
+
import { resolveRegisteredAssuranceMeasurementProvider } from "../../core/extensions/runtime-registrations.js";
|
|
16
|
+
import { stableStringify } from "../../core/shared/serialization.js";
|
|
17
|
+
import { getHistoryPath, listAllItemMetadata, readHistoryEntries, readSettings, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, } from "../runtime-primitives.js";
|
|
15
18
|
const execFileAsync = promisify(execFile);
|
|
16
19
|
const HISTORY_READ_CONCURRENCY = 16;
|
|
20
|
+
const DEFAULT_PROVIDER_TIMEOUT_MS = 30_000;
|
|
21
|
+
function assertProviderResult(provider, key, result) {
|
|
22
|
+
const keyDefinition = provider.keys[key];
|
|
23
|
+
const valueMatches = keyDefinition.value_type === "number"
|
|
24
|
+
? typeof result.value === "number" && Number.isFinite(result.value)
|
|
25
|
+
: Array.isArray(result.value) &&
|
|
26
|
+
result.value.every((entry) => typeof entry === "string");
|
|
27
|
+
if (!valueMatches) {
|
|
28
|
+
throw new TypeError(`assurance provider ${provider.id} key ${key} returned the wrong value type`);
|
|
29
|
+
}
|
|
30
|
+
if (!Number.isInteger(result.population_size) ||
|
|
31
|
+
result.population_size < 0 ||
|
|
32
|
+
!Number.isFinite(result.cost) ||
|
|
33
|
+
result.cost < 0) {
|
|
34
|
+
throw new TypeError(`assurance provider ${provider.id} returned an invalid population or cost`);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function validateProviderParameters(provider, source) {
|
|
39
|
+
const keyDefinition = provider.keys[source.key];
|
|
40
|
+
if (!keyDefinition) {
|
|
41
|
+
throw new TypeError(`assurance provider ${provider.id} does not declare key ${source.key}`);
|
|
42
|
+
}
|
|
43
|
+
const parameters = source.parameters ?? {};
|
|
44
|
+
const schema = keyDefinition.parameters ?? {};
|
|
45
|
+
for (const required of Object.entries(schema)
|
|
46
|
+
.filter(([, definition]) => definition.required === true)
|
|
47
|
+
.map(([name]) => name)) {
|
|
48
|
+
if (!Object.hasOwn(parameters, required)) {
|
|
49
|
+
throw new TypeError(`assurance provider ${provider.id} key ${source.key} requires parameter ${required}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const [name, value] of Object.entries(parameters)) {
|
|
53
|
+
const definition = schema[name];
|
|
54
|
+
if (!definition) {
|
|
55
|
+
throw new TypeError(`assurance provider ${provider.id} key ${source.key} does not declare parameter ${name}`);
|
|
56
|
+
}
|
|
57
|
+
if (value === null || typeof value !== definition.type) {
|
|
58
|
+
throw new TypeError(`assurance provider ${provider.id} parameter ${name} must be ${definition.type}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { ...parameters };
|
|
62
|
+
}
|
|
63
|
+
async function runRegisteredProvider(provider, source, pmRoot, trigger) {
|
|
64
|
+
const parameters = validateProviderParameters(provider, source);
|
|
65
|
+
const providerPromise = Promise.resolve().then(() => provider.resolve({
|
|
66
|
+
provider: provider.id,
|
|
67
|
+
key: source.key,
|
|
68
|
+
parameters,
|
|
69
|
+
trigger,
|
|
70
|
+
pm_root: pmRoot,
|
|
71
|
+
...resolvePortableWorkspaceContext(pmRoot),
|
|
72
|
+
}));
|
|
73
|
+
providerPromise.catch(() => { });
|
|
74
|
+
let timeoutHandle;
|
|
75
|
+
try {
|
|
76
|
+
const result = await Promise.race([
|
|
77
|
+
providerPromise,
|
|
78
|
+
new Promise((_, reject) => {
|
|
79
|
+
timeoutHandle = setTimeout(() => reject(new TypeError(`assurance provider ${provider.id} timed out`)), provider.timeout_ms ?? DEFAULT_PROVIDER_TIMEOUT_MS);
|
|
80
|
+
timeoutHandle.unref?.();
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
return assertProviderResult(provider, source.key, result);
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
clearTimeout(timeoutHandle);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
17
89
|
function valueAtPath(input, field) {
|
|
18
90
|
let current = input;
|
|
19
91
|
for (const segment of field.split(".")) {
|
|
20
|
-
if (typeof current !== "object" ||
|
|
92
|
+
if (typeof current !== "object" ||
|
|
93
|
+
current === null ||
|
|
94
|
+
Array.isArray(current)) {
|
|
21
95
|
throw new TypeError(`assurance field ${field} is not present`);
|
|
22
96
|
}
|
|
23
97
|
current = current[segment];
|
|
24
98
|
}
|
|
25
99
|
if (typeof current === "number" && Number.isFinite(current))
|
|
26
100
|
return current;
|
|
27
|
-
if (Array.isArray(current) &&
|
|
101
|
+
if (Array.isArray(current) &&
|
|
102
|
+
current.every((entry) => typeof entry === "string")) {
|
|
28
103
|
return current;
|
|
29
104
|
}
|
|
30
105
|
throw new TypeError(`assurance field ${field} must resolve to a finite number or string array`);
|
|
@@ -33,8 +108,8 @@ function checkValue(result, checkName, field) {
|
|
|
33
108
|
const check = result.checks.find((entry) => entry.name === checkName);
|
|
34
109
|
if (!check)
|
|
35
110
|
throw new TypeError(`assurance check ${checkName} is not present`);
|
|
36
|
-
const value = field === "status"
|
|
37
|
-
? check.
|
|
111
|
+
const value = field === "status" || field === "ok"
|
|
112
|
+
? check.ok
|
|
38
113
|
? 0
|
|
39
114
|
: 1
|
|
40
115
|
: valueAtPath(check.details, field);
|
|
@@ -85,7 +160,7 @@ export async function createAssuranceWorkspaceContext(pmRoot, options = {}) {
|
|
|
85
160
|
const settings = await readSettings(pmRoot);
|
|
86
161
|
const typeRegistry = resolveItemTypeRegistry(settings);
|
|
87
162
|
const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
|
|
88
|
-
const metadata = await
|
|
163
|
+
const metadata = await listAllItemMetadata(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);
|
|
89
164
|
const items = metadata.map((item) => ({
|
|
90
165
|
...item,
|
|
91
166
|
id: item.id,
|
|
@@ -93,6 +168,17 @@ export async function createAssuranceWorkspaceContext(pmRoot, options = {}) {
|
|
|
93
168
|
type: item.type,
|
|
94
169
|
}));
|
|
95
170
|
const global = { path: pmRoot };
|
|
171
|
+
const activeRegistrations = getActiveExtensionRegistrations();
|
|
172
|
+
const registeredProviderCapabilities = Object.fromEntries((activeRegistrations?.assurance_providers ?? []).map((registration) => [
|
|
173
|
+
registration.definition.id,
|
|
174
|
+
{
|
|
175
|
+
cost_class: registration.runtime_definition.cost_class,
|
|
176
|
+
network: registration.runtime_definition.network,
|
|
177
|
+
},
|
|
178
|
+
]));
|
|
179
|
+
const graphRuns = new Map();
|
|
180
|
+
let validateRun;
|
|
181
|
+
let healthRun;
|
|
96
182
|
return {
|
|
97
183
|
tree_id: options.resolve_tree === false
|
|
98
184
|
? (options.tree_id ?? "working-copy")
|
|
@@ -102,9 +188,22 @@ export async function createAssuranceWorkspaceContext(pmRoot, options = {}) {
|
|
|
102
188
|
? []
|
|
103
189
|
: await readWorkspaceHistory(pmRoot, items),
|
|
104
190
|
terminal_statuses: [...statusRegistry.terminal_statuses],
|
|
191
|
+
provider_capabilities: {
|
|
192
|
+
...registeredProviderCapabilities,
|
|
193
|
+
...options.provider_capabilities,
|
|
194
|
+
},
|
|
105
195
|
external: async (source) => {
|
|
106
196
|
if (source.kind === "graph") {
|
|
107
|
-
const
|
|
197
|
+
const key = stableStringify({
|
|
198
|
+
operation: source.operation,
|
|
199
|
+
parameters: source.parameters ?? {},
|
|
200
|
+
});
|
|
201
|
+
let pending = graphRuns.get(key);
|
|
202
|
+
if (pending === undefined) {
|
|
203
|
+
pending = runGraph(source.operation, undefined, undefined, { ...source.parameters, full: true }, global);
|
|
204
|
+
graphRuns.set(key, pending);
|
|
205
|
+
}
|
|
206
|
+
const result = await pending;
|
|
108
207
|
return {
|
|
109
208
|
value: valueAtPath(result, source.field),
|
|
110
209
|
population_size: items.length,
|
|
@@ -112,20 +211,25 @@ export async function createAssuranceWorkspaceContext(pmRoot, options = {}) {
|
|
|
112
211
|
};
|
|
113
212
|
}
|
|
114
213
|
if (source.kind === "validate") {
|
|
115
|
-
|
|
214
|
+
validateRun ??= runValidate({ counts: true }, global);
|
|
215
|
+
const result = await validateRun;
|
|
116
216
|
return checkValue(result, source.check, source.field);
|
|
117
217
|
}
|
|
118
218
|
if (source.kind === "health") {
|
|
119
|
-
|
|
219
|
+
healthRun ??= runHealth(global, { checkOnly: true, full: true });
|
|
220
|
+
const result = await healthRun;
|
|
120
221
|
return checkValue(result, source.check, source.field);
|
|
121
222
|
}
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
223
|
+
const hostProvider = options.providers?.[source.provider];
|
|
224
|
+
if (hostProvider)
|
|
225
|
+
return hostProvider(source);
|
|
226
|
+
const registeredProvider = resolveRegisteredAssuranceMeasurementProvider(activeRegistrations, source.provider);
|
|
227
|
+
if (!registeredProvider) {
|
|
124
228
|
throw new TypeError(`assurance provider ${source.provider} is not registered`);
|
|
125
229
|
}
|
|
126
|
-
return
|
|
230
|
+
return runRegisteredProvider(registeredProvider.runtime_definition, source, pmRoot, options.trigger ?? "sdk");
|
|
127
231
|
},
|
|
128
232
|
};
|
|
129
233
|
}
|
|
130
234
|
//# sourceMappingURL=assurance-runtime.js.map
|
|
131
|
-
//# debugId=
|
|
235
|
+
//# debugId=7c99dfd8-2fa4-56c4-8191-229701eab251
|
|
@@ -6,6 +6,8 @@ export declare const ASSURANCE_GATE_TRIGGERS: readonly ["pre-commit", "pre-push"
|
|
|
6
6
|
export type AssuranceGateTrigger = (typeof ASSURANCE_GATE_TRIGGERS)[number];
|
|
7
7
|
/** Assertion enforcement strength. */
|
|
8
8
|
export type AssuranceEnforcement = "block" | "warn" | "observe";
|
|
9
|
+
/** Provider execution classes ordered from cheapest to most expensive. */
|
|
10
|
+
export type AssuranceProviderCostClass = "low" | "medium" | "high";
|
|
9
11
|
/** Assertion lifetime after its owning work item becomes terminal. */
|
|
10
12
|
export type AssuranceLifetime = "hold" | "retire";
|
|
11
13
|
/** Numeric or labelled-set value produced by a measurement. */
|
|
@@ -32,11 +34,11 @@ export interface AssuranceItemRecord {
|
|
|
32
34
|
/** Typed relationships. */
|
|
33
35
|
dependencies?: AssuranceDependencyRecord[];
|
|
34
36
|
/** Linked files. */
|
|
35
|
-
files?:
|
|
37
|
+
files?: object[];
|
|
36
38
|
/** Linked tests. */
|
|
37
|
-
tests?:
|
|
39
|
+
tests?: object[];
|
|
38
40
|
/** Linked docs. */
|
|
39
|
-
docs?:
|
|
41
|
+
docs?: object[];
|
|
40
42
|
/** Extension-owned metadata remains filterable. */
|
|
41
43
|
[key: string]: unknown;
|
|
42
44
|
}
|
|
@@ -67,6 +69,8 @@ export interface AssuranceItemsSource {
|
|
|
67
69
|
field?: string;
|
|
68
70
|
/** Required exact value for field. */
|
|
69
71
|
equals?: string | number | boolean | null;
|
|
72
|
+
/** Presence predicate for the selected field. */
|
|
73
|
+
state?: "present" | "missing";
|
|
70
74
|
}
|
|
71
75
|
/** Typed relationship-count source. */
|
|
72
76
|
export interface AssuranceDependencyKindSource {
|
|
@@ -244,6 +248,18 @@ export interface AssuranceGateDefinition {
|
|
|
244
248
|
triggers: AssuranceGateTrigger[];
|
|
245
249
|
/** Optional description. */
|
|
246
250
|
description?: string;
|
|
251
|
+
/** Explicit provider allow-list and trigger-specific execution policy. */
|
|
252
|
+
provider_policy?: {
|
|
253
|
+
/** Provider ids this gate may invoke. An empty set refuses every provider. */
|
|
254
|
+
allowed_providers: string[];
|
|
255
|
+
/** Trigger rules; an omitted rule refuses provider execution for that trigger. */
|
|
256
|
+
triggers: Partial<Record<AssuranceGateTrigger, {
|
|
257
|
+
/** Highest provider cost class allowed at this trigger. */
|
|
258
|
+
max_cost_class: AssuranceProviderCostClass;
|
|
259
|
+
/** Whether network-declaring providers may run. */
|
|
260
|
+
allow_network: boolean;
|
|
261
|
+
}>>;
|
|
262
|
+
};
|
|
247
263
|
}
|
|
248
264
|
/** Complete persisted assurance registry. */
|
|
249
265
|
export interface AssuranceDocument {
|
|
@@ -256,6 +272,24 @@ export interface AssuranceDocument {
|
|
|
256
272
|
/** Gate declarations. */
|
|
257
273
|
gates: AssuranceGateDefinition[];
|
|
258
274
|
}
|
|
275
|
+
/** Atomic set of ordinary declarations used by presets and accepted proposals. */
|
|
276
|
+
export interface AssuranceDeclarationBundle {
|
|
277
|
+
/** Measurement declarations to create without overwriting divergent ids. */
|
|
278
|
+
measurements: AssuranceMeasurementDefinition[];
|
|
279
|
+
/** Assertion declarations to create without overwriting divergent ids. */
|
|
280
|
+
assertions: AssuranceAssertionDefinition[];
|
|
281
|
+
/** Gate declarations to create without overwriting divergent ids. */
|
|
282
|
+
gates: AssuranceGateDefinition[];
|
|
283
|
+
}
|
|
284
|
+
/** Audited receipt for one atomic assurance bundle application. */
|
|
285
|
+
export interface AssuranceBundleMutationReceipt {
|
|
286
|
+
/** Whether persistence changed. */
|
|
287
|
+
changed: boolean;
|
|
288
|
+
/** Stable ids created by the bundle. */
|
|
289
|
+
created_ids: string[];
|
|
290
|
+
/** Stable ids already present with byte-equivalent declarations. */
|
|
291
|
+
unchanged_ids: string[];
|
|
292
|
+
}
|
|
259
293
|
/** Host adapter result for graph, validate, health, or provider sources. */
|
|
260
294
|
export interface AssuranceExternalMeasurementResult {
|
|
261
295
|
/** Observed value. */
|
|
@@ -277,6 +311,11 @@ export interface AssuranceEvaluationContext {
|
|
|
277
311
|
history: AssuranceHistoryRecord[];
|
|
278
312
|
/** Status ids that make an assertion owner terminal. */
|
|
279
313
|
terminal_statuses?: string[];
|
|
314
|
+
/** Host-declared capabilities for provider-policy enforcement. */
|
|
315
|
+
provider_capabilities?: Readonly<Record<string, {
|
|
316
|
+
cost_class: AssuranceProviderCostClass;
|
|
317
|
+
network: boolean;
|
|
318
|
+
}>>;
|
|
280
319
|
/** External source adapter. Implementations must enforce an appropriate timeout. */
|
|
281
320
|
external: (source: AssuranceGraphSource | AssuranceValidateSource | AssuranceHealthSource | AssuranceProviderSource) => Promise<AssuranceExternalMeasurementResult>;
|
|
282
321
|
}
|
|
@@ -297,6 +336,8 @@ export interface AssuranceMeasurementCost {
|
|
|
297
336
|
export interface AssuranceMeasurementResult {
|
|
298
337
|
/** Measurement id. */
|
|
299
338
|
id: string;
|
|
339
|
+
/** Stable fingerprint of the exact declaration that produced this result. */
|
|
340
|
+
definition_fingerprint: string;
|
|
300
341
|
/** Observed value. */
|
|
301
342
|
value: AssuranceValue;
|
|
302
343
|
/** Population denominator. */
|
|
@@ -319,6 +360,8 @@ export interface AssuranceAssertionVerdict {
|
|
|
319
360
|
assertion_id: string;
|
|
320
361
|
/** Stable observation key used to obtain the evaluated value. */
|
|
321
362
|
measurement_id: string;
|
|
363
|
+
/** Stable fingerprint of the measurement declaration used for this verdict. */
|
|
364
|
+
measurement_definition_fingerprint: string;
|
|
322
365
|
/** Explicit scope. */
|
|
323
366
|
scope: AssuranceScope;
|
|
324
367
|
/** Population denominator. */
|
|
@@ -401,12 +444,12 @@ export declare function createEmptyAssuranceDocument(): AssuranceDocument;
|
|
|
401
444
|
export declare function evaluateMeasurement(definition: AssuranceMeasurementDefinition, context: AssuranceEvaluationContext, definitions?: AssuranceMeasurementDefinition[]): Promise<AssuranceMeasurementResult>;
|
|
402
445
|
/** Evaluate one assertion against a precomputed measurement receipt. */
|
|
403
446
|
export declare function evaluateAssuranceAssertion(definition: AssuranceAssertionDefinition, measurement: AssuranceMeasurementResult, options?: {
|
|
404
|
-
owner_terminal?: boolean;
|
|
447
|
+
/** Whether the owning item is terminal. */ owner_terminal?: boolean;
|
|
405
448
|
}): AssuranceAssertionVerdict;
|
|
406
449
|
/** Evaluate a named gate into one presentation-independent verdict document. */
|
|
407
450
|
export declare function evaluateAssuranceGate(gateId: string, document: AssuranceDocument, context: AssuranceEvaluationContext, options: {
|
|
408
|
-
|
|
409
|
-
dry_run?: boolean;
|
|
451
|
+
/** Trigger being evaluated. */ trigger: AssuranceGateTrigger;
|
|
452
|
+
/** Skip persistence in the caller. */ dry_run?: boolean;
|
|
410
453
|
}): Promise<AssuranceGateVerdict>;
|
|
411
454
|
/** Read all declarations of one kind with a stable row selector receipt. */
|
|
412
455
|
export declare function listAssuranceDeclarations(pmRoot: string, kind: AssuranceDeclarationKind): Promise<{
|
|
@@ -421,6 +464,8 @@ export declare function listAssuranceDeclarations(pmRoot: string, kind: Assuranc
|
|
|
421
464
|
export declare function getAssuranceDeclaration(pmRoot: string, kind: AssuranceDeclarationKind, id: string): Promise<AssuranceDeclaration>;
|
|
422
465
|
/** Create or update one declaration through audited singleton persistence. */
|
|
423
466
|
export declare function putAssuranceDeclaration(pmRoot: string, kind: AssuranceDeclarationKind, definition: AssuranceDeclaration, options?: AssuranceMutationOptions): Promise<AssuranceMutationReceipt>;
|
|
467
|
+
/** Apply a declaration bundle atomically, idempotently, and without replacing divergent ids. */
|
|
468
|
+
export declare function putAssuranceDeclarationBundle(pmRoot: string, bundle: AssuranceDeclarationBundle, options?: AssuranceMutationOptions): Promise<AssuranceBundleMutationReceipt>;
|
|
424
469
|
/** Remove an unreferenced declaration through audited singleton persistence. */
|
|
425
470
|
export declare function removeAssuranceDeclaration(pmRoot: string, kind: AssuranceDeclarationKind, id: string, options?: AssuranceMutationOptions): Promise<AssuranceMutationReceipt>;
|
|
426
471
|
/** Append one immutable gate verdict without changing registry state. */
|