@vela-science/canopus 0.6.5 → 0.8.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 (120) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +67 -139
  3. package/SECURITY.md +3 -2
  4. package/capsules/erdos1056-k15/bin/linux-arm64/{10428801-10429000 → 10429201-10429400}/verifier +0 -0
  5. package/capsules/erdos1056-k15/bin/linux-x86_64/{10428801-10429000 → 10429201-10429400}/verifier +0 -0
  6. package/compatibility.json +25 -0
  7. package/dist/src/activity/events.d.ts +4 -1
  8. package/dist/src/activity/events.js +8 -2
  9. package/dist/src/activity/store.d.ts +2 -2
  10. package/dist/src/activity/store.js +4 -3
  11. package/dist/src/{receipt/map.d.ts → candidate/finalize.d.ts} +2 -9
  12. package/dist/src/candidate/finalize.js +71 -0
  13. package/dist/src/cli.js +88 -229
  14. package/dist/src/contracts/mission.d.ts +1 -13
  15. package/dist/src/contracts/mission.js +4 -42
  16. package/dist/src/contracts/validation.d.ts +1 -25
  17. package/dist/src/contracts/validation.js +1 -95
  18. package/dist/src/engines/codex-tools-native.js +2 -2
  19. package/dist/src/index.d.ts +5 -34
  20. package/dist/src/index.js +4 -34
  21. package/dist/src/mission/prepare.d.ts +10 -1
  22. package/dist/src/mission/prepare.js +29 -30
  23. package/dist/src/product/coverage.d.ts +17 -0
  24. package/dist/src/product/coverage.js +137 -0
  25. package/dist/src/product/doctor.d.ts +1 -2
  26. package/dist/src/product/doctor.js +29 -8
  27. package/dist/src/product/profile.js +8 -2
  28. package/dist/src/product/replay.js +11 -12
  29. package/dist/src/product/run.d.ts +5 -9
  30. package/dist/src/product/run.js +17 -88
  31. package/dist/src/product/submission.d.ts +40 -0
  32. package/dist/src/product/submission.js +217 -0
  33. package/dist/src/product/submit.d.ts +22 -0
  34. package/dist/src/product/submit.js +264 -0
  35. package/dist/src/product/version.d.ts +2 -2
  36. package/dist/src/product/version.js +27 -4
  37. package/dist/src/projection/current-run.d.ts +12 -0
  38. package/dist/src/projection/current-run.js +94 -0
  39. package/dist/src/projection/failure.d.ts +17 -7
  40. package/dist/src/projection/failure.js +43 -12
  41. package/dist/src/projection/retained-mission.d.ts +6 -0
  42. package/dist/src/projection/retained-mission.js +41 -0
  43. package/dist/src/projection/retained-run.d.ts +7 -0
  44. package/dist/src/projection/retained-run.js +50 -0
  45. package/dist/src/run.d.ts +43 -41
  46. package/dist/src/run.js +34 -412
  47. package/dist/src/util/canonical.d.ts +1 -5
  48. package/dist/src/util/canonical.js +1 -53
  49. package/dist/src/vela/cli.d.ts +7 -51
  50. package/dist/src/vela/cli.js +102 -523
  51. package/dist/src/vela/types.d.ts +3 -19
  52. package/dist/src/verifier/run.js +1 -1
  53. package/dist/src/workspace/prepare.d.ts +1 -1
  54. package/dist/src/workspace/prepare.js +15 -15
  55. package/docs/EVALUATION.md +142 -0
  56. package/docs/MISSIONS.md +42 -80
  57. package/docs/RUN_RECORD.md +77 -99
  58. package/docs/adr/0010-nonmutating-runs-and-explicit-submission.md +191 -0
  59. package/missions/erdos1056-k15-next/mission.draft.json +10 -8
  60. package/package.json +18 -22
  61. package/profiles/{erdos1056-k15-10428801-10429000.json → erdos1056-k15-10429201-10429400.json} +10 -10
  62. package/schemas/failure.v1.json +17 -0
  63. package/schemas/mission.v0.json +3 -4
  64. package/schemas/mission.v1.json +7 -28
  65. package/schemas/{run.v1.json → run.v2.json} +58 -116
  66. package/schemas/submission-bundle.v1.json +63 -0
  67. package/toolchain.lock.json +31 -0
  68. package/BUILD_WEEK.md +0 -198
  69. package/advisories/erdos1056-claim-fidelity/output.schema.json +0 -90
  70. package/advisories/erdos1056-claim-fidelity/registration.json +0 -42
  71. package/advisories/erdos1056-claim-fidelity/results/assessment.json +0 -1
  72. package/advisories/erdos1056-claim-fidelity/results/verification.json +0 -1
  73. package/capsules/formal-erdos-505-test-dim-one/verifier +0 -105
  74. package/capsules/quantum-10-1-4/verifier.py +0 -152
  75. package/capsules/sidon-a24/bin/linux-arm64/verifier +0 -0
  76. package/capsules/sidon-a24/bin/linux-x86_64/verifier +0 -0
  77. package/dist/src/capability/withdrawal.d.ts +0 -47
  78. package/dist/src/capability/withdrawal.js +0 -487
  79. package/dist/src/engines/codex-exec.d.ts +0 -17
  80. package/dist/src/engines/codex-exec.js +0 -136
  81. package/dist/src/engines/codex-tool-free.d.ts +0 -26
  82. package/dist/src/engines/codex-tool-free.js +0 -213
  83. package/dist/src/product/withdraw.d.ts +0 -8
  84. package/dist/src/product/withdraw.js +0 -255
  85. package/dist/src/projection/diagnostic.d.ts +0 -12
  86. package/dist/src/projection/diagnostic.js +0 -61
  87. package/dist/src/projection/public-run.d.ts +0 -59
  88. package/dist/src/projection/public-run.js +0 -106
  89. package/dist/src/projection/publication.d.ts +0 -36
  90. package/dist/src/projection/publication.js +0 -47
  91. package/dist/src/projection/run.d.ts +0 -95
  92. package/dist/src/projection/run.js +0 -173
  93. package/dist/src/receipt/map.js +0 -168
  94. package/dist/src/repair/plan.d.ts +0 -2
  95. package/dist/src/repair/plan.js +0 -22
  96. package/dist/src/roles.d.ts +0 -2
  97. package/dist/src/roles.js +0 -9
  98. package/docs/RELEASES.md +0 -1389
  99. package/evidence/build-week/run_eb6bcd46-cffd-4ae8-b630-2681bd84da71.public.json +0 -1
  100. package/evidence/build-week/run_f68e4cfc-e5c7-4c73-86cb-d79807c47ec4.public.json +0 -1
  101. package/evidence/erdos/run_192b3bef-9d6e-49e5-b72d-7ae903b29d5e/pending-commands.json +0 -1
  102. package/evidence/erdos/run_192b3bef-9d6e-49e5-b72d-7ae903b29d5e/public-run.json +0 -1
  103. package/evidence/erdos/run_192b3bef-9d6e-49e5-b72d-7ae903b29d5e/root-manifest.json +0 -1
  104. package/evidence/erdos/run_192b3bef-9d6e-49e5-b72d-7ae903b29d5e/web-import.json +0 -1
  105. package/evidence/erdos/run_b3b0cf07-b149-4d53-8258-76ba0e1fc0a5/pending-commands.json +0 -1
  106. package/evidence/erdos/run_b3b0cf07-b149-4d53-8258-76ba0e1fc0a5/public-run.json +0 -1
  107. package/evidence/erdos/run_b3b0cf07-b149-4d53-8258-76ba0e1fc0a5/root-manifest.json +0 -1
  108. package/evidence/erdos/run_b3b0cf07-b149-4d53-8258-76ba0e1fc0a5/web-import.json +0 -1
  109. package/missions/formal-erdos-505-test-dim-one-gpt56/mission.draft.json +0 -40
  110. package/missions/quantum-10-1-4-retry/mission.draft.json +0 -40
  111. package/missions/sidon-a24-at-least-7194-gpt56/mission.draft.json +0 -42
  112. package/missions/sidon-a24-at-least-7194-gpt56-v2/mission.draft.json +0 -42
  113. package/missions/sidon-a24-at-least-7194-gpt56-v3/mission.draft.json +0 -42
  114. package/profiles/formal-erdos-505-test-dim-one-gpt56.json +0 -35
  115. package/profiles/quantum-10-1-4-stabilizer-retry.json +0 -35
  116. package/profiles/sidon-a24-at-least-7194-gpt56-v2.json +0 -35
  117. package/profiles/sidon-a24-at-least-7194-gpt56-v3.json +0 -35
  118. package/profiles/sidon-a24-at-least-7194-gpt56.json +0 -35
  119. package/schemas/canopus.public-run.v1.json +0 -116
  120. package/scripts/run-claim-fidelity-advisory.mjs +0 -235
@@ -1,106 +0,0 @@
1
- import { contentDigest } from "../util/canonical.js";
2
- export const PUBLIC_RUN_SCHEMA = "canopus.public-run.v1";
3
- function publicRepository(value) {
4
- if (!/^https:\/\/github\.com\/vela-science\/[a-z0-9-]+(?:\.git)?$/u.test(value)) {
5
- throw new Error("public run repository must be a public vela-science GitHub URL");
6
- }
7
- const url = value.endsWith(".git") ? value.slice(0, -4) : value;
8
- const directory = new URL(url).pathname.split("/").at(-1);
9
- if (directory === undefined || directory === "")
10
- throw new Error("public run repository is invalid");
11
- return { url, directory };
12
- }
13
- function publicCaveat(value) {
14
- if (/verif(?:y|ication|ier).*(?:pending|has not run)|pending.*verif(?:y|ication|ier)/iu.test(value)) {
15
- return "The worker handed off without verifier authority; Canopus subsequently recorded the separate verifier pass shown in this projection.";
16
- }
17
- return value;
18
- }
19
- function shellArgument(value) {
20
- return `'${value.replaceAll("'", `'"'"'`)}'`;
21
- }
22
- export function projectPublicRun(options) {
23
- const { record, mission } = options;
24
- if (mission.schema !== "canopus.mission.v1") {
25
- throw new Error("public run export requires a closed Mission v1 bundle");
26
- }
27
- if (contentDigest(mission) !== record.mission.digest) {
28
- throw new Error("public run mission bytes do not match the completed run");
29
- }
30
- if (mission.id !== record.mission.id || mission.target !== record.mission.target) {
31
- throw new Error("public run mission identity does not match the completed run");
32
- }
33
- if (record.candidate.status !== "success" || record.candidate.artifacts.length < 1) {
34
- throw new Error("public run export requires at least one successful bounded artifact");
35
- }
36
- if (record.verifier.status !== "passed" || record.reproduction.verifier_status !== "passed") {
37
- throw new Error("public run export requires verifier pass in both landing and replay");
38
- }
39
- if (!record.reproduction.matched) {
40
- throw new Error("public run export requires matched clean-clone replay");
41
- }
42
- if (record.landing.route !== "defer" || record.landing.accepted_event_delta !== 0) {
43
- throw new Error("public run export requires Defer with zero accepted-state delta");
44
- }
45
- const repository = publicRepository(options.repository);
46
- return {
47
- schema: PUBLIC_RUN_SCHEMA,
48
- authority: "read_only_projection",
49
- run_id: record.run_id,
50
- mission: {
51
- id: mission.id,
52
- target: mission.target,
53
- digest: record.mission.digest,
54
- registration_kind: mission.profile === undefined ? "mission_bundle" : "profile",
55
- registration_name: mission.profile?.name ?? mission.id,
56
- registration_root: mission.profile?.root ?? record.mission.digest,
57
- target_packet_root: mission.target_packet.sha256,
58
- model: mission.worker.model,
59
- },
60
- activity: {
61
- worker: "success",
62
- verifier: "pass",
63
- clean_clone_replay: "matched",
64
- },
65
- claim: record.candidate.claim,
66
- caveats: [...new Set(record.candidate.caveats.map(publicCaveat))],
67
- artifact_roots: record.candidate.artifacts.map((artifact) => artifact.digest).sort(),
68
- verifier_root: contentDigest(record.verifier),
69
- receipt_root: record.landing.receipt_root,
70
- policy: {
71
- route: "defer",
72
- proposal_id: record.landing.proposal_id,
73
- accepted_state_delta: 0,
74
- },
75
- usage: {
76
- research_elapsed_ms: record.budget.research_elapsed_ms,
77
- research_processes: record.budget.research_processes,
78
- observed_tokens: record.budget.observed_tokens,
79
- attempts: record.budget.attempts,
80
- },
81
- source: {
82
- repository: repository.url,
83
- commit: record.mission.starting_roots.git_commit,
84
- event_log_root: record.mission.starting_roots.vela_event_log,
85
- snapshot_root: record.mission.starting_roots.vela_snapshot,
86
- },
87
- final: {
88
- commit: record.final_roots.git_commit,
89
- event_log_root: record.final_roots.vela_event_log,
90
- snapshot_root: record.final_roots.vela_snapshot,
91
- },
92
- reproduction: {
93
- commands: [
94
- `git clone ${repository.url}.git`,
95
- `cd ${repository.directory}`,
96
- `git checkout ${record.final_roots.git_commit}`,
97
- ...mission.allowed_paths.map((artifact) => `vela reproduce ${shellArgument(artifact)}`),
98
- ],
99
- },
100
- nonclaims: [
101
- "Verifier success is not scientific acceptance.",
102
- "The bounded result does not establish maximality or settle the broader scientific problem.",
103
- "Canopus did not sign or perform a human decision.",
104
- ],
105
- };
106
- }
@@ -1,36 +0,0 @@
1
- import type { Mission } from "../contracts/mission.js";
2
- import type { RunRecord } from "./run.js";
3
- import { projectPublicRun } from "./public-run.js";
4
- export interface PublicationBundle {
5
- projection: ReturnType<typeof projectPublicRun>;
6
- pendingCommands: {
7
- schema: "canopus.pending-commands.v1";
8
- authority: "none";
9
- proposal_id: string;
10
- commands: Array<{
11
- purpose: string;
12
- authority: string;
13
- command: string;
14
- }>;
15
- };
16
- webImport: {
17
- schema: "vela-web.canopus-import.v1";
18
- authority: "read_only";
19
- run_id: string;
20
- projection_path: "public-run.json";
21
- projection_root: string;
22
- route: "defer";
23
- accepted_state_delta: 0;
24
- };
25
- manifest: {
26
- schema: "canopus.publication-manifest.v1";
27
- authority: "none";
28
- run_id: string;
29
- files: Record<string, string>;
30
- };
31
- }
32
- export declare function buildPublicationBundle(options: {
33
- record: RunRecord;
34
- mission: Mission;
35
- repository: string;
36
- }): PublicationBundle;
@@ -1,47 +0,0 @@
1
- import { contentDigest } from "../util/canonical.js";
2
- import { projectPublicRun } from "./public-run.js";
3
- export function buildPublicationBundle(options) {
4
- const projection = projectPublicRun(options);
5
- const pendingCommands = {
6
- schema: "canopus.pending-commands.v1",
7
- authority: "none",
8
- proposal_id: projection.policy.proposal_id,
9
- commands: [
10
- {
11
- purpose: "reproduce_pending_artifact",
12
- authority: "read_only",
13
- command: `vela reproduce . --proposal ${projection.policy.proposal_id} --json`,
14
- },
15
- {
16
- purpose: "inspect_review_material",
17
- authority: "read_only",
18
- command: `vela review show . ${projection.policy.proposal_id} --json`,
19
- },
20
- {
21
- purpose: "retain_independent_verifier_evidence",
22
- authority: "evidence_only",
23
- command: `vela verify attach . <attachment.json> --proposal ${projection.policy.proposal_id} --as verifier:<actor> --json`,
24
- },
25
- ],
26
- };
27
- const webImport = {
28
- schema: "vela-web.canopus-import.v1",
29
- authority: "read_only",
30
- run_id: projection.run_id,
31
- projection_path: "public-run.json",
32
- projection_root: contentDigest(projection),
33
- route: "defer",
34
- accepted_state_delta: 0,
35
- };
36
- const manifest = {
37
- schema: "canopus.publication-manifest.v1",
38
- authority: "none",
39
- run_id: projection.run_id,
40
- files: {
41
- "pending-commands.json": contentDigest(pendingCommands),
42
- "public-run.json": contentDigest(projection),
43
- "web-import.json": contentDigest(webImport),
44
- },
45
- };
46
- return { projection, pendingCommands, webImport, manifest };
47
- }
@@ -1,95 +0,0 @@
1
- import type { MissionRoots } from "../contracts/mission.js";
2
- export declare const RUN_RECORD_SCHEMA: "canopus.run.v1";
3
- export declare const LEGACY_RUN_RECORD_SCHEMA: "canopus.run.v0";
4
- export declare const RUN_PROJECTION_SCHEMA: "canopus.run-projection.v0";
5
- export interface RunRecord {
6
- schema: typeof RUN_RECORD_SCHEMA | typeof LEGACY_RUN_RECORD_SCHEMA;
7
- run_id: string;
8
- status: "completed";
9
- authority: "non_authoritative";
10
- external_gate_credit: false;
11
- mission: {
12
- id: string;
13
- target: string;
14
- digest: string;
15
- starting_roots: MissionRoots;
16
- };
17
- candidate: {
18
- digest: string;
19
- status: "success" | "null" | "failed";
20
- claim: string;
21
- artifacts: Array<{
22
- path: string;
23
- kind: string;
24
- digest: string;
25
- bytes: number;
26
- }>;
27
- caveats: string[];
28
- };
29
- observations?: {
30
- worker_observations: string[];
31
- verifier_observations: string[];
32
- standing_caveats: string[];
33
- };
34
- verifier: {
35
- status: "passed" | "failed" | "error";
36
- sandbox: "macos_sandbox" | "container_network_denied";
37
- record: {
38
- argv: string[];
39
- executable_digest: string;
40
- exit_code: number;
41
- stdout_digest: string;
42
- stderr_digest: string;
43
- duration_ms: number;
44
- };
45
- };
46
- landing: {
47
- operation_id: string;
48
- receipt_root: string;
49
- proposal_id: string;
50
- route: "permit" | "defer" | "exact_retry";
51
- original_route: "permit" | "defer" | null;
52
- accepted_event_delta: number | null;
53
- publication_state: string;
54
- };
55
- final_roots: MissionRoots;
56
- reproduction: {
57
- matched: boolean;
58
- roots: MissionRoots;
59
- verifier_status: "passed" | "failed" | "error";
60
- stdout_digest: string;
61
- stderr_digest: string;
62
- };
63
- budget: {
64
- research_elapsed_ms: number;
65
- research_processes: number;
66
- research_output_bytes: number;
67
- prompt_bytes: number;
68
- artifact_bytes: number;
69
- attempts: number;
70
- observed_tokens: number;
71
- };
72
- }
73
- export interface RunProjection {
74
- schema: typeof RUN_PROJECTION_SCHEMA;
75
- authority: "read_only_projection";
76
- run_id: string;
77
- mission_id: string;
78
- target: string;
79
- starting_roots: MissionRoots;
80
- final_roots: MissionRoots;
81
- candidate_digest: string;
82
- candidate_status: "success" | "null" | "failed";
83
- artifact_digests: string[];
84
- verifier_status: "passed" | "failed" | "error";
85
- receipt_root: string;
86
- proposal_id: string;
87
- route: "permit" | "defer" | "exact_retry";
88
- original_route: "permit" | "defer" | null;
89
- accepted_state_effect: "policy_admitted" | "unchanged_pending" | "exact_retry";
90
- publication_state: string;
91
- clean_clone_reproduced: boolean;
92
- deletion_test: "Vela replay and accepted state do not depend on this projection.";
93
- }
94
- export declare function parseRunRecord(value: unknown): RunRecord;
95
- export declare function projectRun(record: RunRecord): RunProjection;
@@ -1,173 +0,0 @@
1
- import { arrayAt, enumAt, exactKeys, gitObjectAt, integerAt, objectAt, relativePathAt, sha256At, stringAt, } from "../contracts/validation.js";
2
- export const RUN_RECORD_SCHEMA = "canopus.run.v1";
3
- export const LEGACY_RUN_RECORD_SCHEMA = "canopus.run.v0";
4
- export const RUN_PROJECTION_SCHEMA = "canopus.run-projection.v0";
5
- function literal(value, expected, at) {
6
- if (value !== expected)
7
- throw new Error(`${at} must be ${String(expected)}`);
8
- return expected;
9
- }
10
- function rootsAt(value, at) {
11
- const object = objectAt(value, at);
12
- exactKeys(object, ["git_commit", "git_tree", "vela_event_log", "vela_snapshot"], [], at);
13
- return {
14
- git_commit: gitObjectAt(object.git_commit, `${at}.git_commit`),
15
- git_tree: gitObjectAt(object.git_tree, `${at}.git_tree`),
16
- vela_event_log: sha256At(object.vela_event_log, `${at}.vela_event_log`),
17
- vela_snapshot: sha256At(object.vela_snapshot, `${at}.vela_snapshot`),
18
- };
19
- }
20
- function nullableRoute(value, at) {
21
- return value === null ? null : enumAt(value, at, ["permit", "defer"]);
22
- }
23
- function nullableCount(value, at) {
24
- return value === null ? null : integerAt(value, at, 0, Number.MAX_SAFE_INTEGER);
25
- }
26
- export function parseRunRecord(value) {
27
- const record = objectAt(value, "run");
28
- const schema = enumAt(record.schema, "run.schema", [RUN_RECORD_SCHEMA, LEGACY_RUN_RECORD_SCHEMA]);
29
- exactKeys(record, [
30
- "schema", "run_id", "status", "authority", "external_gate_credit", "mission",
31
- "candidate", "verifier", "landing", "final_roots", "reproduction", "budget",
32
- ...(schema === RUN_RECORD_SCHEMA ? ["observations"] : []),
33
- ], schema === LEGACY_RUN_RECORD_SCHEMA ? ["observations"] : [], "run");
34
- const mission = objectAt(record.mission, "run.mission");
35
- exactKeys(mission, ["id", "target", "digest", "starting_roots"], [], "run.mission");
36
- const candidate = objectAt(record.candidate, "run.candidate");
37
- exactKeys(candidate, ["digest", "status", "claim", "artifacts", "caveats"], [], "run.candidate");
38
- const verifier = objectAt(record.verifier, "run.verifier");
39
- exactKeys(verifier, ["status", "sandbox", "record"], [], "run.verifier");
40
- const testRecord = objectAt(verifier.record, "run.verifier.record");
41
- exactKeys(testRecord, ["argv", "executable_digest", "exit_code", "stdout_digest", "stderr_digest", "duration_ms"], [], "run.verifier.record");
42
- const landing = objectAt(record.landing, "run.landing");
43
- exactKeys(landing, [
44
- "operation_id", "receipt_root", "proposal_id", "route", "original_route",
45
- "accepted_event_delta", "publication_state",
46
- ], [], "run.landing");
47
- const reproduction = objectAt(record.reproduction, "run.reproduction");
48
- exactKeys(reproduction, ["matched", "roots", "verifier_status", "stdout_digest", "stderr_digest"], [], "run.reproduction");
49
- const budget = objectAt(record.budget, "run.budget");
50
- exactKeys(budget, [
51
- "research_elapsed_ms", "research_processes", "research_output_bytes", "prompt_bytes",
52
- "artifact_bytes", "attempts", "observed_tokens",
53
- ], [], "run.budget");
54
- const observations = record.observations === undefined ? undefined : (() => {
55
- const stages = objectAt(record.observations, "run.observations");
56
- exactKeys(stages, ["worker_observations", "verifier_observations", "standing_caveats"], [], "run.observations");
57
- const strings = (value, at) => arrayAt(value, at, { max: 16 }, (item, itemAt) => stringAt(item, itemAt, { min: 1, max: 4096 }));
58
- return {
59
- worker_observations: strings(stages.worker_observations, "run.observations.worker_observations"),
60
- verifier_observations: strings(stages.verifier_observations, "run.observations.verifier_observations"),
61
- standing_caveats: strings(stages.standing_caveats, "run.observations.standing_caveats"),
62
- };
63
- })();
64
- return {
65
- schema,
66
- run_id: stringAt(record.run_id, "run.run_id", { min: 5, max: 128 }),
67
- status: literal(record.status, "completed", "run.status"),
68
- authority: literal(record.authority, "non_authoritative", "run.authority"),
69
- external_gate_credit: literal(record.external_gate_credit, false, "run.external_gate_credit"),
70
- mission: {
71
- id: stringAt(mission.id, "run.mission.id", { min: 1, max: 134 }),
72
- target: stringAt(mission.target, "run.mission.target", { min: 1, max: 256 }),
73
- digest: sha256At(mission.digest, "run.mission.digest"),
74
- starting_roots: rootsAt(mission.starting_roots, "run.mission.starting_roots"),
75
- },
76
- candidate: {
77
- digest: sha256At(candidate.digest, "run.candidate.digest"),
78
- status: enumAt(candidate.status, "run.candidate.status", ["success", "null", "failed"]),
79
- claim: stringAt(candidate.claim, "run.candidate.claim", { min: 1, max: 8192 }),
80
- artifacts: arrayAt(candidate.artifacts, "run.candidate.artifacts", { max: 10 }, (item, at) => {
81
- const artifact = objectAt(item, at);
82
- exactKeys(artifact, ["path", "kind", "digest", "bytes"], [], at);
83
- return {
84
- path: relativePathAt(artifact.path, `${at}.path`),
85
- kind: stringAt(artifact.kind, `${at}.kind`, { min: 1, max: 128 }),
86
- digest: sha256At(artifact.digest, `${at}.digest`),
87
- bytes: integerAt(artifact.bytes, `${at}.bytes`, 0, 1_073_741_824),
88
- };
89
- }),
90
- caveats: arrayAt(candidate.caveats, "run.candidate.caveats", { max: 10 }, (item, at) => stringAt(item, at, { min: 1, max: 4096 })),
91
- },
92
- ...(observations === undefined ? {} : { observations }),
93
- verifier: {
94
- status: enumAt(verifier.status, "run.verifier.status", ["passed", "failed", "error"]),
95
- sandbox: enumAt(verifier.sandbox, "run.verifier.sandbox", ["macos_sandbox", "container_network_denied"]),
96
- record: {
97
- argv: arrayAt(testRecord.argv, "run.verifier.record.argv", { min: 1, max: 64 }, (item, at) => stringAt(item, at, { max: 4096 })),
98
- executable_digest: sha256At(testRecord.executable_digest, "run.verifier.record.executable_digest"),
99
- exit_code: integerAt(testRecord.exit_code, "run.verifier.record.exit_code", -1, 255),
100
- stdout_digest: sha256At(testRecord.stdout_digest, "run.verifier.record.stdout_digest"),
101
- stderr_digest: sha256At(testRecord.stderr_digest, "run.verifier.record.stderr_digest"),
102
- duration_ms: integerAt(testRecord.duration_ms, "run.verifier.record.duration_ms", 0, 3_600_000),
103
- },
104
- },
105
- landing: {
106
- operation_id: stringAt(landing.operation_id, "run.landing.operation_id", { min: 1, max: 256 }),
107
- receipt_root: sha256At(landing.receipt_root, "run.landing.receipt_root"),
108
- proposal_id: stringAt(landing.proposal_id, "run.landing.proposal_id", { min: 1, max: 256 }),
109
- route: enumAt(landing.route, "run.landing.route", ["permit", "defer", "exact_retry"]),
110
- original_route: nullableRoute(landing.original_route, "run.landing.original_route"),
111
- accepted_event_delta: nullableCount(landing.accepted_event_delta, "run.landing.accepted_event_delta"),
112
- publication_state: stringAt(landing.publication_state, "run.landing.publication_state", { min: 1, max: 64 }),
113
- },
114
- final_roots: rootsAt(record.final_roots, "run.final_roots"),
115
- reproduction: {
116
- matched: literal(reproduction.matched, true, "run.reproduction.matched"),
117
- roots: rootsAt(reproduction.roots, "run.reproduction.roots"),
118
- verifier_status: enumAt(reproduction.verifier_status, "run.reproduction.verifier_status", ["passed", "failed", "error"]),
119
- stdout_digest: sha256At(reproduction.stdout_digest, "run.reproduction.stdout_digest"),
120
- stderr_digest: sha256At(reproduction.stderr_digest, "run.reproduction.stderr_digest"),
121
- },
122
- budget: {
123
- research_elapsed_ms: integerAt(budget.research_elapsed_ms, "run.budget.research_elapsed_ms", 0, 3_600_000),
124
- research_processes: integerAt(budget.research_processes, "run.budget.research_processes", 0, 64),
125
- research_output_bytes: integerAt(budget.research_output_bytes, "run.budget.research_output_bytes", 0, 67_108_864),
126
- prompt_bytes: integerAt(budget.prompt_bytes, "run.budget.prompt_bytes", 0, 8_388_608),
127
- artifact_bytes: integerAt(budget.artifact_bytes, "run.budget.artifact_bytes", 0, 1_073_741_824),
128
- attempts: integerAt(budget.attempts, "run.budget.attempts", 0, 8),
129
- observed_tokens: integerAt(budget.observed_tokens, "run.budget.observed_tokens", 0, 1_000_000),
130
- },
131
- };
132
- }
133
- export function projectRun(record) {
134
- if ((record.landing.route === "exact_retry") !== (record.landing.original_route !== null)) {
135
- throw new Error("exact retry must name exactly one durable original route");
136
- }
137
- const effectiveRoute = record.landing.route === "exact_retry"
138
- ? record.landing.original_route
139
- : record.landing.route;
140
- if (effectiveRoute === null)
141
- throw new Error("landing has no effective route");
142
- const expectedDelta = effectiveRoute === "permit" ? 1 : 0;
143
- if (record.landing.accepted_event_delta !== null &&
144
- record.landing.accepted_event_delta !== expectedDelta) {
145
- throw new Error(`${record.landing.route} landing has invalid accepted-event delta ${String(record.landing.accepted_event_delta)}`);
146
- }
147
- const acceptedStateEffect = record.landing.route === "permit"
148
- ? "policy_admitted"
149
- : record.landing.route === "defer"
150
- ? "unchanged_pending"
151
- : "exact_retry";
152
- return {
153
- schema: RUN_PROJECTION_SCHEMA,
154
- authority: "read_only_projection",
155
- run_id: record.run_id,
156
- mission_id: record.mission.id,
157
- target: record.mission.target,
158
- starting_roots: record.mission.starting_roots,
159
- final_roots: record.final_roots,
160
- candidate_digest: record.candidate.digest,
161
- candidate_status: record.candidate.status,
162
- artifact_digests: record.candidate.artifacts.map((artifact) => artifact.digest),
163
- verifier_status: record.verifier.status,
164
- receipt_root: record.landing.receipt_root,
165
- proposal_id: record.landing.proposal_id,
166
- route: record.landing.route,
167
- original_route: record.landing.original_route,
168
- accepted_state_effect: acceptedStateEffect,
169
- publication_state: record.landing.publication_state,
170
- clean_clone_reproduced: record.reproduction.matched,
171
- deletion_test: "Vela replay and accepted state do not depend on this projection.",
172
- };
173
- }
@@ -1,168 +0,0 @@
1
- import { constants } from "node:fs";
2
- import { chmod, copyFile, mkdir } from "node:fs/promises";
3
- import path from "node:path";
4
- import { hashRegularFile, } from "../artifact/freeze.js";
5
- import { parseCandidate } from "../contracts/candidate.js";
6
- function unique(values) {
7
- return [...new Set(values)];
8
- }
9
- function finalizeWorkerCaveat(value) {
10
- if (/verif(?:y|ication|ier).*(?:pending|has not run)|pending.*verif(?:y|ication|ier)/iu.test(value)) {
11
- return "The worker handed off without verifier authority; Canopus subsequently recorded the separate verifier outcome.";
12
- }
13
- return value;
14
- }
15
- export function finalizeCandidate(options) {
16
- const draftPaths = options.engine.draft.artifacts.map((artifact) => `${artifact.path}:${artifact.kind}`).sort();
17
- const supporting = new Map((options.supportingArtifacts ?? []).map((entry) => [entry.path, entry.kind]));
18
- const frozenPaths = options.frozen
19
- .filter((entry) => !supporting.has(entry.artifact.path))
20
- .map((entry) => `${entry.artifact.path}:${entry.artifact.kind}`)
21
- .sort();
22
- if (JSON.stringify(draftPaths) !== JSON.stringify(frozenPaths)) {
23
- throw new Error("frozen artifacts do not exactly match the engine declaration");
24
- }
25
- for (const [path, kind] of supporting) {
26
- const entry = options.frozen.find((candidate) => candidate.artifact.path === path);
27
- if (entry === undefined || entry.artifact.kind !== kind) {
28
- throw new Error(`supporting artifact ${path} is absent or misclassified`);
29
- }
30
- }
31
- const verifierFailed = options.engine.draft.status === "success" && options.verifier.status !== "passed";
32
- const status = verifierFailed ? "failed" : options.engine.draft.status;
33
- const exactPositiveClaim = options.mission.schema === "canopus.mission.v1" &&
34
- options.mission.result_contract !== undefined &&
35
- options.engine.draft.status === "success" &&
36
- options.verifier.status === "passed"
37
- ? options.mission.result_contract.claim_exact
38
- : undefined;
39
- const claim = verifierFailed
40
- ? `The engine proposed a candidate, but the declared verifier did not pass: ${options.engine.draft.claim}`
41
- : exactPositiveClaim ?? options.engine.draft.claim;
42
- const caveats = unique([
43
- ...options.engine.draft.caveats.map(finalizeWorkerCaveat),
44
- `Declared verifier outcome: ${options.verifier.status}.`,
45
- "Canopus produced this record; it is not a human acceptance decision.",
46
- ]);
47
- const base = {
48
- schema: "canopus.candidate.v0",
49
- mission_id: options.mission.id,
50
- status,
51
- claim,
52
- artifacts: options.frozen.map((entry) => entry.artifact),
53
- observations: options.engine.draft.observations,
54
- tests: [options.verifier.record],
55
- costs: {
56
- wall_time_ms: options.budget.research_elapsed_ms,
57
- attempt: options.budget.attempts,
58
- input_tokens: options.engine.usage.input_tokens,
59
- output_tokens: options.engine.usage.output_tokens,
60
- },
61
- caveats,
62
- engine: options.engine.engine,
63
- };
64
- return parseCandidate(options.mission.parent_candidate === undefined
65
- ? base
66
- : {
67
- ...base,
68
- repair: {
69
- parent_candidate: options.mission.parent_candidate,
70
- reason: options.mission.repair_reason ?? "Bounded repair of the named candidate.",
71
- },
72
- });
73
- }
74
- export function mapCandidateToReceipt(mission, candidate, verifier, work) {
75
- if (candidate.mission_id !== mission.id) {
76
- throw new Error("candidate belongs to a different mission");
77
- }
78
- if (candidate.artifacts.length === 0) {
79
- throw new Error("Receipt v1 requires at least one frozen artifact");
80
- }
81
- if (candidate.status === "success" && verifier.status !== "passed") {
82
- throw new Error("a success candidate requires a passing declared verifier");
83
- }
84
- if (mission.schema === "canopus.mission.v1" && mission.result_contract !== undefined) {
85
- const contract = mission.result_contract;
86
- if (candidate.status !== contract.candidate_status ||
87
- candidate.claim !== contract.claim_exact ||
88
- verifier.status !== contract.verifier_status ||
89
- mission.target !== contract.target ||
90
- mission.claim_type !== contract.claim_type ||
91
- mission.replayability !== contract.replayability) {
92
- throw new Error("candidate does not satisfy the exact positive result contract");
93
- }
94
- const artifactKinds = new Set(candidate.artifacts.map((artifact) => artifact.kind));
95
- for (const kind of contract.required_artifact_kinds) {
96
- if (!artifactKinds.has(kind)) {
97
- throw new Error(`candidate is missing result-contract artifact kind ${kind}`);
98
- }
99
- }
100
- }
101
- const result = verifier.status === "passed"
102
- ? "The declared verifier exited zero on the frozen artifact set."
103
- : verifier.status === "failed"
104
- ? `The declared verifier returned nonzero exit ${verifier.record.exit_code}.`
105
- : `The declared verifier could not complete: ${verifier.error ?? "unspecified error"}.`;
106
- const evidence = [
107
- ...candidate.artifacts.map((artifact) => `artifact:${artifact.digest}`),
108
- `verifier_executable:${verifier.record.executable_digest}`,
109
- `verifier_stdout:${verifier.record.stdout_digest}`,
110
- `verifier_stderr:${verifier.record.stderr_digest}`,
111
- ];
112
- const counterevidence = verifier.status === "passed"
113
- ? []
114
- : [
115
- `verifier_outcome:${verifier.status}`,
116
- ];
117
- const prediction = "predicted_observable" in mission.scientific_chain
118
- ? { predictedObservable: mission.scientific_chain.predicted_observable }
119
- : { notApplicable: true };
120
- return {
121
- claim: candidate.claim,
122
- claimType: mission.claim_type,
123
- replayability: mission.replayability,
124
- artifacts: candidate.artifacts.map((artifact) => ({
125
- path: artifact.path,
126
- kind: artifact.kind,
127
- })),
128
- caveats: unique(candidate.caveats),
129
- ...prediction,
130
- performedTest: mission.scientific_chain.performed_test,
131
- result,
132
- evidence,
133
- counterevidence,
134
- ...(mission.schema === "canopus.mission.v1" && mission.execution_binding !== undefined
135
- ? { executionBinding: mission.execution_binding }
136
- : {}),
137
- ...(work === undefined ? {} : { work }),
138
- };
139
- }
140
- export async function installFrozenArtifacts(options) {
141
- const frontierRoot = path.resolve(options.landingRepo, options.frontier);
142
- const installed = [];
143
- for (const entry of options.frozen) {
144
- const target = path.resolve(frontierRoot, entry.artifact.path);
145
- const relative = path.relative(frontierRoot, target);
146
- if (relative === "" ||
147
- relative === ".." ||
148
- relative.startsWith(`..${path.sep}`) ||
149
- path.isAbsolute(relative)) {
150
- throw new Error(`artifact path escapes the landing frontier: ${entry.artifact.path}`);
151
- }
152
- await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
153
- try {
154
- await copyFile(entry.frozenPath, target, constants.COPYFILE_EXCL);
155
- }
156
- catch (error) {
157
- if (error.code !== "EEXIST")
158
- throw error;
159
- }
160
- const observed = await hashRegularFile(target, options.maxBytes);
161
- if (observed.digest !== entry.artifact.digest || observed.bytes !== entry.artifact.bytes) {
162
- throw new Error(`installed artifact ${entry.artifact.path} does not match frozen bytes`);
163
- }
164
- await chmod(target, 0o444);
165
- installed.push(target);
166
- }
167
- return installed;
168
- }
@@ -1,2 +0,0 @@
1
- import type { Mission } from "../contracts/mission.js";
2
- export declare function planRepair(mission: Mission, parentCandidate: string, reason: string, remainingAttempts: number): Mission;
@@ -1,22 +0,0 @@
1
- import { parseMission } from "../contracts/mission.js";
2
- import { sha256At, stringAt } from "../contracts/validation.js";
3
- import { contentDigest } from "../util/canonical.js";
4
- export function planRepair(mission, parentCandidate, reason, remainingAttempts) {
5
- const parent = sha256At(parentCandidate, "parent_candidate");
6
- const repairReason = stringAt(reason, "repair_reason", { min: 1, max: 4096 });
7
- if (!Number.isSafeInteger(remainingAttempts) || remainingAttempts < 1) {
8
- throw new Error("repair requires at least one remaining attempt");
9
- }
10
- const suffix = contentDigest({ mission: mission.id, parent, repairReason }).slice(7, 19);
11
- return parseMission({
12
- ...mission,
13
- id: `mission_repair_${suffix}`,
14
- objective: `Repair candidate ${parent}: ${repairReason}`.slice(0, 8192),
15
- budgets: {
16
- ...mission.budgets,
17
- max_attempts: Math.min(mission.budgets.max_attempts, remainingAttempts),
18
- },
19
- parent_candidate: parent,
20
- repair_reason: repairReason,
21
- });
22
- }
@@ -1,2 +0,0 @@
1
- import type { MissionRole } from "./contracts/mission.js";
2
- export declare function roleInstruction(role: MissionRole): string;
package/dist/src/roles.js DELETED
@@ -1,9 +0,0 @@
1
- const ROLE_INSTRUCTIONS = {
2
- producer: "Construct the smallest candidate that meets the completion condition. Preserve a null result when the evidence does not support the claim.",
3
- adversary: "Try to falsify or narrow the inherited candidate. Prefer a concrete counterexample or an explicit no-counterexample result over stylistic criticism.",
4
- verifier: "Inspect whether the candidate and declared checks correspond. You do not replace the separate frozen verifier and you do not issue an acceptance verdict.",
5
- fidelity: "Check that the claim says no more than the frozen artifacts and verifier facts support. Record mismatches as caveats or a failed candidate.",
6
- };
7
- export function roleInstruction(role) {
8
- return ROLE_INSTRUCTIONS[role];
9
- }