@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,78 +0,0 @@
1
- import { readArchiveSource, retainArchiveSource } from "./evidence-archive.js";
2
- import { projectWorkLedger } from "./generated/work-v4/reader.js";
3
- import { WORK_V4_READER_COMMIT } from "./generated/work-v4/pin.js";
4
- import { captureWorkCandidates } from "./work-case-archive.js";
5
- import { retainWorkSignalObservation } from "./work-signal-observation.js";
6
- import { captureWorkSignalCases } from "./work-signal-cases.js";
7
- /** Pinned producer's actual pure reader/projector, with no append/inspect/file-writing API in the generated facade. */
8
- export function readArchivedWork(root, manifestId, context = { selectedSnapshot: null, authority: null }) {
9
- const source = readArchiveSource(root, manifestId);
10
- if (source.status !== "available")
11
- return { state: source.status === "missing" ? "missing" : "error", manifestId, reason: "work-source-unavailable" };
12
- if (source.reference.retention !== "exact" || source.reference.parser.id !== "pi-daddy-work-ledger" || source.reference.parser.version !== "4")
13
- return { state: "error", manifestId, reason: "exact-work-v4-source-required" };
14
- try {
15
- const text = new TextDecoder("utf-8", { fatal: true }).decode(source.bytes);
16
- const projection = projectWorkLedger(text, context);
17
- return { state: "available", manifestId, sourceSha256: source.reference.sha256, producerCommit: WORK_V4_READER_COMMIT, projection };
18
- }
19
- catch {
20
- return { state: "error", manifestId, reason: "invalid-work-source-or-context" };
21
- }
22
- }
23
- /** Preserve raw work bytes, derived facts and candidate batch linkage. No authority is read from an archive/context file. */
24
- export function captureArchivedWorkCandidates(root, manifestId, context, options) {
25
- const read = readArchivedWork(root, manifestId, context);
26
- if (read.state !== "available" || read.projection.errors.length || read.projection.scopeState !== "valid")
27
- throw new Error("work source/selection incomplete; cannot nominate behavior");
28
- const cases = captureWorkCandidates(root, read.projection, options);
29
- const linkage = { version: "archived-work-candidates-v1", workManifestId: manifestId, workSha256: read.sourceSha256, producerCommit: read.producerCommit,
30
- observationId: cases.observationId, caseBatchId: cases.batchId, candidateIds: cases.candidateIds, authorityBasis: "independently-supplied-host-context", acceptance: "not-assessed" };
31
- const stored = retainArchiveSource(root, { sourceId: `work-case-link-${read.sourceSha256}`, parser: { id: "archived-work-candidates", version: "1" }, retention: "exact", bytes: Buffer.from(JSON.stringify(linkage)) });
32
- return { ...linkage, linkageManifestId: stored.manifestId };
33
- }
34
- /** Derive binding/coverage/acceptance fields from the real pinned P01 projection, not caller replacements. */
35
- export function captureArchivedWorkSignals(root, manifestId, context, suppliedFacts) {
36
- const read = readArchivedWork(root, manifestId, context);
37
- if (read.state !== "available" || read.projection.errors.length || read.projection.scopeState !== "valid" || !read.projection.selectedSnapshot || !read.projection.runtime)
38
- throw new Error("work source/selection incomplete; cannot capture signals");
39
- const work = read.projection, runtime = read.projection.runtime, snapshotDigest = read.projection.selectedSnapshot.digest;
40
- const snapshot = { snapshotDigest, scopeValid: true,
41
- obligations: work.obligations.map(o => ({ id: o.binding.obligation.id, digest: o.binding.obligation.digest,
42
- intentDigest: o.binding.intent.digest, policyDigest: o.binding.policy.digest, artifactDigest: o.binding.artifact?.digest ?? null,
43
- acceptance: o.acceptance,
44
- coverage: [o.artifactCoverage.state, o.evidenceCoverage.state].includes("conflicted") ? "conflicted"
45
- : [o.artifactCoverage.state, o.evidenceCoverage.state].includes("unavailable") ? "unavailable"
46
- : o.artifactCoverage.state === "available" && o.evidenceCoverage.state === "available" && o.problems.every(p => p.code === "TRUSTED_REJECTION") ? "available" : "unknown" })) };
47
- // Null means derive only facts the retained projection itself establishes. Empty arrays are explicit:
48
- // runtime failure is not an objective violation, and absence cannot invent a deadline, expected wait,
49
- // prior acceptance or authority. Coverage candidates still follow from the projected obligation.
50
- const facts = suppliedFacts ?? { scopeDigest: snapshotDigest, version: "observed-work-v1", population: "retained-work",
51
- expectedWaits: [], checkpoints: [], violations: [], priorAccepted: [] };
52
- const runtimeFacts = {
53
- version: "observed-work-runtime-v1", snapshotDigest, sourceManifestId: manifestId,
54
- attempts: runtime.attempts.map(attempt => {
55
- const eventDigests = runtime.occurrences.filter(occurrence => occurrence.payload.executionId === attempt.executionId &&
56
- occurrence.payload.provenance === "observed" && ["completed", "failed", "cancelled"].includes(occurrence.payload.state))
57
- .map(occurrence => occurrence.event.digest).sort();
58
- return { executionId: attempt.executionId, state: attempt.state, resolution: attempt.resolution,
59
- completionEvidence: { state: eventDigests.length ? "available" : "unavailable", eventDigests } };
60
- }).sort((a, b) => a.executionId < b.executionId ? -1 : a.executionId > b.executionId ? 1 : 0),
61
- obligations: snapshot.obligations.map(obligation => ({ obligationDigest: obligation.digest, acceptance: obligation.acceptance, coverage: obligation.coverage }))
62
- .sort((a, b) => a.obligationDigest < b.obligationDigest ? -1 : a.obligationDigest > b.obligationDigest ? 1 : 0),
63
- unavailable: ["checkpoint-evidence", "expected-wait-evidence", "prior-acceptance-history"],
64
- };
65
- const retainedRuntimeFacts = retainArchiveSource(root, { sourceId: `observed-runtime-${read.sourceSha256}`, parser: { id: "observed-work-runtime-facts", version: "1" }, retention: "exact", bytes: Buffer.from(JSON.stringify(runtimeFacts)) });
66
- // All four digests here are REVISION identities, not artifact content digests.
67
- // Duplicate obligation bindings cannot be collapsed by this input profile; its validator refuses them.
68
- const observation = retainWorkSignalObservation(root, snapshot, facts);
69
- const projection = retainArchiveSource(root, { sourceId: `work-signal-projection-${read.sourceSha256}`, parser: { id: "pi-daddy-work-projection", version: "1" }, retention: "exact", bytes: Buffer.from(JSON.stringify(work)) });
70
- const cases = captureWorkSignalCases(root, observation.manifestId);
71
- const linkage = { version: "archived-work-signals-v1", bindingProfile: "work-v4-revision-digests-v1", workManifestId: manifestId,
72
- workSha256: read.sourceSha256, producerCommit: read.producerCommit, projectionManifestId: projection.manifestId,
73
- runtimeFactsManifestId: retainedRuntimeFacts.manifestId, observationId: observation.manifestId, caseBatchId: cases.batchId, candidateIds: cases.candidateIds,
74
- authorityBasis: "independently-supplied-host-context", acceptance: "not-assessed" };
75
- const stored = retainArchiveSource(root, { sourceId: `work-signal-link-${read.sourceSha256}`, parser: { id: "archived-work-signals", version: "1" }, retention: "exact", bytes: Buffer.from(JSON.stringify(linkage)) });
76
- return { ...linkage, linkageManifestId: stored.manifestId };
77
- }
78
- //# sourceMappingURL=archived-work.js.map
@@ -1,35 +0,0 @@
1
- import { type BlindQualityChoice, type InterventionManifest, type InterventionEvidence, type InterventionQualification } from "@skill-harness/core";
2
- /** Explicit private retention. Host role declarations are NOT authentication. No provider is called. */
3
- export declare function retainBlindIntervention(root: string, manifest: InterventionManifest, evidence: InterventionEvidence[], qualification: InterventionQualification, author: string): string;
4
- /** Opaque linkage metadata only; never exposes roles, arm identities or cost before choice. */
5
- export declare function readBlindInterventionBinding(root: string, id: string, author: string): Readonly<{
6
- experimentDigest: string;
7
- investigationDigest: string;
8
- }>;
9
- /** One immutable quality choice per comparison. Reopening cannot reset the reveal gate. */
10
- export declare function openBlindIntervention(root: string, id: string, author: string): Readonly<{
11
- view: () => {
12
- version: string;
13
- cards: {
14
- label: string;
15
- artifactDigests: string[];
16
- }[];
17
- limitations: string[];
18
- };
19
- quality(): BlindQualityChoice | null;
20
- previewChoice(input: BlindQualityChoice): BlindQualityChoice;
21
- readArtifact: (label: string, hash: string) => Buffer<ArrayBuffer>;
22
- choose(input: BlindQualityChoice): BlindQualityChoice;
23
- reveal(): {
24
- manifestId: string;
25
- choice: BlindQualityChoice;
26
- arms: {
27
- label: string;
28
- armId: string;
29
- configuration: Record<import("@skill-harness/core").InterventionAxis, string>;
30
- cost: number | null;
31
- costUnit: string;
32
- }[];
33
- routingDefault: null;
34
- };
35
- }>;
@@ -1,218 +0,0 @@
1
- import { constants, closeSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readSync, writeSync } from "node:fs";
2
- import { createHash, randomBytes } from "node:crypto";
3
- import { join } from "node:path";
4
- import { assessIntervention, createBlindComparison, interventionCanonicalJson } from "@skill-harness/core";
5
- import { readArchiveSource, retainArchiveSource } from "./evidence-archive.js";
6
- const SHA = /^[a-f0-9]{64}$/;
7
- const missing = (e) => e?.code === "ENOENT";
8
- const encode = interventionCanonicalJson;
9
- const copy = (value) => JSON.parse(encode(value));
10
- function keys(value, names) {
11
- if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).sort().join() !== names.sort().join())
12
- throw new Error("invalid blind record fields");
13
- }
14
- function authorValid(author) {
15
- if (typeof author !== "string" || !author.length || author.length > 512 || /[\u0000-\u001f\u007f]/.test(author))
16
- throw new Error("explicit blind author required");
17
- }
18
- function claimsValid(claims, manifest) {
19
- keys(claims, ["manifestId", "proposer", "judge", "subjects", "evidenceDigests"]);
20
- for (const role of [claims.proposer, claims.judge])
21
- keys(role, ["requested", "canonical"]);
22
- keys(claims.subjects, manifest.arms.map(a => a.id));
23
- keys(claims.evidenceDigests, manifest.arms.map(a => a.id));
24
- for (const role of Object.values(claims.subjects))
25
- keys(role, ["requested", "canonical"]);
26
- }
27
- /** Explicit private retention. Host role declarations are NOT authentication. No provider is called. */
28
- export function retainBlindIntervention(root, manifest, evidence, qualification, author) {
29
- authorValid(author);
30
- const descriptors = Object.getOwnPropertyDescriptors(qualification);
31
- if (Reflect.ownKeys(descriptors).some(k => typeof k !== "string" || !descriptors[k].enumerable || !Object.hasOwn(descriptors[k], "value")))
32
- throw new Error("plain qualification required");
33
- keys(qualification, ["manifestId", "proposer", "judge", "subjects", "evidenceDigests", "artifacts"]);
34
- const { artifacts: artifactDescriptor, ...rest } = descriptors;
35
- const claims = copy(Object.fromEntries(Object.entries(rest).map(([k, d]) => [k, d.value])));
36
- const stableManifest = copy(manifest), stableEvidence = copy(evidence);
37
- claimsValid(claims, stableManifest);
38
- if (!(artifactDescriptor.value instanceof Map))
39
- throw new Error("retained artifact map required");
40
- const artifacts = new Map();
41
- let total = 0;
42
- for (const [hash, bytes] of Map.prototype.entries.call(artifactDescriptor.value)) {
43
- if (typeof hash !== "string" || !SHA.test(hash) || !(bytes instanceof Uint8Array) || bytes.byteLength > 8 * 1024 * 1024 || artifacts.size >= 4096 || (total += bytes.byteLength) > 64 * 1024 * 1024)
44
- throw new Error("bounded blind artifacts required");
45
- const stable = Buffer.from(bytes);
46
- if (createHash("sha256").update(stable).digest("hex") !== hash)
47
- throw new Error("blind artifact digest mismatch");
48
- artifacts.set(hash, stable);
49
- }
50
- const assessment = assessIntervention(stableManifest, stableEvidence, { ...claims, artifacts });
51
- const seed = randomBytes(32).toString("hex");
52
- createBlindComparison(stableManifest, assessment, seed); // Refuse incomplete inputs BEFORE writes.
53
- const referenced = new Set(stableEvidence.flatMap(e => e.artifactDigests));
54
- if ([...artifacts.keys()].some(h => !referenced.has(h)))
55
- throw new Error("unreferenced blind artifact");
56
- const refs = [...artifacts].sort(([a], [b]) => a.localeCompare(b)).map(([hash, bytes]) => ({ hash,
57
- manifestId: retainArchiveSource(root, { sourceId: `blind-artifact-${hash}`, parser: { id: "blind-artifact", version: "1" }, retention: "exact", bytes }).manifestId }));
58
- const bundle = { version: "retained-blind-intervention-v1", manifest: stableManifest, evidence: stableEvidence, qualification: claims, artifacts: refs, seed, author };
59
- return retainArchiveSource(root, { sourceId: `blind-${stableManifest.id}`, parser: { id: "blind-intervention", version: "1" }, retention: "exact", bytes: Buffer.from(encode(bundle)) }).manifestId;
60
- }
61
- function load(root, id, author) {
62
- authorValid(author);
63
- const source = readArchiveSource(root, id);
64
- if (source.status !== "available" || source.reference.retention !== "exact" || source.reference.parser.id !== "blind-intervention" || source.reference.parser.version !== "1")
65
- throw new Error("blind input unavailable");
66
- let bundle;
67
- try {
68
- const text = new TextDecoder("utf-8", { fatal: true }).decode(source.bytes);
69
- bundle = JSON.parse(text);
70
- if (encode(bundle) !== text)
71
- throw new Error();
72
- }
73
- catch {
74
- throw new Error("invalid blind input JSON");
75
- }
76
- keys(bundle, ["version", "manifest", "evidence", "qualification", "artifacts", "seed", "author"]);
77
- if (bundle.version !== "retained-blind-intervention-v1" || bundle.author !== author)
78
- throw new Error("blind author or version mismatch");
79
- claimsValid(bundle.qualification, bundle.manifest);
80
- if (!Array.isArray(bundle.artifacts) || bundle.artifacts.length > 4096)
81
- throw new Error("invalid blind artifacts");
82
- const artifacts = new Map();
83
- let total = 0;
84
- for (const ref of bundle.artifacts) {
85
- keys(ref, ["hash", "manifestId"]);
86
- if (!SHA.test(ref.hash) || artifacts.has(ref.hash))
87
- throw new Error("invalid blind artifact identity");
88
- const artifact = readArchiveSource(root, ref.manifestId);
89
- if (artifact.status !== "available" || artifact.reference.retention !== "exact" || artifact.reference.parser.id !== "blind-artifact" || artifact.reference.parser.version !== "1" || artifact.reference.sha256 !== ref.hash || (total += artifact.bytes.length) > 64 * 1024 * 1024)
90
- throw new Error("blind artifact unavailable");
91
- artifacts.set(ref.hash, artifact.bytes);
92
- }
93
- const assessment = assessIntervention(bundle.manifest, bundle.evidence, { ...bundle.qualification, artifacts });
94
- return { blind: createBlindComparison(bundle.manifest, assessment, bundle.seed), manifest: bundle.manifest };
95
- }
96
- /** Opaque linkage metadata only; never exposes roles, arm identities or cost before choice. */
97
- export function readBlindInterventionBinding(root, id, author) {
98
- const { manifest } = load(root, id, author);
99
- return Object.freeze({ experimentDigest: manifest.id, investigationDigest: manifest.investigationSha256 });
100
- }
101
- function directory(path) {
102
- const s = lstatSync(path);
103
- if (!s.isDirectory() || s.isSymbolicLink() || (s.mode & 0o077) || (process.getuid && s.uid !== process.getuid()))
104
- throw new Error("private blind directory required");
105
- }
106
- function syncDirectory(path) {
107
- const fd = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
108
- try {
109
- fsyncSync(fd);
110
- }
111
- finally {
112
- closeSync(fd);
113
- }
114
- }
115
- function readChoice(root, id) {
116
- const parent = join(root, "blind-decisions"), dir = join(parent, id);
117
- try {
118
- directory(parent);
119
- directory(dir);
120
- }
121
- catch (e) {
122
- if (missing(e))
123
- return null;
124
- throw e;
125
- }
126
- let fd;
127
- try {
128
- fd = openSync(join(dir, "choice.json"), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
129
- }
130
- catch (e) {
131
- if (missing(e))
132
- throw new Error("blind choice incomplete; explicit recovery required");
133
- throw e;
134
- }
135
- try {
136
- const s = fstatSync(fd);
137
- if (!s.isFile() || s.nlink !== 1 || (s.mode & 0o077) || (process.getuid && s.uid !== process.getuid()) || s.size > 16384)
138
- throw new Error("invalid blind choice file");
139
- const bytes = Buffer.alloc(16385);
140
- let used = 0;
141
- while (used < bytes.length) {
142
- const n = readSync(fd, bytes, used, bytes.length - used, used);
143
- if (!n)
144
- break;
145
- used += n;
146
- }
147
- if (used > 16384)
148
- throw new Error("invalid blind choice bound");
149
- try {
150
- const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, used));
151
- const value = JSON.parse(text);
152
- if (encode(value) !== text)
153
- throw new Error();
154
- return value;
155
- }
156
- catch {
157
- throw new Error("invalid blind choice JSON; explicit recovery required");
158
- }
159
- }
160
- finally {
161
- closeSync(fd);
162
- }
163
- }
164
- /** One immutable quality choice per comparison. Reopening cannot reset the reveal gate. */
165
- export function openBlindIntervention(root, id, author) {
166
- if (!SHA.test(id))
167
- throw new Error("invalid blind comparison identity");
168
- const current = () => load(root, id, author).blind;
169
- return Object.freeze({
170
- view: () => current().view(),
171
- quality() { const blind = current(), choice = readChoice(root, id); return choice ? blind.choose(choice) : null; },
172
- previewChoice(input) { return current().choose(input); },
173
- readArtifact: (label, hash) => current().readArtifact(label, hash),
174
- choose(input) {
175
- const blind = current(), choice = blind.choose(input);
176
- const before = readChoice(root, id);
177
- if (before) {
178
- blind.choose(before);
179
- if (encode(before) !== encode(choice))
180
- throw new Error("blind quality choice locked");
181
- return before;
182
- }
183
- const parent = join(root, "blind-decisions"), dir = join(parent, id);
184
- try {
185
- mkdirSync(parent, { mode: 0o700 });
186
- }
187
- catch (e) {
188
- if (e.code !== "EEXIST")
189
- throw e;
190
- }
191
- directory(parent);
192
- // Atomic mkdir is the single-writer claim. Never remove or recover an incomplete claim automatically.
193
- mkdirSync(dir, { mode: 0o700 });
194
- const fd = openSync(join(dir, "choice.json"), constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 0o600);
195
- try {
196
- const data = Buffer.from(encode(choice));
197
- let offset = 0;
198
- while (offset < data.length) {
199
- const n = writeSync(fd, data, offset, data.length - offset);
200
- if (!n)
201
- throw new Error("blind choice write stalled");
202
- offset += n;
203
- }
204
- fsyncSync(fd);
205
- }
206
- finally {
207
- closeSync(fd);
208
- }
209
- syncDirectory(dir);
210
- syncDirectory(parent);
211
- syncDirectory(root);
212
- return choice;
213
- },
214
- reveal() { const blind = current(), choice = readChoice(root, id); if (!choice)
215
- throw new Error("durable quality choice required before reveal"); blind.choose(choice); return blind.reveal(); },
216
- });
217
- }
218
- //# sourceMappingURL=blind-intervention.js.map
@@ -1,14 +0,0 @@
1
- import type { CodexSdkBinding } from './codex-sdk-transport.js';
2
- export interface CodexDiagnosticModelPin {
3
- path: string;
4
- sha256: string;
5
- }
6
- /** Local catalogue declaration only, NOT canonical resolution or account entitlement. */
7
- export declare function validateCodexDiagnosticModel(raw: unknown): CodexSdkBinding['model'];
8
- export declare function loadCodexDiagnosticModel(pin: CodexDiagnosticModelPin): {
9
- [key: string]: unknown;
10
- id: string;
11
- provider: string;
12
- api: string;
13
- baseUrl: string;
14
- };
@@ -1,39 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { isAbsolute } from 'node:path';
3
- import { learningCopy, learningFile } from './learning-journal.js';
4
- const closed = (v, keys) => { if (!v || typeof v !== 'object' || Array.isArray(v) || Object.keys(v).sort().join() !== keys.sort().join())
5
- throw Error('closed diagnostic model definition required'); };
6
- /** Local catalogue declaration only, NOT canonical resolution or account entitlement. */
7
- export function validateCodexDiagnosticModel(raw) {
8
- const m = learningCopy(raw);
9
- closed(m, ['id', 'name', 'provider', 'api', 'baseUrl', 'reasoning', 'input', 'cost', 'contextWindow', 'maxTokens', 'thinkingLevelMap', 'compat']);
10
- if (m.id !== 'gpt-6-astra' || m.name !== 'GPT-6 Astra' || m.provider !== 'openai-codex' || m.api !== 'openai-codex-responses' || m.baseUrl !== 'https://chatgpt.com/backend-api' || m.reasoning !== true || JSON.stringify(m.input) !== '["text","image"]' || ![m.contextWindow, m.maxTokens].every(n => Number.isSafeInteger(n) && n > 0))
11
- throw Error('diagnostic model identity/capability mismatch');
12
- closed(m.thinkingLevelMap, ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
13
- if (m.thinkingLevelMap.off !== null || m.thinkingLevelMap.minimal !== 'low' || ['low', 'medium', 'high', 'xhigh', 'max'].some(k => m.thinkingLevelMap[k] !== k))
14
- throw Error('diagnostic effort mapping mismatch');
15
- closed(m.compat, ['supportsOpenAIGrammarTools', 'supportsAdditionalTools', 'supportsToolSearch']);
16
- if (!Object.values(m.compat).every(v => typeof v === 'boolean'))
17
- throw Error('diagnostic compatibility mismatch');
18
- const prices = ['input', 'output', 'cacheRead', 'cacheWrite'];
19
- closed(m.cost, [...prices, 'tiers']);
20
- if (!Array.isArray(m.cost.tiers) || m.cost.tiers.length > 8)
21
- throw Error('diagnostic cost declaration');
22
- for (const [i, cost] of [m.cost, ...m.cost.tiers].entries()) {
23
- if (i)
24
- closed(cost, ['inputTokensAbove', ...prices]);
25
- if (![...prices, ...(i ? ['inputTokensAbove'] : [])].every(k => typeof cost[k] === 'number' && Number.isFinite(cost[k]) && cost[k] >= 0))
26
- throw Error('diagnostic cost declaration');
27
- }
28
- return m;
29
- }
30
- export function loadCodexDiagnosticModel(pin) {
31
- closed(pin, ['path', 'sha256']);
32
- if (typeof pin.path !== 'string' || !isAbsolute(pin.path) || !/^[a-f0-9]{64}$/.test(pin.sha256))
33
- throw Error('diagnostic definition pin required');
34
- const bytes = learningFile(pin.path, 8192);
35
- if (createHash('sha256').update(bytes).digest('hex') !== pin.sha256)
36
- throw Error('diagnostic definition source mismatch');
37
- return validateCodexDiagnosticModel(JSON.parse(bytes.toString('utf8')));
38
- }
39
- //# sourceMappingURL=codex-diagnostic-model.js.map
@@ -1,111 +0,0 @@
1
- import type { Readable, Writable } from 'node:stream';
2
- import { type CodexSdkBinding, type CodexWireTransport } from './codex-sdk-transport.js';
3
- /** LOCAL host protocol with an inert installed-SDK seam; no auth loader or live network switch.
4
- * The trusted host owns this module and transport streams; the subject gets framed IPC only.
5
- * Stream finish proves a host-side write, NOT provider receipt, backend identity or token limits.
6
- * Journal integrity assumes a trusted cooperative host/filesystem, not hostile same-UID rollback. */
7
- export declare const CODEX_SUBSCRIPTION_DESTINATION = "https://chatgpt.com/backend-api/codex/responses";
8
- type Role = 'proposer' | 'subject' | 'judge';
9
- export interface LocalCodexInvocation {
10
- id: string;
11
- role: Role;
12
- model: string;
13
- effort: 'low' | 'medium' | 'high';
14
- instructions: string;
15
- input: string;
16
- expectedSha256: string;
17
- subjectId: string | null;
18
- }
19
- export interface LocalCodexHostSpec {
20
- version: 'codex-host-local-v1';
21
- maxCalls: number;
22
- wallMs: number;
23
- invocations: LocalCodexInvocation[];
24
- }
25
- export interface SubscriptionReservations {
26
- charterSha256: string;
27
- mode: 'fixture' | 'subscription-live';
28
- requestBytes: number;
29
- responseBytes: number;
30
- totalRequestBytes: number;
31
- totalResponseBytes: number;
32
- callMs: number;
33
- }
34
- export interface LocalCodexObservation {
35
- id: string;
36
- sequence: number;
37
- requestBody: string;
38
- requestSha256: string;
39
- outputBase64: string;
40
- outputSha256: string;
41
- objective: 'PASS' | 'FAIL';
42
- providerInternalFacts: null;
43
- liveQualified: false;
44
- }
45
- /** This checks supplied policy consistency, never authenticates its source or invents lineage. */
46
- export declare function inspectCodexRoleSeparation(raw: Array<{
47
- role: Role;
48
- model: string;
49
- canonical: string | null;
50
- lineage: string | null;
51
- }>): {
52
- state: "BLOCKED";
53
- reason: string;
54
- liveQualified: false;
55
- } | {
56
- state: "CONSISTENT_DECLARATION_ONLY";
57
- reason: string;
58
- disclosures: string[];
59
- liveQualified: false;
60
- };
61
- export declare function createLocalCodexHost(path: string, input: LocalCodexHostSpec, rolePolicy?: Parameters<typeof inspectCodexRoleSeparation>[0], subscription?: SubscriptionReservations): {
62
- inspect: () => {
63
- calls: number;
64
- complete: boolean;
65
- aborted: boolean;
66
- liveQualified: false;
67
- };
68
- exchangeSubscriptionSdk(subjectFrames: Readable, binding: CodexSdkBinding, transport: CodexWireTransport, charterSha256: string, sourceSignal?: AbortSignal): Promise<LocalCodexObservation>;
69
- exchangeSdk(subjectFrames: Readable, binding: CodexSdkBinding, fixture: () => Promise<Response>): Promise<LocalCodexObservation>;
70
- exchange(subjectFrames: Readable, hostTransport: Writable, hostResponse: Readable, subscriptionMode?: boolean, sourceSignal?: AbortSignal): Promise<LocalCodexObservation>;
71
- panel(subjectId: string, judgeIds: string[], rawPolicy: Parameters<typeof inspectCodexRoleSeparation>[0]): {
72
- label: string;
73
- collapse: import("@skill-harness/core").VotePanelCollapse;
74
- identityStatus: "CONSISTENT_DECLARATION_ONLY";
75
- disclosures: string[];
76
- liveQualified: false;
77
- routingDefault: null;
78
- };
79
- eligibleOutputs(): {
80
- label: string;
81
- outputBase64: string;
82
- outputSha256: string;
83
- liveQualified: false;
84
- }[];
85
- };
86
- export declare function openLocalCodexHost(path: string): {
87
- inspect: () => {
88
- calls: number;
89
- complete: boolean;
90
- aborted: boolean;
91
- liveQualified: false;
92
- };
93
- exchangeSubscriptionSdk(subjectFrames: Readable, binding: CodexSdkBinding, transport: CodexWireTransport, charterSha256: string, sourceSignal?: AbortSignal): Promise<LocalCodexObservation>;
94
- exchangeSdk(subjectFrames: Readable, binding: CodexSdkBinding, fixture: () => Promise<Response>): Promise<LocalCodexObservation>;
95
- exchange(subjectFrames: Readable, hostTransport: Writable, hostResponse: Readable, subscriptionMode?: boolean, sourceSignal?: AbortSignal): Promise<LocalCodexObservation>;
96
- panel(subjectId: string, judgeIds: string[], rawPolicy: Parameters<typeof inspectCodexRoleSeparation>[0]): {
97
- label: string;
98
- collapse: import("@skill-harness/core").VotePanelCollapse;
99
- identityStatus: "CONSISTENT_DECLARATION_ONLY";
100
- disclosures: string[];
101
- liveQualified: false;
102
- routingDefault: null;
103
- };
104
- eligibleOutputs(): {
105
- label: string;
106
- outputBase64: string;
107
- outputSha256: string;
108
- liveQualified: false;
109
- }[];
110
- };
111
- export {};