@quolu/lattice 0.79.5 → 0.81.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 (56) 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/bridge-config.mjs +6 -7
  6. package/src/fs-publish.mjs +9 -0
  7. package/src/mcp-startup-receipt.mjs +3 -3
  8. package/src/plan-backchain.mjs +4 -3
  9. package/src/project-cli.mjs +22 -10
  10. package/src/runtime-multi-epoch-store.mjs +53 -13
  11. package/src/runtime-os-observation.mjs +18 -1
  12. package/src/seat-identity.mjs +23 -0
  13. package/src/store-lock.mjs +250 -0
  14. package/src/todo-cli.mjs +6 -0
  15. package/src/todo-contracts.mjs +95 -50
  16. package/src/todo-migration.mjs +35 -10
  17. package/src/todo-note-store.mjs +45 -12
  18. package/src/todo-readiness.mjs +154 -0
  19. package/src/todo-revision.mjs +7 -5
  20. package/src/todo-status.mjs +4 -33
  21. package/src/todo-store-git-transaction.mjs +11 -6
  22. package/src/todo-store-view.mjs +105 -0
  23. package/src/todo-store.mjs +602 -455
  24. package/src/artifact-contracts-v2.mjs +0 -325
  25. package/src/boundary-compiler.mjs +0 -712
  26. package/src/bounded-seam.mjs +0 -230
  27. package/src/control-compiler.mjs +0 -532
  28. package/src/rc1-black-box-oracle.mjs +0 -906
  29. package/src/rc1-comparison.mjs +0 -154
  30. package/src/rc1-evidence-bundle.mjs +0 -456
  31. package/src/rc1-v4-campaign.mjs +0 -708
  32. package/src/rc1-v4-transform.mjs +0 -467
  33. package/src/rc1-v5-artifact-set.mjs +0 -855
  34. package/src/rc1-v5-behavior-evidence.mjs +0 -594
  35. package/src/rc1-v5-campaign.mjs +0 -797
  36. package/src/rc1-v5-transform.mjs +0 -421
  37. package/src/rc1-v6-artifact-set.mjs +0 -807
  38. package/src/rc1-v6-behavior-evidence.mjs +0 -273
  39. package/src/rc1-v6-campaign.mjs +0 -623
  40. package/src/rc1-v6-causal-binding.mjs +0 -473
  41. package/src/rc1-v6-measurement.mjs +0 -313
  42. package/src/rc2-artifact-set.mjs +0 -1584
  43. package/src/rc2-campaign.mjs +0 -1495
  44. package/src/rc2-delivery-policy-front-end.mjs +0 -1079
  45. package/src/rc2-delivery-policy-oracle.mjs +0 -134
  46. package/src/rc2-delivery-policy-transform.mjs +0 -1127
  47. package/src/rc2-rc1-transfer-front-end.mjs +0 -511
  48. package/src/rc3-actual-dogfood.mjs +0 -652
  49. package/src/rc3-dogfood-scaffold.mjs +0 -315
  50. package/src/rc3-scripted-campaign.mjs +0 -1383
  51. package/src/rc4-stage1-dogfood.mjs +0 -673
  52. package/src/runtime-scripted-executor.mjs +0 -163
  53. package/src/runtime-worktree-executor.mjs +0 -199
  54. package/src/seam-transform.mjs +0 -554
  55. package/src/treatment-compiler.mjs +0 -728
  56. 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
- }