@quolu/lattice 0.110.2 → 0.111.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.
@@ -76,7 +76,8 @@
76
76
  "required": ["within", "symbols"],
77
77
  "properties": {
78
78
  "within": { "$ref": "#/$defs/repoRelativePath" },
79
- "symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" } }
79
+ "symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" } },
80
+ "new_symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" }, "description": "Optional (ADR 0204 §7). The names of `symbols` that did not resolve when the ToDo declared them: functions that do not exist yet. With no range such a name overlaps only a whole-file claim on the path and the same name. Strictly sorted and unique, a subset of symbols." }
80
81
  }
81
82
  }
82
83
  },
@@ -88,7 +89,8 @@
88
89
  "required": ["within", "symbols"],
89
90
  "properties": {
90
91
  "within": { "$ref": "#/$defs/repoRelativePath" },
91
- "symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" } }
92
+ "symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" } },
93
+ "new_symbols": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/identifier" }, "description": "Optional (ADR 0204 §7). The names of `symbols` that did not resolve when the ToDo declared them: functions that do not exist yet. With no range such a name overlaps only a whole-file claim on the path and the same name. Strictly sorted and unique, a subset of symbols." }
92
94
  }
93
95
  }
94
96
  }
@@ -390,6 +390,17 @@
390
390
  "minLength": 1,
391
391
  "maxLength": 1024
392
392
  }
393
+ },
394
+ "new_symbols": {
395
+ "type": "array",
396
+ "minItems": 1,
397
+ "maxItems": 256,
398
+ "description": "Optional (ADR 0204 §7). The names of `symbols` that did not resolve when the ToDo declared them: functions that do not exist yet. With no range such a name overlaps only a whole-file claim on the path and the same name. Strictly sorted and unique, a subset of symbols.",
399
+ "items": {
400
+ "type": "string",
401
+ "minLength": 1,
402
+ "maxLength": 1024
403
+ }
393
404
  }
394
405
  }
395
406
  }
@@ -424,6 +424,17 @@
424
424
  "minLength": 1,
425
425
  "maxLength": 1024
426
426
  }
427
+ },
428
+ "new_symbols": {
429
+ "type": "array",
430
+ "minItems": 1,
431
+ "maxItems": 256,
432
+ "description": "Optional (ADR 0204 §7). The names of `symbols` that did not resolve when the ToDo declared them: functions that do not exist yet. With no range such a name overlaps only a whole-file claim on the path and the same name. Strictly sorted and unique, a subset of symbols.",
433
+ "items": {
434
+ "type": "string",
435
+ "minLength": 1,
436
+ "maxLength": 1024
437
+ }
427
438
  }
428
439
  }
429
440
  }
@@ -472,6 +483,17 @@
472
483
  "minLength": 1,
473
484
  "maxLength": 1024
474
485
  }
486
+ },
487
+ "new_symbols": {
488
+ "type": "array",
489
+ "minItems": 1,
490
+ "maxItems": 256,
491
+ "description": "Optional (ADR 0204 §7). The names of `symbols` that did not resolve when the ToDo declared them: functions that do not exist yet. With no range such a name overlaps only a whole-file claim on the path and the same name. Strictly sorted and unique, a subset of symbols.",
492
+ "items": {
493
+ "type": "string",
494
+ "minLength": 1,
495
+ "maxLength": 1024
496
+ }
475
497
  }
476
498
  }
477
499
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.110.2",
3
+ "version": "0.111.0",
4
4
  "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
5
  "author": {
6
6
  "name": "Quo / クオ at kitepon.dev",
@@ -1674,16 +1674,18 @@ function main() {
1674
1674
  const request = JSON.parse(Buffer.concat(chunks).toString('utf8'));
1675
1675
  const anchors = request.anchors ?? [];
1676
1676
  const names = request.names ?? [];
1677
+ const files = request.files ?? [];
1677
1678
  if (!Array.isArray(anchors) || !anchors.every((a) => a && typeof a.path === 'string' && typeof a.symbol === 'string')
1678
- || !Array.isArray(names) || !names.every((n) => typeof n === 'string')) {
1679
- error('resolve expects {"anchors"?:[{"path":string,"symbol":string}],"names"?:string[],"related"?:boolean} on stdin');
1679
+ || !Array.isArray(names) || !names.every((n) => typeof n === 'string')
1680
+ || !Array.isArray(files) || !files.every((f) => typeof f === 'string')) {
1681
+ error('resolve expects {"anchors"?:[{"path":string,"symbol":string}],"names"?:string[],"files"?:string[],"related"?:boolean} on stdin');
1680
1682
  process.exit(2);
1681
1683
  }
1682
1684
  const { default: LatticeSensor } = await loadLatticeSensor();
1683
1685
  const cg = await LatticeSensor.open(projectPath);
1684
- const { resolveAnchors, lookupNames } = await Promise.resolve().then(() => __importStar(require('../graph/anchor-resolve')));
1686
+ const { resolveAnchors, lookupNames, countFunctions } = await Promise.resolve().then(() => __importStar(require('../graph/anchor-resolve')));
1685
1687
  const result = resolveAnchors(cg, anchors, { related: request.related === true });
1686
- console.log(JSON.stringify({ schema: 'lattice.sensor_resolve.v1', ...result, named: lookupNames(cg, names) }));
1688
+ console.log(JSON.stringify({ schema: 'lattice.sensor_resolve.v1', ...result, named: lookupNames(cg, names), files: countFunctions(cg, files) }));
1687
1689
  cg.destroy();
1688
1690
  }
1689
1691
  catch (err) {
@@ -72,6 +72,14 @@ export declare function resolveAnchors(host: AnchorResolveHost, anchors: Array<{
72
72
  }>, options?: {
73
73
  related?: boolean;
74
74
  }): AnchorResolution;
75
+ /**
76
+ * How many functions a whole-file claim makes conflicting (ADR 0204 §7.3). A file with none, a path that is not indexed or
77
+ * not a repo-relative path answers 0; there is no refusal.
78
+ */
79
+ export declare function countFunctions(host: AnchorResolveHost, paths: string[]): Array<{
80
+ path: string;
81
+ functions: number;
82
+ }>;
75
83
  export interface NamedDefinitions {
76
84
  name: string;
77
85
  /** Exact-name definitions across the project (at most {@link NAME_DEFINITION_LIMIT}); empty when none or too common. */
@@ -1 +1 @@
1
- {"version":3,"file":"anchor-resolve.d.ts","sourceRoot":"","sources":["../../src/graph/anchor-resolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,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HAAwH;IACxH,WAAW,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvG,4GAA4G;IAC5G,SAAS,EAAE,OAAO,CAAC;CACpB;AAID,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAYxF"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.resolveAnchors = resolveAnchors;
11
+ exports.countFunctions = countFunctions;
11
12
  exports.lookupNames = lookupNames;
12
13
  /** Kinds that are not a unit of change inside a file. */
13
14
  const NOT_A_SYMBOL = new Set(['file', 'import', 'export', 'parameter']);
@@ -114,6 +115,19 @@ function resolveAnchors(host, anchors, options = {}) {
114
115
  }
115
116
  return out;
116
117
  }
118
+ /** Function-like definitions: functions, methods (constructors are methods). Types, fields and variables are not. */
119
+ const FUNCTION_LIKE = new Set(['function', 'method']);
120
+ /**
121
+ * How many functions a whole-file claim makes conflicting (ADR 0204 §7.3). A file with none, a path that is not indexed or
122
+ * not a repo-relative path answers 0; there is no refusal.
123
+ */
124
+ function countFunctions(host, paths) {
125
+ return paths.map((written) => {
126
+ const path = written.replace(/^\.\//, '');
127
+ const valid = path !== '' && !path.startsWith('/') && !path.split('/').includes('..');
128
+ return { path: written, functions: valid ? host.getNodesInFile(path).filter((node) => FUNCTION_LIKE.has(node.kind)).length : 0 };
129
+ });
130
+ }
117
131
  const NAME_DEFINITION_LIMIT = 5;
118
132
  /** Seed fallback (2b): which graph symbols does a bare identifier name? Exact name only, never fuzzy. */
119
133
  function lookupNames(host, names) {
@@ -1 +1 @@
1
- {"version":3,"file":"anchor-resolve.js","sourceRoot":"","s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L,CAAC;AAUD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,yGAAyG;AACzG,SAAgB,WAAW,CAAC,IAAuB,EAAE,KAAe;IAClE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvF,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,qBAAqB,CAAC;QACvD,OAAO;YACL,IAAI;YACJ,SAAS;YACT,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjD,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO;aAC9G,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -77,12 +77,13 @@ const snake = ({ startLine, endLine, qualified, ...rest }) => ({ ...rest, qualif
77
77
  /**
78
78
  * Resolve `{path, symbol}[]` against the maintained index of `root`.
79
79
  * → `{resolved: [{path, symbol, qualified, kind, start_line, end_line, related?}], unresolved: [{path, symbol, reason, nearest[], elsewhere[]}],
80
- * ambiguous: [{path, symbol, names[]}]}`
80
+ * ambiguous: [{path, symbol, names[]}], files: [{path, functions}]}`
81
81
  * Exact match only. A symbol with several definitions in its file (overloads, same name in two classes) returns every span, and
82
82
  * `ambiguous` names the case when they are different definitions. `unresolved` is an answer, not an error.
83
+ * `files` (ADR 0204 §7.3): paths written without `#`; `functions` = function-like definitions in that file, 0 when none or not indexed.
83
84
  */
84
- export async function resolveAnchors({ root, anchors, related = false }) {
85
- const result = await runSensorJson({ command: 'resolve', root, request: { anchors, related } });
85
+ export async function resolveAnchors({ root, anchors, related = false, files = [] }) {
86
+ const result = await runSensorJson({ command: 'resolve', root, request: { anchors, related, files } });
86
87
  const moveRelated = (node) => (node.related === undefined ? node : {
87
88
  ...node,
88
89
  related: Object.fromEntries(Object.entries(node.related).map(([key, value]) => [key,
@@ -94,6 +95,7 @@ export async function resolveAnchors({ root, anchors, related = false }) {
94
95
  ...anchor, nearest: anchor.nearest.map(snake), elsewhere: anchor.elsewhere.map(snake),
95
96
  })),
96
97
  ambiguous: result.ambiguous,
98
+ files: result.files,
97
99
  };
98
100
  }
99
101
 
package/src/todo-cli.mjs CHANGED
@@ -1428,7 +1428,8 @@ async function holdForSplit({ repoRoot, env, member, planKey, taskId, read, over
1428
1428
  /** What the function-split commands need from this module: retire a task, and declare a row again (resolved at HEAD). */
1429
1429
  const splitDeps = (repoRoot, planKey) => ({
1430
1430
  retire: (options) => retireTask(options),
1431
- declareRow: ({ taskId, flags }) => declareTaskRow({ repoRoot, planKey, taskId, flags, observable: headResolves(repoRoot) }),
1431
+ // strict: the cut must be on HEAD (ADR 0205 §5); the new-name rule (ADR 0204 §7) is for a member's own declare/add.
1432
+ declareRow: ({ taskId, flags }) => declareTaskRow({ repoRoot, planKey, taskId, flags, observable: headResolves(repoRoot), strict: true }),
1432
1433
  });
1433
1434
 
1434
1435
  /** ADR 0205 §3: starting the split task S shows the worker its members, the size of the cut and what to do (no member rule exists). */
@@ -1488,7 +1489,8 @@ function headResolves(repoRoot) {
1488
1489
  }
1489
1490
 
1490
1491
  const declareCommand = (planKey, taskId) => `lattice todo independence witness declare --plan ${planKey} --task ${taskId}`
1491
- + ' --owns <path>[,<path>...] [--reads <path>,...] [--writes <path>,...]';
1492
+ + ' --owns <path>#<function>[,...] [--reads <path>#<function>,...] [--writes <path>,...]'
1493
+ + ' (a path alone only for a file with no functions or a new file)';
1492
1494
 
1493
1495
  /**
1494
1496
  * g3: a task in a lane the host marked `no_code_lanes` (`chart set --no-code-lane`) touches no code, so gates 1–3 do not apply:
@@ -1509,7 +1511,7 @@ function enforcedStartGate({ advisory, planKey, taskId, overrideReason }) {
1509
1511
  throw new TodoStoreError('TODO_TRANSITION_REFUSED', reason, undefined, { plan_key: planKey, task_id: taskId, ...detail });
1510
1512
  };
1511
1513
  if (advisory.coverage === 'missing' || unknown('witness_missing')) {
1512
- refuse('enforced_witness_undeclared', { next_action: `Declare the files ${taskId} touches, then start again: \`${declareCommand(planKey, taskId)}\`.` });
1514
+ refuse('enforced_witness_undeclared', { next_action: `Declare the functions ${taskId} touches, then start again: \`${declareCommand(planKey, taskId)}\`.` });
1513
1515
  }
1514
1516
  if (advisory.drift_intersecting === true || unknown('record_stale')) {
1515
1517
  refuse('enforced_witness_stale', { next_action: `Main changed under ${taskId}'s declared files since the check: declare them again (it recompiles), then start: \`${declareCommand(planKey, taskId)}\`.` });
@@ -4159,18 +4161,20 @@ function declarationNextAction(planKey, taskId, declaration) {
4159
4161
  * Resolve and the fresh observation run before the Store lock; if another declaration changed the set meanwhile (a row or
4160
4162
  * path this attempt did not resolve or observe), the call writes nothing and the attempt runs again (three at most).
4161
4163
  */
4162
- async function declareTaskRow({ repoRoot, planKey, taskId, flags, observable }) {
4164
+ async function declareTaskRow({ repoRoot, planKey, taskId, flags, observable, strict = false }) {
4163
4165
  const store = await readTodoStore({ repoRoot });
4164
4166
  const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
4165
4167
  if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
4166
4168
  const writer = createTodoStoreWriter({ caller: 'todo-relations' });
4167
4169
  const mine = declaredPaths(flags);
4170
+ const task = member.plan.tasks.find(({ task_id: id }) => id === taskId);
4168
4171
  const headSha = observable ? currentHeadSha(repoRoot) : null;
4169
4172
  const peek = await readTodoWitnessSet({ repoRoot, planKey }).catch(() => null);
4170
4173
  let alsoResolve = neededAnchors(peek?.plan_key === planKey ? peek.manual_witness : {}, taskId, mine);
4171
4174
  for (let attempt = 0; attempt < 3; attempt += 1) {
4172
4175
  const { row, declaration, ranges } = await buildDeclarationRow({
4173
- root: repoRoot, observable, owns: flags.owns, reads: flags.reads, writes: flags.writes, alsoResolve });
4176
+ root: repoRoot, observable, owns: flags.owns, reads: flags.reads, writes: flags.writes, alsoResolve, strict,
4177
+ text: { title: task?.title, memo: typeof task?.design_memo === 'string' ? task.design_memo : undefined } });
4174
4178
  if (row === null) return { declaration, scaffolded: null };
4175
4179
  const resolved = new Set([...alsoResolve, ...declaration.resolved].map(({ path: where, symbol }) => `${where}\0${symbol}`));
4176
4180
  const draftFor = (witnessSet, unfinishedTaskIds) => {
@@ -946,11 +946,12 @@ const relationText = (field) => typeof field === 'string' && field.length > 0 &&
946
946
  const relationSha = (field) => field === null || relationText(field);
947
947
  const lineNumber = (field) => Number.isSafeInteger(field) && field >= 1;
948
948
 
949
- /** One side of an overlap. A whole-file claim has no symbol and no range (both null). */
949
+ /** One side of an overlap. A whole-file claim has no symbol and no range (all null); a function that does not exist yet (ADR 0204 §7) has its name and no range. */
950
950
  function relationEntry(entry) {
951
951
  return exactRecord(entry, ['symbol', 'start_line', 'end_line', 'access'])
952
952
  && ['read', 'write'].includes(entry.access)
953
953
  && ((entry.symbol === null && entry.start_line === null && entry.end_line === null)
954
+ || (relationText(entry.symbol) && entry.start_line === null && entry.end_line === null)
954
955
  || (relationText(entry.symbol) && lineNumber(entry.start_line) && lineNumber(entry.end_line)
955
956
  && entry.end_line >= entry.start_line));
956
957
  }
@@ -37,20 +37,56 @@ export function parseDeclarationList(value) {
37
37
  return { paths, anchors, malformed };
38
38
  }
39
39
 
40
- const byWithin = (anchors) => {
40
+ /** `{within, symbols[, new_symbols]}` per path; `isNew(anchor)` marks the names that did not resolve when declared (ADR 0204 §7). */
41
+ const byWithin = (anchors, isNew = () => false) => {
41
42
  const grouped = new Map();
42
- for (const { path: within, symbol } of anchors) grouped.set(within, [...(grouped.get(within) ?? []), symbol]);
43
- return [...grouped].map(([within, symbols]) => ({ within, symbols: sortedUnique(symbols) }));
43
+ for (const anchor of anchors) grouped.set(anchor.path, [...(grouped.get(anchor.path) ?? []), anchor]);
44
+ return [...grouped].map(([within, list]) => {
45
+ const fresh = sortedUnique(list.filter(isNew).map(({ symbol }) => symbol));
46
+ return { within, symbols: sortedUnique(list.map(({ symbol }) => symbol)), ...(fresh.length > 0 ? { new_symbols: fresh } : {}) };
47
+ });
44
48
  };
45
49
 
46
- async function resolveOnce(root, anchors) {
47
- try { return await resolveAnchors({ root, anchors }); } catch (error) {
50
+ async function resolveOnce(root, anchors, files = []) {
51
+ try { return await resolveAnchors({ root, anchors, files }); } catch (error) {
48
52
  if (!(error instanceof SensorResolveError) || error.code !== 'RESOLVE_INDEX_MISSING') throw error;
49
53
  }
50
54
  // First use only: the maintained index does not exist yet (Observe builds it; later calls reuse it).
51
55
  const sink = { write() {} };
52
56
  await runSensorCli({ argv: ['init', root, '--json'], stdout: sink, stderr: sink });
53
- return resolveAnchors({ root, anchors });
57
+ return resolveAnchors({ root, anchors, files });
58
+ }
59
+
60
+ /**
61
+ * The paths a declaration claims whole: owned, written or read without `#`, and not narrowed to functions by an anchor of the
62
+ * same access (a path with anchors claims only those). `[{path, access}]`, `write` when the path is claimed both ways.
63
+ */
64
+ function wholeFileClaims({ own, read, writes }) {
65
+ const anchored = (list) => new Set(list.map(({ path: where }) => where));
66
+ const written = anchored(own.anchors);
67
+ const readOnly = anchored(read.anchors);
68
+ const claims = new Map();
69
+ for (const where of [...own.paths, ...items(writes)]) if (!written.has(where)) claims.set(where, 'write');
70
+ for (const where of read.paths) if (!readOnly.has(where) && !claims.has(where)) claims.set(where, 'read');
71
+ return [...claims].map(([where, access]) => ({ path: where, access })).sort((left, right) => (left.path < right.path ? -1 : 1));
72
+ }
73
+
74
+ /**
75
+ * ADR 0204 §7.3, information only: for each whole-file claim on a file with functions, how many functions it makes conflicting
76
+ * and which functions the title / design memo name in that file. Never a refusal or a question; no functions = no entry.
77
+ */
78
+ async function wholeFiles({ root, observable, bare, files, text }) {
79
+ const counts = new Map(files.map(({ path: where, functions }) => [where, functions]));
80
+ const found = bare.filter(({ path: where }) => counts.get(where) > 0);
81
+ if (found.length === 0) return [];
82
+ const proposed = await proposeFromText({ root, observable, title: text.title, memo: text.memo });
83
+ return found.map(({ path: where, access }) => {
84
+ const candidates = sortedUnique((proposed?.proposed ?? []).flatMap(({ definitions }) => definitions)
85
+ .filter(({ path: definedIn }) => definedIn === where).map(({ symbol }) => symbol));
86
+ const functions = counts.get(where);
87
+ return { path: where, access, functions, candidates,
88
+ text: `${where}: whole file, its ${functions} functions all conflict; by function: --owns ${where}#${candidates[0] ?? '<function>'}` };
89
+ });
54
90
  }
55
91
 
56
92
  const unresolvedEntry = (anchor, reason, nearest = [], elsewhere = []) => ({
@@ -58,54 +94,73 @@ const unresolvedEntry = (anchor, reason, nearest = [], elsewhere = []) => ({
58
94
  });
59
95
 
60
96
  /**
61
- * Resolve a task's declared functions and build its witness-draft row.
62
- * → `{row, declaration: {written, resolved[], unresolved[], malformed[]}}`; `row` is null when `written` is false
63
- * (a task's row is not written until every name resolves, so the next declare retries from scratch).
64
- * `observable` false = the Store root has no code tree: functions cannot be checked, never recorded as a guess.
97
+ * Resolve a task's declared functions and build its witness-draft row (ADR 0204 §7).
98
+ * → `{row, declaration: {written, resolved[], new_names[], unresolved[], malformed[]}}`. A name that does not resolve is kept
99
+ * in the row as a new name (`new_symbols` of its anchor) and listed in `new_names` with the nearest names, so a typo is seen
100
+ * at once; `row` is null (`written` false) only for a malformed entry (`malformed`, or `unresolved` for a path or symbol Resolve
101
+ * cannot read at all). No code tree or no Resolve answer writes the row with every name as new: that give-up protected nothing.
102
+ * `strict` (the `todo done S` rewrite, ADR 0205 §5) keeps the old reading: a name that is not on HEAD is `unresolved` and the row is not
103
+ * written, because the cut it names must have landed. The new-name rule is for a member's own declare/add.
65
104
  */
66
- export async function buildDeclarationRow({ root, observable, owns, reads, writes, alsoResolve = [] }) {
105
+ export async function buildDeclarationRow({ root, observable, owns, reads, writes, alsoResolve = [], text = {}, strict = false }) {
67
106
  const own = parseDeclarationList(owns);
68
107
  const read = parseDeclarationList(reads);
69
108
  const malformed = [...own.malformed, ...read.malformed];
70
109
  const keyOf = (anchor) => `${anchor.path}\0${anchor.symbol}`;
71
110
  const wanted = [...new Map([...own.anchors, ...read.anchors].map((anchor) => [keyOf(anchor), anchor])).values()];
72
- const declaration = { written: false, resolved: [], unresolved: [], malformed };
111
+ const declaration = { written: false, resolved: [], new_names: [], whole_files: [], unresolved: [], malformed };
73
112
  if (malformed.length > 0) return { row: null, declaration };
74
- // `alsoResolve`: other tasks' anchors, answered by the same Resolve call (a5 compares ranges); a miss there is not this task's refusal.
113
+ // `alsoResolve`: other tasks' anchors, answered by the same Resolve call (a5 compares ranges); a miss there is not this task's.
75
114
  const wantedKeys = new Set(wanted.map(keyOf));
76
115
  const extra = [...new Map(alsoResolve.filter((anchor) => !wantedKeys.has(keyOf(anchor))).map((anchor) => [keyOf(anchor), anchor])).values()];
77
116
  let ranges = [];
78
- if (wanted.length > 0 && !observable) {
79
- declaration.unresolved = wanted.map((anchor) => unresolvedEntry(anchor, 'no_code_tree'));
80
- return { row: null, declaration };
81
- }
82
- if (wanted.length + extra.length > 0 && observable) {
117
+ const everyNew = (reason) => {
118
+ if (strict) {
119
+ declaration.unresolved = wanted.map((anchor) => unresolvedEntry(anchor, reason));
120
+ return { row: null, declaration };
121
+ }
122
+ declaration.new_names = wanted.map((anchor) => ({ path: anchor.path, symbol: anchor.symbol, nearest: [], elsewhere: [] }));
123
+ return buildRow({ own, read, writes, declaration, ranges, isNew: () => true });
124
+ };
125
+ if (wanted.length > 0 && !observable) return everyNew('no_code_tree');
126
+ let newKeys = new Set();
127
+ // ADR 0204 §7.3: a path declared without `#` that holds functions is asked in the same Resolve call (`files`).
128
+ const bare = wholeFileClaims({ own, read, writes });
129
+ if (wanted.length + extra.length + bare.length > 0 && observable) {
83
130
  let answer;
84
- try { answer = await resolveOnce(root, [...wanted, ...extra]); } catch (error) {
131
+ try { answer = await resolveOnce(root, [...wanted, ...extra], bare.map(({ path: where }) => where)); } catch (error) {
85
132
  if (wanted.length === 0) return buildRow({ own, read, writes, declaration, ranges });
86
- declaration.unresolved = wanted.map((anchor) => unresolvedEntry(anchor, 'resolve_unavailable'));
87
133
  declaration.resolve_error = error?.code ?? error?.message ?? 'resolve_failed';
88
- return { row: null, declaration };
134
+ return everyNew('resolve_unavailable');
89
135
  }
90
136
  const mine = answer.unresolved.filter((anchor) => wantedKeys.has(keyOf(anchor)));
91
- declaration.unresolved = mine.map((anchor) => unresolvedEntry(
137
+ const entry = (anchor) => unresolvedEntry(
92
138
  anchor, anchor.reason,
93
139
  anchor.nearest.map(({ qualified }) => qualified),
94
140
  anchor.elsewhere.map(({ path: where, qualified }) => `${where}#${qualified}`),
95
- ));
141
+ );
142
+ // path_invalid / symbol_empty cannot be stored at all; every other miss is a name that does not exist yet.
143
+ const unreadable = mine.filter(({ reason }) => strict || reason === 'path_invalid' || reason === 'symbol_empty');
144
+ declaration.unresolved = unreadable.map(entry);
145
+ declaration.new_names = mine.filter((anchor) => !unreadable.includes(anchor)).map((anchor) => {
146
+ const { path: where, symbol, nearest, elsewhere } = entry(anchor);
147
+ return { path: where, symbol, nearest, elsewhere };
148
+ });
149
+ newKeys = new Set(declaration.new_names.map(keyOf));
96
150
  ranges = answer.resolved;
97
151
  declaration.resolved = answer.resolved.filter(({ path: where, symbol }) => wantedKeys.has(`${where}\0${symbol}`))
98
152
  .map(({ path: where, symbol, kind, start_line: start, end_line: end }) => ({
99
153
  path: where, symbol, kind, start_line: start, end_line: end,
100
154
  }));
101
155
  if (declaration.unresolved.length > 0) return { row: null, declaration };
156
+ declaration.whole_files = await wholeFiles({ root, observable, bare, files: answer.files ?? [], text });
102
157
  }
103
- return buildRow({ own, read, writes, declaration, ranges });
158
+ return buildRow({ own, read, writes, declaration, ranges, isNew: (anchor) => newKeys.has(keyOf(anchor)) });
104
159
  }
105
160
 
106
- function buildRow({ own, read, writes, declaration, ranges }) {
107
- const concern = byWithin(own.anchors);
108
- const readAnchors = byWithin(read.anchors);
161
+ function buildRow({ own, read, writes, declaration, ranges, isNew }) {
162
+ const concern = byWithin(own.anchors, isNew);
163
+ const readAnchors = byWithin(read.anchors, isNew);
109
164
  const row = {
110
165
  owns: sortedUnique([...own.paths, ...concern.map(({ within }) => within)]),
111
166
  reads: sortedUnique([...read.paths, ...readAnchors.map(({ within }) => within)]),
@@ -7,7 +7,8 @@ import { verifyFunctionSplit } from './function-split-verify.mjs';
7
7
  import { measureWaveCount } from './seam-verification.mjs';
8
8
  import { parseAnchor } from './sensor-resolve.mjs';
9
9
  import { appendTodoNote } from './todo-note-store.mjs';
10
- import { anchorsOf, claimsOf, judgeTask, rangeIndex } from './todo-judgment.mjs';
10
+ import { anchorsOf, claimsOf, judgeTask, rangeIndex, relationView } from './todo-judgment.mjs';
11
+ import { readTodoTaskRelations } from './todo-relation-store.mjs';
11
12
  import { readTodoSplit, recordTodoSplit } from './todo-split-store.mjs';
12
13
  import {
13
14
  createTodoStoreWriter, readTodoStore, readTodoWitnessSet, TodoStoreError,
@@ -166,6 +167,13 @@ const reaches = (plan, from, to) => {
166
167
  return false;
167
168
  };
168
169
 
170
+ /** The tasks `lead` still has an open write x write overlap with on `path` (a whole-file side counts); `read` null = none open. */
171
+ function writeOverlaps({ read, lead, path }) {
172
+ return (read?.open ?? []).map((relation) => relationView(lead, relation))
173
+ .filter((view) => view.path === path && view.overlaps.some(({ self, other }) => self.access === 'write' && other.access === 'write'))
174
+ .map((view) => view.with);
175
+ }
176
+
169
177
  /**
170
178
  * Not split (D6, D7): the member in progress that started first becomes the predecessor of the unfinished members that have
171
179
  * not started, each member gets a note with the reason, then S is retired. The edges go first, so a crash leaves S open and
@@ -180,8 +188,11 @@ export async function reorganizeNotSplit({ repoRoot, env, planKey, taskId, reaso
180
188
  const open = mark.members.filter((id) => state.has(id) && !FINISHED.has(state.get(id).status));
181
189
  const lead = open.filter((id) => state.get(id).status === 'in-progress')
182
190
  .sort((left, right) => (state.get(left).started_at < state.get(right).started_at ? -1 : 1))[0];
183
- const edges = lead === undefined ? [] : open.filter((id) => state.get(id).status !== 'in-progress' && !reaches(member.plan, lead, id))
184
- .map((id) => ({ from: lead, to: id }));
191
+ const candidates = lead === undefined ? [] : open.filter((id) => state.get(id).status !== 'in-progress' && !reaches(member.plan, lead, id));
192
+ // ADR 0205 §6: a member that moved out of F and declared again leaves no overlap: no edge for it (an unreadable relation file fails here, as any Store read).
193
+ const overlapping = candidates.length === 0 ? [] : writeOverlaps({ read: await readTodoTaskRelations({ repoRoot, planKey, taskId: lead }), lead, path: mark.path });
194
+ const edges = candidates.filter((id) => overlapping.includes(id)).map((id) => ({ from: lead, to: id }));
195
+ const gone = new Set(candidates.filter((id) => !overlapping.includes(id)));
185
196
  let planVersion = member.plan.plan_version;
186
197
  if (edges.length > 0) {
187
198
  const { applyPlanRevision, desiredFromPlan } = await import('./plan-revise.mjs');
@@ -194,7 +205,7 @@ export async function reorganizeNotSplit({ repoRoot, env, planKey, taskId, reaso
194
205
  for (const id of open) {
195
206
  await appendTodoNote({ repoRoot, projectId: member.plan.project_id, planKey, planVersion, taskId: id, actor,
196
207
  recordedAt: new Date().toISOString(), supersedes: null, eligibleSupersedes: [],
197
- body: `function split ${taskId} on ${mark.path}#${mark.symbol} was not made: ${reason}${lead !== undefined && id !== lead && state.get(id).status !== 'in-progress' ? `; ${id} now waits for ${lead}` : ''}` });
208
+ body: `function split ${taskId} on ${mark.path}#${mark.symbol} was not made: ${reason}${lead === undefined || id === lead || state.get(id).status === 'in-progress' ? '' : gone.has(id) ? `; the overlap with ${lead} is gone, ${id} does not wait` : `; ${id} now waits for ${lead}`}` });
198
209
  }
199
210
  const retired = await deps.retire({ repoRoot, env, planKey, taskId, reason });
200
211
  return { schema: 'lattice.todo_function_split_decline_result.v1', project_id: member.plan.project_id, plan_key: planKey,
@@ -223,7 +223,8 @@ function explainConcernAnchors(anchors, owns, writes, at) {
223
223
  }
224
224
  for (const [index, entry] of anchors.entries()) {
225
225
  const entryAt = `${at}/${index}`;
226
- if (!exactRecord(entry, ['within', 'symbols'])) {
226
+ // `new_symbols` (ADR 0204 §7) is optional: the names of `symbols` that did not resolve when the task declared them.
227
+ if (!exactRecord(entry, Object.hasOwn(entry, 'new_symbols') ? ['within', 'symbols', 'new_symbols'] : ['within', 'symbols'])) {
227
228
  return reject('unexpected_or_missing_keys', entryAt);
228
229
  }
229
230
  if (!exactRecord(entry.within, ['kind', 'target'])
@@ -247,6 +248,13 @@ function explainConcernAnchors(anchors, owns, writes, at) {
247
248
  if (!strictlySorted(entry.symbols)) {
248
249
  return reject('unsorted_or_duplicate_collection', `${entryAt}/symbols`);
249
250
  }
251
+ if (Object.hasOwn(entry, 'new_symbols')) {
252
+ if (!Array.isArray(entry.new_symbols) || entry.new_symbols.length < 1 || entry.new_symbols.length > entry.symbols.length
253
+ || !entry.new_symbols.every((symbol) => entry.symbols.includes(symbol))) {
254
+ return reject('invalid_concern_anchor_symbol', `${entryAt}/new_symbols`);
255
+ }
256
+ if (!strictlySorted(entry.new_symbols)) return reject('unsorted_or_duplicate_collection', `${entryAt}/new_symbols`);
257
+ }
250
258
  }
251
259
  if (!strictlySorted(anchors, (entry) => `${entry.within.kind}\0${entry.within.target}`)) {
252
260
  return reject('unsorted_or_duplicate_collection', at);
@@ -13,12 +13,14 @@ const compareText = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
13
13
  export function claimsOf(row) {
14
14
  const claims = new Map();
15
15
  const add = (target, claim) => claims.set(target, [...(claims.get(target) ?? []), claim]);
16
- const anchored = (list) => new Map((list ?? []).map(({ within, symbols }) => [within.target, symbols]));
16
+ const anchored = (list) => new Map((list ?? []).map(({ within, symbols, new_symbols: fresh = [] }) => [within.target,
17
+ symbols.map((symbol) => ({ symbol, fresh: fresh.includes(symbol) }))]));
17
18
  const concern = anchored(row.concern_anchors);
18
19
  const readAnchor = anchored(row.read_anchors);
19
20
  const written = new Set([...row.owns.filter(({ kind }) => kind === 'path').map(({ target }) => target), ...row.writes]);
20
- for (const target of written) for (const symbol of concern.get(target) ?? [null]) add(target, { symbol, access: 'write' });
21
- for (const target of row.reads) for (const symbol of readAnchor.get(target) ?? [null]) add(target, { symbol, access: 'read' });
21
+ const nameless = [{ symbol: null, fresh: false }];
22
+ for (const target of written) for (const { symbol, fresh } of concern.get(target) ?? nameless) add(target, { symbol, fresh, access: 'write' });
23
+ for (const target of row.reads) for (const { symbol, fresh } of readAnchor.get(target) ?? nameless) add(target, { symbol, fresh, access: 'read' });
22
24
  return claims;
23
25
  }
24
26
 
@@ -35,7 +37,8 @@ export const rangeIndex = (resolved) => new Map(resolved.map(({ path: target, sy
35
37
  /**
36
38
  * Judge `taskId` against every other task in `rows` (`{taskId: witnessRow}`, already limited to unfinished tasks).
37
39
  * `ranges` is a `rangeIndex`; an anchored claim with no range (the name no longer resolves) is read as a whole-file claim
38
- * and counted in `unresolved` (distinct names). Overlap needs at least one write; two reads never conflict (ADR 0204, claim 4).
40
+ * and counted in `unresolved` (distinct names), except a name the task declared as new (`new_symbols`): it keeps its name with no lines
41
+ * and overlaps only a whole-file claim and the same name (ADR 0204 §7). Overlap needs at least one write; two reads never conflict (ADR 0204, claim 4).
39
42
  * → `{relations: [{task_a, task_b, path, overlaps}], gone: [{task_a, task_b, path}], unresolved}`: `gone` names the pairs of
40
43
  * this task that no longer overlap on a path they once shared (the caller closes only those that are open).
41
44
  */
@@ -43,15 +46,22 @@ export function judgeTask({ taskId, rows, ranges, openRelations = [], only = nul
43
46
  const mine = claimsOf(rows[taskId]);
44
47
  const relations = [];
45
48
  const missing = new Set();
49
+ // A name declared as new that has no range yet keeps its name and no lines (ADR 0204 §7); a name NOT declared as new that
50
+ // no longer resolves (renamed on main) is read as a whole-file claim, never as "no conflict".
46
51
  const side = (target, claim) => {
47
52
  const range = claim.symbol === null ? undefined : ranges.get(rangeKey(target, claim.symbol));
53
+ if (range === undefined && claim.symbol !== null && claim.fresh) return { symbol: claim.symbol, start_line: null, end_line: null, access: claim.access };
48
54
  if (claim.symbol !== null && range === undefined) missing.add(rangeKey(target, claim.symbol));
49
55
  return range === undefined
50
56
  ? { symbol: null, start_line: null, end_line: null, access: claim.access }
51
57
  : { symbol: claim.symbol, start_line: range.start_line, end_line: range.end_line, access: claim.access };
52
58
  };
53
- const overlap = (left, right) => left.symbol === null || right.symbol === null
54
- || !(left.end_line < right.start_line || right.end_line < left.start_line);
59
+ const unranged = (entry) => entry.symbol !== null && entry.start_line === null;
60
+ const overlap = (left, right) => {
61
+ if (left.symbol === null || right.symbol === null) return true;
62
+ if (unranged(left) || unranged(right)) return unranged(left) && unranged(right) && left.symbol === right.symbol;
63
+ return !(left.end_line < right.start_line || right.end_line < left.start_line);
64
+ };
55
65
  for (const otherId of Object.keys(rows).sort(compareText)) {
56
66
  if (otherId === taskId) continue;
57
67
  const [taskA, taskB] = taskId < otherId ? [taskId, otherId] : [otherId, taskId];
@@ -25,7 +25,7 @@ function triggerOf(member, event, ref) {
25
25
  export function startPath(planKey, taskId, mode, declared) {
26
26
  return [
27
27
  ...(mode === 'enforced' && !declared
28
- ? [`lattice todo independence witness declare --plan ${planKey} --task ${taskId} --owns <path>[,<path>...]`] : []),
28
+ ? [`lattice todo independence witness declare --plan ${planKey} --task ${taskId} --owns <path>#<function>[,...] [--reads <path>#<function>,...]`] : []),
29
29
  `lattice todo start --plan ${planKey} --task ${taskId}`,
30
30
  ];
31
31
  }
@@ -23,7 +23,8 @@ export function splitGuide({ planKey, taskId, mark }) {
23
23
  + ' (map the members whose function changed; an unmapped member keeps its declaration).'
24
24
  + ' Once verify accepts, open the PR with `[skip ci]` in the commit message (verify already ran the checks for the cut), merge it,'
25
25
  + ` then run \`lattice todo done --plan ${planKey} --task ${taskId} --message <what you merged>\`.`,
26
- `Not split: run \`${base} decline --plan ${planKey} --task ${taskId} --reason <text>\`; the later tasks then wait for the one that started first.`,
26
+ `Not split: run \`${base} decline --plan ${planKey} --task ${taskId} --reason <text>\`; the later tasks then wait for the one that started first,`
27
+ + ' unless you moved your change out of the function and declared again first: with no write overlap left there is no wait.',
27
28
  ].join('\n');
28
29
  }
29
30
 
@@ -46,7 +47,8 @@ export function planSplitHold({ member, taskId, read }) {
46
47
  const other = byId.get(otherId);
47
48
  if (state.get(otherId) !== 'in-progress' || other.lane === self.lane) continue;
48
49
  for (const { self: mine, other: theirs } of overlaps) {
49
- if (mine.access !== 'write' || theirs.access !== 'write' || mine.symbol === null || theirs.symbol === null) continue;
50
+ // a side with no range (whole file, or a function that does not exist yet) has nothing to cut
51
+ if (mine.access !== 'write' || theirs.access !== 'write' || mine.start_line === null || theirs.start_line === null) continue;
50
52
  const key = `${where}\0${theirs.symbol}`;
51
53
  const entry = functions.get(key) ?? { path: where, symbol: theirs.symbol, start_line: theirs.start_line, end_line: theirs.end_line, owners: new Set() };
52
54
  entry.owners.add(otherId);
@@ -69,7 +69,9 @@ function explainDraftTask(task, schema) {
69
69
  for (const key of ['concern_anchors', 'read_anchors']) {
70
70
  if (task[key] !== undefined && !(Array.isArray(task[key])
71
71
  && task[key].every((anchor) => plainObject(anchor) && isTodoRef(anchor.within)
72
- && Array.isArray(anchor.symbols) && anchor.symbols.length > 0 && anchor.symbols.every(isTodoIdentifier)))) {
72
+ && Array.isArray(anchor.symbols) && anchor.symbols.length > 0 && anchor.symbols.every(isTodoIdentifier)
73
+ && (anchor.new_symbols === undefined || (Array.isArray(anchor.new_symbols) && anchor.new_symbols.length > 0
74
+ && anchor.new_symbols.every((symbol) => anchor.symbols.includes(symbol))))))) {
73
75
  return { reason: `invalid_${key}`, path: `/${key}` };
74
76
  }
75
77
  }
@@ -123,10 +125,12 @@ export function witnessDraftTemplate({ projectId, planKey, taskIds, witnessSet =
123
125
  writes: witness.writes.filter((target) => !owned.has(target)),
124
126
  ...(witness.unknowns.length > 0 ? { unknowns: witness.unknowns.map(({ kind, ref }) => ({ kind, ref })) } : {}),
125
127
  ...(witness.concern_anchors?.length > 0 ? {
126
- concern_anchors: witness.concern_anchors.map(({ within, symbols }) => ({ within: within.target, symbols: [...symbols] })),
128
+ concern_anchors: witness.concern_anchors.map(({ within, symbols, new_symbols: fresh }) => ({
129
+ within: within.target, symbols: [...symbols], ...(fresh === undefined ? {} : { new_symbols: [...fresh] }) })),
127
130
  } : {}),
128
131
  ...(witness.read_anchors?.length > 0 ? {
129
- read_anchors: witness.read_anchors.map(({ within, symbols }) => ({ within: within.target, symbols: [...symbols] })),
132
+ read_anchors: witness.read_anchors.map(({ within, symbols, new_symbols: fresh }) => ({
133
+ within: within.target, symbols: [...symbols], ...(fresh === undefined ? {} : { new_symbols: [...fresh] }) })),
130
134
  } : {}),
131
135
  };
132
136
  };
@@ -195,7 +199,8 @@ export function buildWitnessSet({ draft, observationByPath } = {}) {
195
199
  if (!readTargets.has(anchor.within)) reasons.push(`read_anchor_outside_reads:${taskId}:${anchor.within}`);
196
200
  }
197
201
  const anchorEntries = (anchors) => [...anchors]
198
- .map((anchor) => ({ within: { kind: 'path', target: anchor.within }, symbols: sortedUnique(anchor.symbols) }))
202
+ .map((anchor) => ({ within: { kind: 'path', target: anchor.within }, symbols: sortedUnique(anchor.symbols),
203
+ ...(anchor.new_symbols === undefined ? {} : { new_symbols: sortedUnique(anchor.new_symbols) }) }))
199
204
  .sort((left, right) => compareText(left.within.target, right.within.target));
200
205
  manualWitness[taskId] = {
201
206
  owns: owns.map(({ target, creates }) => (