@skill-harness/adapters 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/index.d.ts +0 -28
  2. package/dist/index.js +0 -28
  3. package/dist/pi.js +21 -133
  4. package/package.json +2 -3
  5. package/dist/archive-access.d.ts +0 -58
  6. package/dist/archive-access.js +0 -61
  7. package/dist/archive-checkpoint.d.ts +0 -47
  8. package/dist/archive-checkpoint.js +0 -116
  9. package/dist/archive-facts.d.ts +0 -19
  10. package/dist/archive-facts.js +0 -20
  11. package/dist/archive-observer.d.ts +0 -21
  12. package/dist/archive-observer.js +0 -79
  13. package/dist/archive-policy.d.ts +0 -107
  14. package/dist/archive-policy.js +0 -135
  15. package/dist/archive-read-capability.d.ts +0 -49
  16. package/dist/archive-read-capability.js +0 -45
  17. package/dist/archive-retention-policy.d.ts +0 -52
  18. package/dist/archive-retention-policy.js +0 -49
  19. package/dist/archived-work.d.ts +0 -45
  20. package/dist/archived-work.js +0 -78
  21. package/dist/blind-intervention.d.ts +0 -35
  22. package/dist/blind-intervention.js +0 -218
  23. package/dist/codex-diagnostic-model.d.ts +0 -14
  24. package/dist/codex-diagnostic-model.js +0 -39
  25. package/dist/codex-host-observer.d.ts +0 -111
  26. package/dist/codex-host-observer.js +0 -309
  27. package/dist/codex-https.d.ts +0 -7
  28. package/dist/codex-https.js +0 -221
  29. package/dist/codex-model-profile.d.ts +0 -38
  30. package/dist/codex-model-profile.js +0 -54
  31. package/dist/codex-producer-ipc.d.ts +0 -55
  32. package/dist/codex-producer-ipc.js +0 -67
  33. package/dist/codex-sdk-transport.d.ts +0 -50
  34. package/dist/codex-sdk-transport.js +0 -294
  35. package/dist/codex-subscription.d.ts +0 -114
  36. package/dist/codex-subscription.js +0 -268
  37. package/dist/evidence-archive.d.ts +0 -65
  38. package/dist/evidence-archive.js +0 -225
  39. package/dist/execution-projection-schema.d.ts +0 -10
  40. package/dist/execution-projection-schema.js +0 -30
  41. package/dist/execution-retention-archive.d.ts +0 -69
  42. package/dist/execution-retention-archive.js +0 -154
  43. package/dist/generated/retention-v2-contract.d.ts +0 -72
  44. package/dist/generated/retention-v2-contract.js +0 -105
  45. package/dist/generated/retention-v2-json.d.ts +0 -24
  46. package/dist/generated/retention-v2-json.js +0 -268
  47. package/dist/generated/retention-v2-native-json.d.ts +0 -2
  48. package/dist/generated/retention-v2-native-json.js +0 -33
  49. package/dist/generated/retention-v2-native.d.ts +0 -58
  50. package/dist/generated/retention-v2-native.js +0 -155
  51. package/dist/generated/retention-v2-pin.d.ts +0 -2
  52. package/dist/generated/retention-v2-pin.js +0 -4
  53. package/dist/generated/retention-v2-types.d.ts +0 -49
  54. package/dist/generated/retention-v2-types.js +0 -2
  55. package/dist/generated/retention-v2-work-types.d.ts +0 -260
  56. package/dist/generated/retention-v2-work-types.js +0 -13
  57. package/dist/generated/work-v4/execution-id.d.ts +0 -5
  58. package/dist/generated/work-v4/execution-id.js +0 -14
  59. package/dist/generated/work-v4/json.d.ts +0 -24
  60. package/dist/generated/work-v4/json.js +0 -268
  61. package/dist/generated/work-v4/occurrences.d.ts +0 -226
  62. package/dist/generated/work-v4/occurrences.js +0 -116
  63. package/dist/generated/work-v4/pin.d.ts +0 -1
  64. package/dist/generated/work-v4/pin.js +0 -3
  65. package/dist/generated/work-v4/projection.d.ts +0 -294
  66. package/dist/generated/work-v4/projection.js +0 -238
  67. package/dist/generated/work-v4/reader.d.ts +0 -24
  68. package/dist/generated/work-v4/reader.js +0 -109
  69. package/dist/generated/work-v4/snapshot.d.ts +0 -28
  70. package/dist/generated/work-v4/snapshot.js +0 -268
  71. package/dist/generated/work-v4/types.d.ts +0 -260
  72. package/dist/generated/work-v4/types.js +0 -13
  73. package/dist/generated/work-v4/validation.d.ts +0 -13
  74. package/dist/generated/work-v4/validation.js +0 -227
  75. package/dist/installed-review-session.d.ts +0 -28
  76. package/dist/installed-review-session.js +0 -166
  77. package/dist/intervention-run.d.ts +0 -403
  78. package/dist/intervention-run.js +0 -169
  79. package/dist/learning-case.d.ts +0 -12
  80. package/dist/learning-case.js +0 -15
  81. package/dist/learning-journal.d.ts +0 -18
  82. package/dist/learning-journal.js +0 -256
  83. package/dist/learning-lifecycle.d.ts +0 -28
  84. package/dist/learning-lifecycle.js +0 -66
  85. package/dist/learning-trust-setup.d.ts +0 -64
  86. package/dist/learning-trust-setup.js +0 -55
  87. package/dist/learning-workspace.d.ts +0 -930
  88. package/dist/learning-workspace.js +0 -663
  89. package/dist/principal-payload-port.d.ts +0 -25
  90. package/dist/principal-payload-port.js +0 -40
  91. package/dist/producer-product.d.ts +0 -70
  92. package/dist/producer-product.js +0 -186
  93. package/dist/producer-review.d.ts +0 -53
  94. package/dist/producer-review.js +0 -207
  95. package/dist/prompt-capture-extension.d.ts +0 -10
  96. package/dist/prompt-capture-extension.js +0 -26
  97. package/dist/prompt-provenance.d.ts +0 -22
  98. package/dist/prompt-provenance.js +0 -146
  99. package/dist/reviewed-archive-export.d.ts +0 -42
  100. package/dist/reviewed-archive-export.js +0 -78
  101. package/dist/trust-lifecycle.d.ts +0 -152
  102. package/dist/trust-lifecycle.js +0 -209
  103. package/dist/weekly-investigation.d.ts +0 -237
  104. package/dist/weekly-investigation.js +0 -330
  105. package/dist/work-candidates.d.ts +0 -29
  106. package/dist/work-candidates.js +0 -78
  107. package/dist/work-case-archive.d.ts +0 -25
  108. package/dist/work-case-archive.js +0 -63
  109. package/dist/work-case-review.d.ts +0 -45
  110. package/dist/work-case-review.js +0 -220
  111. package/dist/work-signal-cases.d.ts +0 -15
  112. package/dist/work-signal-cases.js +0 -54
  113. package/dist/work-signal-observation.d.ts +0 -23
  114. package/dist/work-signal-observation.js +0 -89
@@ -1,21 +0,0 @@
1
- import { ingestPolicySource } from "./archive-policy.js";
2
- export interface ArchiveObserverOptions {
3
- policyPath: string;
4
- sourceId: string;
5
- intervalMs: number;
6
- maxPolls: number;
7
- previousCheckpointId?: string;
8
- signal?: AbortSignal;
9
- /** Optional synchronous metadata consumer, never a worker hook. Its failure does not stop capture. */
10
- onObservation?: (value: ReturnType<typeof ingestPolicySource>) => void;
11
- }
12
- /** Bounded external file observation. No worker process, socket, session API, prompt or control channel is used. */
13
- export declare function observeArchiveSource(options: ArchiveObserverOptions): Promise<{
14
- observerId: `${string}-${string}-${string}-${string}-${string}`;
15
- polls: number;
16
- lastCheckpointId: string | null;
17
- receiptId: string;
18
- stopped: "aborted" | "poll-limit" | "policy-change";
19
- gaps: string[];
20
- workerInteractions: 0;
21
- }>;
@@ -1,79 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { archivePolicyBinding, ingestPolicySource } from "./archive-policy.js";
3
- import { retainArchiveSource } from "./evidence-archive.js";
4
- function cadence(ms, signal) {
5
- return new Promise(resolve => {
6
- if (signal?.aborted) {
7
- resolve();
8
- return;
9
- }
10
- const finish = () => { clearTimeout(timer); signal?.removeEventListener("abort", finish); resolve(); };
11
- const timer = setTimeout(finish, ms);
12
- signal?.addEventListener("abort", finish, { once: true });
13
- });
14
- }
15
- /** Bounded external file observation. No worker process, socket, session API, prompt or control channel is used. */
16
- export async function observeArchiveSource(options) {
17
- if (!Number.isSafeInteger(options.intervalMs) || options.intervalMs < 1 || options.intervalMs > 60000
18
- || !Number.isSafeInteger(options.maxPolls) || options.maxPolls < 1 || options.maxPolls > 128)
19
- throw new Error("bounded observer interval/poll count required");
20
- const binding = archivePolicyBinding(options.policyPath, options.sourceId), observerId = randomUUID(), startedAt = new Date().toISOString();
21
- let lastCheckpointId = options.previousCheckpointId ?? null, polls = 0, receiptId = "", consumer = options.onObservation;
22
- let stopped = "poll-limit", terminal = false;
23
- const gaps = new Set();
24
- const records = [];
25
- const persist = () => retainArchiveSource(binding.archiveRoot, {
26
- sourceId: `observer-${observerId}`, parser: { id: "archive-observer", version: "1" }, retention: "exact",
27
- bytes: Buffer.from(JSON.stringify({ version: "archive-observer-v1", observerId, policySha256: binding.policySha256, sourceId: binding.sourceId,
28
- startedAt, polls, lastCheckpointId, state: terminal ? "terminal" : "running", stopped: terminal ? stopped : null, gaps: [...gaps].sort(), records, workerInteractions: 0, continuity: "bounded-observations-not-complete-live-coverage" })),
29
- }).manifestId;
30
- for (let i = 0; i < options.maxPolls; i++) {
31
- if (options.signal?.aborted) {
32
- stopped = "aborted";
33
- break;
34
- }
35
- try {
36
- if (archivePolicyBinding(options.policyPath, options.sourceId).policySha256 !== binding.policySha256)
37
- throw new Error("changed");
38
- }
39
- catch {
40
- gaps.add("policy-changed-or-unavailable");
41
- stopped = "policy-change";
42
- break;
43
- }
44
- polls++;
45
- try {
46
- const observation = ingestPolicySource(options.policyPath, options.sourceId, lastCheckpointId ?? undefined, binding.policySha256);
47
- lastCheckpointId = observation.checkpointId;
48
- records.push({ poll: polls, at: new Date().toISOString(), checkpointId: lastCheckpointId, state: "captured" });
49
- if (consumer) {
50
- try {
51
- const returned = consumer(observation);
52
- if (returned && typeof returned.then === "function") {
53
- gaps.add("async-consumer-outcome-unobserved");
54
- consumer = undefined;
55
- // The unsupported asynchronous outcome is already an explicit durable gap; never await it on capture.
56
- void Promise.resolve(returned).catch(() => undefined);
57
- }
58
- }
59
- catch {
60
- gaps.add("observation-consumer-failed");
61
- consumer = undefined;
62
- }
63
- }
64
- }
65
- catch {
66
- gaps.add("source-observation-failed");
67
- records.push({ poll: polls, at: new Date().toISOString(), checkpointId: lastCheckpointId, state: "gap" });
68
- }
69
- receiptId = persist();
70
- if (i + 1 < options.maxPolls)
71
- await cadence(options.intervalMs, options.signal);
72
- }
73
- if (options.signal?.aborted)
74
- stopped = "aborted";
75
- terminal = true;
76
- receiptId = persist();
77
- return { observerId, polls, lastCheckpointId, receiptId, stopped, gaps: [...gaps].sort(), workerInteractions: 0 };
78
- }
79
- //# sourceMappingURL=archive-observer.js.map
@@ -1,107 +0,0 @@
1
- import { type ArchiveRetention } from "./evidence-archive.js";
2
- export interface PolicySource {
3
- id: string;
4
- path: string;
5
- parser: {
6
- id: string;
7
- version: string;
8
- };
9
- contentPolicy?: "manifest-only" | "referenced-blobs";
10
- }
11
- export interface ArchiveIngestionPolicy {
12
- version: "archive-policy-v1" | "archive-policy-v2";
13
- id: string;
14
- revision: string;
15
- sourceRoot: string;
16
- archiveRoot: string;
17
- maxBytes: number;
18
- retention: ArchiveRetention;
19
- expiresAt: string;
20
- sources: PolicySource[];
21
- }
22
- /** Host-only policy binding for bounded external observation; no source bytes are read. */
23
- export declare function archivePolicyBinding(policyPath: string, sourceId: string): Readonly<{
24
- policySha256: string;
25
- archiveRoot: string;
26
- sourceId: string;
27
- archiveSourceId: string;
28
- expiresAt: string;
29
- }>;
30
- /** Explicit operator-selected file policy. Not a credential, authorization attestation or hostile-agent sandbox. */
31
- export declare function ingestPolicySource(policyPath: string, sourceId: string, previousCheckpointId?: string, expectedPolicySha256?: string): {
32
- change: string;
33
- policyReceiptId: string;
34
- kind: "execution-retention-v2";
35
- checkpointId: string;
36
- policySha256: string;
37
- sourceId: string;
38
- archiveSourceId: string;
39
- sourceSha256: string;
40
- sourceStatus: "available";
41
- retention: "exact";
42
- syntax: "not-applicable";
43
- runtime: "running" | "terminal";
44
- content: Record<"session" | "stdout" | "stderr" | "paneSnapshot" | "checkReceipt" | "result", {
45
- status: "available" | "missing" | "mismatch";
46
- sha256: string | null;
47
- bytes: number | null;
48
- }>;
49
- activeBranch: null;
50
- coverage: "partial";
51
- issueCount: number;
52
- acceptance: "not-assessed";
53
- } | {
54
- sourceId: string;
55
- archiveSourceId: string;
56
- change: import("./archive-checkpoint.js").SnapshotChange | "repeat";
57
- policyReceiptId: string;
58
- checkpointId: string;
59
- policySha256: string;
60
- sourceSha256: string;
61
- sourceStatus: "available" | "missing" | "error";
62
- retention: ArchiveRetention;
63
- syntax: "error" | "complete" | "partial" | "unavailable";
64
- completeBytes: number;
65
- pendingBytes: number;
66
- invalidLines: number;
67
- issues: string[];
68
- activeBranch: null;
69
- acceptance: "not-assessed";
70
- };
71
- /** Metadata-only CLI/read-model output; no payload, local path or policy file is exported. */
72
- export declare function inspectPolicyCheckpoint(policyPath: string, sourceId: string, checkpointId: string): {
73
- kind: "execution-retention-v2";
74
- checkpointId: string;
75
- policySha256: string;
76
- sourceId: string;
77
- archiveSourceId: string;
78
- sourceSha256: string;
79
- sourceStatus: "available";
80
- retention: "exact";
81
- syntax: "not-applicable";
82
- runtime: "running" | "terminal";
83
- content: Record<"session" | "stdout" | "stderr" | "paneSnapshot" | "checkReceipt" | "result", {
84
- status: "available" | "missing" | "mismatch";
85
- sha256: string | null;
86
- bytes: number | null;
87
- }>;
88
- activeBranch: null;
89
- coverage: "partial";
90
- issueCount: number;
91
- acceptance: "not-assessed";
92
- } | {
93
- sourceId: string;
94
- archiveSourceId: string;
95
- checkpointId: string;
96
- policySha256: string;
97
- sourceSha256: string;
98
- sourceStatus: "available" | "missing" | "error";
99
- retention: ArchiveRetention;
100
- syntax: "error" | "complete" | "partial" | "unavailable";
101
- completeBytes: number;
102
- pendingBytes: number;
103
- invalidLines: number;
104
- issues: string[];
105
- activeBranch: null;
106
- acceptance: "not-assessed";
107
- };
@@ -1,135 +0,0 @@
1
- import { closeSync, constants, fstatSync, lstatSync, openSync, readSync } from "node:fs";
2
- import { createHash } from "node:crypto";
3
- import { dirname, isAbsolute, join, parse, resolve, sep } from "node:path";
4
- import { ingestArchiveSnapshot, readArchiveCheckpoint } from "./archive-checkpoint.js";
5
- import { retainArchiveSource } from "./evidence-archive.js";
6
- import { ingestNativePolicy, inspectNativePolicy } from "./archive-retention-policy.js";
7
- const ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
8
- const forbidden = new Set([".pi", ".env", "auth.json", "credentials", "credentials.json"]);
9
- function fail() { throw new Error("archive policy refused invalid, expired or inaccessible input"); }
10
- const keys = (v, names) => !!v && typeof v === "object" && !Array.isArray(v)
11
- && Object.keys(v).length === names.length && Object.keys(v).every(k => names.includes(k));
12
- const identifier = (v) => typeof v === "string" && ID.test(v);
13
- function regularBytes(path, limit) {
14
- if (!constants.O_NOFOLLOW || !constants.O_NONBLOCK)
15
- fail();
16
- const absolute = resolve(path);
17
- if (absolute.split(sep).some(part => forbidden.has(part)))
18
- fail();
19
- let current = parse(absolute).root;
20
- for (const part of dirname(absolute).slice(current.length).split(sep).filter(Boolean)) {
21
- current = join(current, part);
22
- const stat = lstatSync(current);
23
- if (!stat.isDirectory() || stat.isSymbolicLink())
24
- fail();
25
- }
26
- const fd = openSync(absolute, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
27
- try {
28
- const stat = fstatSync(fd);
29
- if (!stat.isFile() || stat.size > limit || (stat.mode & 0o077) !== 0 || (process.getuid && stat.uid !== process.getuid()))
30
- fail();
31
- const bytes = Buffer.alloc(limit + 1);
32
- let size = 0;
33
- while (size <= limit) {
34
- const n = readSync(fd, bytes, size, bytes.length - size, size);
35
- if (!n)
36
- break;
37
- size += n;
38
- }
39
- if (size > limit)
40
- fail();
41
- return bytes.subarray(0, size);
42
- }
43
- finally {
44
- closeSync(fd);
45
- }
46
- }
47
- function selectedPolicy(path, sourceId) {
48
- const bytes = regularBytes(path, 65536);
49
- const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
50
- const p = JSON.parse(text);
51
- // Canonical JSON excludes duplicate-key ambiguity. This is a selected operator configuration, not a signed approval.
52
- if (JSON.stringify(p) !== text || !keys(p, ["version", "id", "revision", "sourceRoot", "archiveRoot", "maxBytes", "retention", "expiresAt", "sources"])
53
- || !["archive-policy-v1", "archive-policy-v2"].includes(p.version) || !identifier(p.id) || !identifier(p.revision)
54
- || typeof p.sourceRoot !== "string" || !isAbsolute(p.sourceRoot) || typeof p.archiveRoot !== "string" || !isAbsolute(p.archiveRoot)
55
- || resolve(p.sourceRoot) === resolve(p.archiveRoot)
56
- || [p.sourceRoot, p.archiveRoot].some(root => root.split(/[\\/]/).some(part => forbidden.has(part)))
57
- || !Number.isSafeInteger(p.maxBytes) || p.maxBytes < 1 || p.maxBytes > 8 * 1024 * 1024
58
- || !["exact", "redacted", "reference-only"].includes(p.retention)
59
- || typeof p.expiresAt !== "string" || !Number.isFinite(Date.parse(p.expiresAt))
60
- || new Date(p.expiresAt).toISOString() !== p.expiresAt || Date.parse(p.expiresAt) <= Date.now()
61
- || !Array.isArray(p.sources) || p.sources.length < 1 || p.sources.length > 128)
62
- fail();
63
- const ids = new Set();
64
- for (const item of p.sources) {
65
- if (!keys(item, p.version === "archive-policy-v2" ? ["id", "path", "parser", "contentPolicy"] : ["id", "path", "parser"]) || !identifier(item.id) || ids.has(item.id)
66
- || typeof item.path !== "string" || !item.path || isAbsolute(item.path) || item.path.includes("\\")
67
- || item.path.split("/").some(part => !part || part === "." || part === ".." || forbidden.has(part))
68
- || !keys(item.parser, ["id", "version"]) || !identifier(item.parser.id) || !identifier(item.parser.version))
69
- fail();
70
- if (p.version === "archive-policy-v2" && !["manifest-only", "referenced-blobs"].includes(item.contentPolicy))
71
- fail();
72
- if (item.contentPolicy === "referenced-blobs" && (p.retention !== "exact" || item.parser.id !== "pi-daddy-execution-retention" || item.parser.version !== "2.0"))
73
- fail();
74
- ids.add(item.id);
75
- }
76
- const source = p.sources.find(s => s.id === sourceId);
77
- if (!source)
78
- fail();
79
- const root = lstatSync(p.sourceRoot);
80
- if (!root.isDirectory() || root.isSymbolicLink() || (root.mode & 0o077) !== 0 || (process.getuid && root.uid !== process.getuid()))
81
- fail();
82
- const archiveSourceId = `policy-source-${createHash("sha256").update(JSON.stringify([p.id, source.id, resolve(p.sourceRoot), source.path])).digest("hex")}`;
83
- return { policy: p, source, archiveSourceId, policySha256: createHash("sha256").update(bytes).digest("hex") };
84
- }
85
- function metadata(result, checkpointId, policySha256) {
86
- return { checkpointId, policySha256, sourceId: result.checkpoint.sourceId, sourceSha256: result.checkpoint.sourceSha256,
87
- sourceStatus: result.source.status, retention: result.checkpoint.retention, syntax: result.checkpoint.syntax,
88
- completeBytes: result.checkpoint.completeBytes, pendingBytes: result.checkpoint.pendingBytes,
89
- invalidLines: result.checkpoint.invalidLines, issues: result.checkpoint.issues,
90
- activeBranch: result.checkpoint.activeBranch, acceptance: result.checkpoint.acceptance };
91
- }
92
- /** Host-only policy binding for bounded external observation; no source bytes are read. */
93
- export function archivePolicyBinding(policyPath, sourceId) {
94
- const selected = selectedPolicy(policyPath, sourceId);
95
- return Object.freeze({ policySha256: selected.policySha256, archiveRoot: selected.policy.archiveRoot,
96
- sourceId, archiveSourceId: selected.archiveSourceId, expiresAt: selected.policy.expiresAt });
97
- }
98
- /** Explicit operator-selected file policy. Not a credential, authorization attestation or hostile-agent sandbox. */
99
- export function ingestPolicySource(policyPath, sourceId, previousCheckpointId, expectedPolicySha256) {
100
- try {
101
- const { policy, source, archiveSourceId, policySha256 } = selectedPolicy(policyPath, sourceId);
102
- if (expectedPolicySha256 !== undefined && expectedPolicySha256 !== policySha256)
103
- throw new Error("archive policy changed");
104
- if (source.contentPolicy === "referenced-blobs")
105
- return ingestNativePolicy({ policy, source, archiveSourceId, policySha256 }, previousCheckpointId, regularBytes);
106
- const bytes = regularBytes(join(policy.sourceRoot, source.path), policy.maxBytes);
107
- const result = ingestArchiveSnapshot(policy.archiveRoot, { sourceId: archiveSourceId, parser: source.parser, retention: policy.retention, bytes, previousCheckpointId });
108
- const receipt = retainArchiveSource(policy.archiveRoot, {
109
- sourceId: `policy-${policySha256}`, parser: { id: "archive-policy-receipt", version: "1" }, retention: "exact",
110
- bytes: Buffer.from(JSON.stringify({ version: "archive-policy-receipt-v1", policySha256, checkpointId: result.checkpointId, sourceId })),
111
- });
112
- return { ...metadata(result, result.checkpointId, policySha256), sourceId, archiveSourceId, change: result.change, policyReceiptId: receipt.manifestId };
113
- }
114
- catch {
115
- fail();
116
- }
117
- }
118
- /** Metadata-only CLI/read-model output; no payload, local path or policy file is exported. */
119
- export function inspectPolicyCheckpoint(policyPath, sourceId, checkpointId) {
120
- try {
121
- const { policy, source, archiveSourceId, policySha256 } = selectedPolicy(policyPath, sourceId);
122
- if (source.contentPolicy === "referenced-blobs")
123
- return inspectNativePolicy({ policy, source, archiveSourceId, policySha256 }, checkpointId);
124
- const result = readArchiveCheckpoint(policy.archiveRoot, checkpointId);
125
- const c = result.checkpoint;
126
- if (c.sourceId !== archiveSourceId || c.retention !== policy.retention || c.sourceBytes > policy.maxBytes
127
- || c.declaredParser.id !== source.parser.id || c.declaredParser.version !== source.parser.version)
128
- fail();
129
- return { ...metadata(result, checkpointId, policySha256), sourceId, archiveSourceId };
130
- }
131
- catch {
132
- fail();
133
- }
134
- }
135
- //# sourceMappingURL=archive-policy.js.map
@@ -1,49 +0,0 @@
1
- import { type GovernedArchiveRoute } from './archive-access.js';
2
- export interface ArchiveReadCapabilityOptions {
3
- root: string;
4
- /** Optional durable shared policy; absent preserves the historical raw route. */
5
- access?: GovernedArchiveRoute;
6
- /** Independently selected, content-reviewed artifact IDs; never accepted from model requests. */
7
- manifestIds: readonly string[];
8
- maxCalls: number;
9
- /** Total returned bytes, not a claim about OS-level read bandwidth or process memory. */
10
- maxBytes: number;
11
- durationMs: number;
12
- representations?: readonly ("exact" | "redacted")[];
13
- }
14
- /** A closed read interface for an existing host/tool integration, not an OS sandbox or model route qualification. */
15
- export declare function createArchiveReadCapability(options: ArchiveReadCapabilityOptions, clock?: () => number): Readonly<{
16
- snapshot: Readonly<{
17
- id: string;
18
- version: string;
19
- manifestIds: readonly any[];
20
- maxCalls: number;
21
- maxBytes: number;
22
- durationMs: number;
23
- representations: readonly string[];
24
- access?: Readonly<{
25
- directory: string;
26
- purpose: string;
27
- }> | undefined;
28
- }>;
29
- status: () => Readonly<{
30
- calls: number;
31
- bytes: number;
32
- expired: boolean;
33
- }>;
34
- read(manifestId: string): Readonly<{
35
- manifestId: string;
36
- reference: Readonly<{
37
- schema: "archive-source-v1";
38
- sourceId: string;
39
- parser: {
40
- id: string;
41
- version: string;
42
- };
43
- sha256: string;
44
- bytes: number;
45
- retention: import("./evidence-archive.js").ArchiveRetention;
46
- }>;
47
- bytes: Buffer<ArrayBuffer>;
48
- }>;
49
- }>;
@@ -1,45 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { performance } from "node:perf_hooks";
3
- import { readGovernedArchive } from './archive-access.js';
4
- import { readArchiveSource } from "./evidence-archive.js";
5
- /** A closed read interface for an existing host/tool integration, not an OS sandbox or model route qualification. */
6
- export function createArchiveReadCapability(options, clock = () => performance.now()) {
7
- if (!Array.isArray(options.manifestIds) || !options.manifestIds.length || options.manifestIds.length > 4096
8
- || options.manifestIds.some(id => typeof id !== "string" || !/^[a-f0-9]{64}$/.test(id))
9
- || !Number.isSafeInteger(options.maxCalls) || options.maxCalls < 1 || options.maxCalls > 128
10
- || !Number.isSafeInteger(options.maxBytes) || options.maxBytes < 1 || options.maxBytes > 64 * 1024 * 1024
11
- || !Number.isSafeInteger(options.durationMs) || options.durationMs < 1 || options.durationMs > 3600000)
12
- throw new Error("invalid archive capability bounds");
13
- const root = options.root, maxCalls = options.maxCalls, maxBytes = options.maxBytes, durationMs = options.durationMs;
14
- const representations = [...new Set(options.representations ?? ["redacted"])].sort();
15
- if (!representations.length || representations.some(r => r !== "exact" && r !== "redacted"))
16
- throw new Error("invalid archive representation policy");
17
- const ids = Object.freeze([...new Set(options.manifestIds)].sort()), allowed = new Set(ids), started = clock();
18
- if (!Number.isFinite(started))
19
- throw new Error("invalid host clock");
20
- const access = options.access ? Object.freeze({ ...options.access }) : undefined;
21
- const descriptor = { ...(access ? { access } : {}), version: "archive-read-capability-v1", manifestIds: ids, maxCalls, maxBytes, durationMs, representations: Object.freeze(representations) };
22
- const snapshot = Object.freeze({ ...descriptor, id: createHash("sha256").update(JSON.stringify(descriptor)).digest("hex") });
23
- let calls = 0, returned = 0;
24
- const elapsed = () => { const now = clock(); if (!Number.isFinite(now) || now < started)
25
- return Infinity; return now - started; };
26
- return Object.freeze({
27
- snapshot,
28
- status: () => Object.freeze({ calls, bytes: returned, expired: elapsed() >= durationMs }),
29
- read(manifestId) {
30
- if (calls >= maxCalls || elapsed() >= durationMs)
31
- throw new Error("archive read refused");
32
- calls++;
33
- if (typeof manifestId !== "string" || !allowed.has(manifestId))
34
- throw new Error("archive read refused");
35
- const limit = Math.min(8 * 1024 * 1024, maxBytes - returned);
36
- const source = access ? readGovernedArchive(root, manifestId, limit, access) : readArchiveSource(root, manifestId, limit);
37
- if (source.status !== "available" || !representations.includes(source.reference.retention)
38
- || source.bytes.length > maxBytes - returned || elapsed() >= durationMs)
39
- throw new Error("archive read refused");
40
- returned += source.bytes.length;
41
- return Object.freeze({ manifestId, reference: Object.freeze({ ...source.reference }), bytes: Buffer.from(source.bytes) });
42
- },
43
- });
44
- }
45
- //# sourceMappingURL=archive-read-capability.js.map
@@ -1,52 +0,0 @@
1
- import type { ArchiveIngestionPolicy, PolicySource } from "./archive-policy.js";
2
- interface Context {
3
- policy: ArchiveIngestionPolicy;
4
- source: PolicySource;
5
- archiveSourceId: string;
6
- policySha256: string;
7
- }
8
- export declare function inspectNativePolicy(context: Context, checkpointId: string): {
9
- kind: "execution-retention-v2";
10
- checkpointId: string;
11
- policySha256: string;
12
- sourceId: string;
13
- archiveSourceId: string;
14
- sourceSha256: string;
15
- sourceStatus: "available";
16
- retention: "exact";
17
- syntax: "not-applicable";
18
- runtime: "running" | "terminal";
19
- content: Record<"session" | "stdout" | "stderr" | "paneSnapshot" | "checkReceipt" | "result", {
20
- status: "available" | "missing" | "mismatch";
21
- sha256: string | null;
22
- bytes: number | null;
23
- }>;
24
- activeBranch: null;
25
- coverage: "partial";
26
- issueCount: number;
27
- acceptance: "not-assessed";
28
- };
29
- export declare function ingestNativePolicy(context: Context, previous: string | undefined, readBytes: (path: string, limit: number) => Buffer): {
30
- change: string;
31
- policyReceiptId: string;
32
- kind: "execution-retention-v2";
33
- checkpointId: string;
34
- policySha256: string;
35
- sourceId: string;
36
- archiveSourceId: string;
37
- sourceSha256: string;
38
- sourceStatus: "available";
39
- retention: "exact";
40
- syntax: "not-applicable";
41
- runtime: "running" | "terminal";
42
- content: Record<"session" | "stdout" | "stderr" | "paneSnapshot" | "checkReceipt" | "result", {
43
- status: "available" | "missing" | "mismatch";
44
- sha256: string | null;
45
- bytes: number | null;
46
- }>;
47
- activeBranch: null;
48
- coverage: "partial";
49
- issueCount: number;
50
- acceptance: "not-assessed";
51
- };
52
- export {};
@@ -1,49 +0,0 @@
1
- import { dirname, join } from "node:path";
2
- import { parseExecutionRetentionManifest } from "./generated/retention-v2-contract.js";
3
- import { ingestRetainedExecution, readRetainedExecution } from "./execution-retention-archive.js";
4
- import { retainArchiveSource } from "./evidence-archive.js";
5
- function metadata(context, checkpointId, projection) {
6
- return {
7
- kind: "execution-retention-v2", checkpointId, policySha256: context.policySha256,
8
- sourceId: context.source.id, archiveSourceId: context.archiveSourceId, sourceSha256: projection.sourceSha256,
9
- sourceStatus: "available", retention: "exact", syntax: "not-applicable",
10
- runtime: projection.runtime, content: projection.content, activeBranch: null,
11
- coverage: projection.coverage, issueCount: projection.issues.length, acceptance: projection.acceptance,
12
- };
13
- }
14
- export function inspectNativePolicy(context, checkpointId) {
15
- const read = readRetainedExecution(context.policy.archiveRoot, checkpointId);
16
- if (read.sourceId !== context.archiveSourceId || Object.values(read.manifest.content).some(ref => ref.bytes !== null && ref.bytes > context.policy.maxBytes))
17
- throw new Error("native snapshot outside policy");
18
- return metadata(context, checkpointId, read.projection);
19
- }
20
- export function ingestNativePolicy(context, previous, readBytes) {
21
- if (previous)
22
- inspectNativePolicy(context, previous);
23
- const path = join(context.policy.sourceRoot, context.source.path);
24
- const manifestBytes = readBytes(path, Math.min(context.policy.maxBytes, 65536));
25
- const manifest = parseExecutionRetentionManifest(new TextDecoder("utf-8", { fatal: true }).decode(manifestBytes));
26
- const blobs = new Map();
27
- for (const ref of Object.values(manifest.content)) {
28
- if (!ref.path)
29
- continue;
30
- if (ref.bytes > context.policy.maxBytes)
31
- throw new Error("native content exceeds policy bound");
32
- try {
33
- blobs.set(ref.path, readBytes(join(dirname(path), ref.path), Math.min(context.policy.maxBytes, 1024 * 1024)));
34
- }
35
- catch (error) {
36
- if (error.code !== "ENOENT")
37
- throw error;
38
- }
39
- }
40
- const result = ingestRetainedExecution(context.policy.archiveRoot, {
41
- manifest: manifestBytes, blobs, retention: "exact", sourceId: context.archiveSourceId,
42
- });
43
- const receipt = retainArchiveSource(context.policy.archiveRoot, {
44
- sourceId: `policy-${context.policySha256}`, parser: { id: "archive-policy-receipt", version: "1" }, retention: "exact",
45
- bytes: Buffer.from(JSON.stringify({ version: "archive-policy-receipt-v1", policySha256: context.policySha256, checkpointId: result.snapshotId, sourceId: context.source.id })),
46
- });
47
- return { ...metadata(context, result.snapshotId, result.projection), change: previous === result.snapshotId ? "repeat" : previous ? "observation" : "initial", policyReceiptId: receipt.manifestId };
48
- }
49
- //# sourceMappingURL=archive-retention-policy.js.map
@@ -1,45 +0,0 @@
1
- import { type WorkProjectionContext, type WorkFrozen, type WorkProjection } from "./generated/work-v4/reader.js";
2
- import type { WorkDetectionOptions } from "./work-candidates.js";
3
- import type { WorkSignalFacts } from "@skill-harness/core";
4
- export type ArchivedWork = {
5
- state: "available";
6
- manifestId: string;
7
- sourceSha256: string;
8
- producerCommit: string;
9
- projection: WorkFrozen<WorkProjection>;
10
- } | {
11
- state: "missing" | "error";
12
- manifestId: string;
13
- reason: string;
14
- };
15
- /** Pinned producer's actual pure reader/projector, with no append/inspect/file-writing API in the generated facade. */
16
- export declare function readArchivedWork(root: string, manifestId: string, context?: WorkFrozen<WorkProjectionContext>): ArchivedWork;
17
- /** Preserve raw work bytes, derived facts and candidate batch linkage. No authority is read from an archive/context file. */
18
- export declare function captureArchivedWorkCandidates(root: string, manifestId: string, context: WorkFrozen<WorkProjectionContext>, options: WorkDetectionOptions): {
19
- linkageManifestId: string;
20
- version: string;
21
- workManifestId: string;
22
- workSha256: string;
23
- producerCommit: string;
24
- observationId: string;
25
- caseBatchId: string;
26
- candidateIds: string[];
27
- authorityBasis: string;
28
- acceptance: string;
29
- };
30
- /** Derive binding/coverage/acceptance fields from the real pinned P01 projection, not caller replacements. */
31
- export declare function captureArchivedWorkSignals(root: string, manifestId: string, context: WorkFrozen<WorkProjectionContext>, suppliedFacts: WorkSignalFacts | null): {
32
- linkageManifestId: string;
33
- version: string;
34
- bindingProfile: string;
35
- workManifestId: string;
36
- workSha256: string;
37
- producerCommit: string;
38
- projectionManifestId: string;
39
- runtimeFactsManifestId: string;
40
- observationId: string;
41
- caseBatchId: string;
42
- candidateIds: string[];
43
- authorityBasis: string;
44
- acceptance: string;
45
- };