@quolu/lattice 0.79.5 → 0.80.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 (51) hide show
  1. package/docs/schemas/lattice.plan_create_input.v4.schema.json +8 -4
  2. package/docs/schemas/lattice.todo_extraction.v3.schema.json +5 -3
  3. package/docs/schemas/lattice.todo_extraction.v4.schema.json +5 -3
  4. package/package.json +1 -1
  5. package/src/fs-publish.mjs +9 -0
  6. package/src/mcp-startup-receipt.mjs +3 -3
  7. package/src/project-cli.mjs +2 -2
  8. package/src/runtime-os-observation.mjs +18 -1
  9. package/src/store-lock.mjs +250 -0
  10. package/src/todo-cli.mjs +6 -0
  11. package/src/todo-contracts.mjs +95 -50
  12. package/src/todo-migration.mjs +35 -10
  13. package/src/todo-note-store.mjs +45 -12
  14. package/src/todo-readiness.mjs +154 -0
  15. package/src/todo-status.mjs +4 -33
  16. package/src/todo-store-git-transaction.mjs +11 -6
  17. package/src/todo-store-view.mjs +47 -0
  18. package/src/todo-store.mjs +597 -398
  19. package/src/artifact-contracts-v2.mjs +0 -325
  20. package/src/boundary-compiler.mjs +0 -712
  21. package/src/bounded-seam.mjs +0 -230
  22. package/src/control-compiler.mjs +0 -532
  23. package/src/rc1-black-box-oracle.mjs +0 -906
  24. package/src/rc1-comparison.mjs +0 -154
  25. package/src/rc1-evidence-bundle.mjs +0 -456
  26. package/src/rc1-v4-campaign.mjs +0 -708
  27. package/src/rc1-v4-transform.mjs +0 -467
  28. package/src/rc1-v5-artifact-set.mjs +0 -855
  29. package/src/rc1-v5-behavior-evidence.mjs +0 -594
  30. package/src/rc1-v5-campaign.mjs +0 -797
  31. package/src/rc1-v5-transform.mjs +0 -421
  32. package/src/rc1-v6-artifact-set.mjs +0 -807
  33. package/src/rc1-v6-behavior-evidence.mjs +0 -273
  34. package/src/rc1-v6-campaign.mjs +0 -623
  35. package/src/rc1-v6-causal-binding.mjs +0 -473
  36. package/src/rc1-v6-measurement.mjs +0 -313
  37. package/src/rc2-artifact-set.mjs +0 -1584
  38. package/src/rc2-campaign.mjs +0 -1495
  39. package/src/rc2-delivery-policy-front-end.mjs +0 -1079
  40. package/src/rc2-delivery-policy-oracle.mjs +0 -134
  41. package/src/rc2-delivery-policy-transform.mjs +0 -1127
  42. package/src/rc2-rc1-transfer-front-end.mjs +0 -511
  43. package/src/rc3-actual-dogfood.mjs +0 -652
  44. package/src/rc3-dogfood-scaffold.mjs +0 -315
  45. package/src/rc3-scripted-campaign.mjs +0 -1383
  46. package/src/rc4-stage1-dogfood.mjs +0 -673
  47. package/src/runtime-scripted-executor.mjs +0 -163
  48. package/src/runtime-worktree-executor.mjs +0 -199
  49. package/src/seam-transform.mjs +0 -554
  50. package/src/treatment-compiler.mjs +0 -728
  51. package/src/treatment-runner.mjs +0 -656
@@ -1,134 +0,0 @@
1
- import { execFile } from 'node:child_process';
2
- import { createHash } from 'node:crypto';
3
- import { realpath } from 'node:fs/promises';
4
- import path from 'node:path';
5
- import { promisify } from 'node:util';
6
-
7
- const execFileAsync = promisify(execFile);
8
- const ENTRYPOINT = 'research/fixtures/delivery-policy-registry/src/delivery-policy-registry.mjs';
9
-
10
- const CASES = Object.freeze([
11
- ['email-routine', { channel: 'email', urgency: 'routine' }, { channel: 'email', transport: 'smtp', retry_limit: 3, delay_seconds: 60 }],
12
- ['email-urgent', { channel: 'email', urgency: 'urgent' }, { channel: 'email', transport: 'smtp', retry_limit: 5, delay_seconds: 0 }],
13
- ['sms-routine', { channel: 'sms', urgency: 'routine' }, { channel: 'sms', transport: 'sms', retry_limit: 2, delay_seconds: 30 }],
14
- ['sms-urgent', { channel: 'sms', urgency: 'urgent' }, { channel: 'sms', transport: 'sms', retry_limit: 4, delay_seconds: 0 }],
15
- ['push-routine', { channel: 'push', urgency: 'routine' }, { channel: 'push', transport: 'push', retry_limit: 1, delay_seconds: 10 }],
16
- ['push-urgent', { channel: 'push', urgency: 'urgent' }, { channel: 'push', transport: 'push', retry_limit: 3, delay_seconds: 0 }],
17
- ]);
18
-
19
- const CHILD_PROGRAM = String.raw`
20
- import { createHash } from 'node:crypto';
21
- import { pathToFileURL } from 'node:url';
22
- const [entrypoint, serializedCases] = process.argv.slice(1);
23
- const cases = JSON.parse(serializedCases);
24
- const targetModule = await import(pathToFileURL(entrypoint).href);
25
- if (typeof targetModule.resolveDeliveryPolicy !== 'function') {
26
- throw new TypeError('resolveDeliveryPolicy export is not a function');
27
- }
28
- const case_results = cases.map(({ id, input }) => ({
29
- id,
30
- output_digest: createHash('sha256')
31
- .update(JSON.stringify(targetModule.resolveDeliveryPolicy(input)))
32
- .digest('hex'),
33
- }));
34
- process.stdout.write(JSON.stringify({ case_results }) + '\n');
35
- `;
36
-
37
- function sha256(value) {
38
- return createHash('sha256').update(value).digest('hex');
39
- }
40
-
41
- function inside(root, target) {
42
- const relative = path.relative(root, target);
43
- return relative !== ''
44
- && relative !== '..'
45
- && !relative.startsWith(`..${path.sep}`)
46
- && !path.isAbsolute(relative);
47
- }
48
-
49
- function exactRecord(value, keys) {
50
- if (value === null || typeof value !== 'object' || Array.isArray(value)
51
- || Object.getPrototypeOf(value) !== Object.prototype) return false;
52
- const actual = Object.keys(value).sort();
53
- const expected = [...keys].sort();
54
- return actual.length === expected.length
55
- && actual.every((key, index) => key === expected[index]);
56
- }
57
-
58
- function expectedDigest(value) {
59
- return sha256(JSON.stringify(value));
60
- }
61
-
62
- /** runtime oracleとartifact verifierが共有する唯一のexpected receiptを返す。 */
63
- export function expectedRc2DeliveryPolicyOracleReceipt() {
64
- return {
65
- schema: 'lattice.rc2.delivery_policy_oracle_receipt.v1',
66
- outcome: 'passed',
67
- case_results: CASES.map(([id, _input, expected]) => ({
68
- id,
69
- outcome: 'passed',
70
- output_digest: expectedDigest(expected),
71
- })),
72
- };
73
- }
74
-
75
- async function resolveEntrypoint(repoRoot) {
76
- if (typeof repoRoot !== 'string' || repoRoot.length === 0) {
77
- throw new TypeError('repoRoot must be a non-empty path');
78
- }
79
- const root = await realpath(repoRoot);
80
- const entrypoint = await realpath(path.resolve(root, ENTRYPOINT));
81
- if (!inside(root, entrypoint)) throw new TypeError('delivery policy entrypoint is outside repoRoot');
82
- return entrypoint;
83
- }
84
-
85
- function parseChildReceipt(stdout) {
86
- let value;
87
- try {
88
- value = JSON.parse(stdout);
89
- } catch {
90
- throw new TypeError('delivery policy oracle child returned invalid JSON');
91
- }
92
- if (!exactRecord(value, ['case_results'])
93
- || !Array.isArray(value.case_results)
94
- || value.case_results.length !== CASES.length) {
95
- throw new TypeError('delivery policy oracle child receipt shape is invalid');
96
- }
97
- return value.case_results;
98
- }
99
-
100
- /** 指定worktreeのfixtureをfresh Node processでblack-box照合する。 */
101
- export async function runRc2DeliveryPolicyOracle({ repoRoot } = {}) {
102
- const entrypoint = await resolveEntrypoint(repoRoot);
103
- const childCases = CASES.map(([id, input]) => ({ id, input }));
104
- const expectedReceipt = expectedRc2DeliveryPolicyOracleReceipt();
105
- let stdout;
106
- let stderr;
107
- try {
108
- ({ stdout, stderr } = await execFileAsync(process.execPath, [
109
- '--input-type=module',
110
- '--eval',
111
- CHILD_PROGRAM,
112
- entrypoint,
113
- JSON.stringify(childCases),
114
- ], { encoding: 'utf8', maxBuffer: 64 * 1024 }));
115
- } catch (error) {
116
- throw new Error(`delivery policy oracle child failed: ${error.message}`, { cause: error });
117
- }
118
- if (stderr.length !== 0) throw new Error('delivery policy oracle child wrote stderr');
119
-
120
- const childResults = parseChildReceipt(stdout);
121
- childResults.forEach((result, index) => {
122
- const expected = expectedReceipt.case_results[index];
123
- if (!exactRecord(result, ['id', 'output_digest'])
124
- || result.id !== expected.id
125
- || typeof result.output_digest !== 'string'
126
- || !/^[0-9a-f]{64}$/.test(result.output_digest)) {
127
- throw new TypeError('delivery policy oracle child case receipt is invalid');
128
- }
129
- if (result.output_digest !== expected.output_digest) {
130
- throw new Error(`delivery policy behavior mismatch: ${expected.id}`);
131
- }
132
- });
133
- return expectedReceipt;
134
- }