@quolu/lattice 0.90.0 → 0.91.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.90.0",
3
+ "version": "0.91.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",
package/src/cli-help.mjs CHANGED
@@ -173,8 +173,8 @@ Write commands:
173
173
  # 実際に受理する最新契約のJSON Schemaを返す(storeを読まない)。
174
174
  # 入力が契約に合わないときは、違反フィールドのpathがerror detailへ載る
175
175
  phase review --plan <key> --phase <id> --reason <text>
176
- phase accept --plan <key> --phase <id> --evidence <file> # 監査fileから入力を機械が組む
177
- phase reject --plan <key> --phase <id> --reason <text> --evidence <file>
176
+ phase accept --plan <key> --phase <id> --evidence <file> | --message <text> # 監査file/文から入力を機械が組む
177
+ phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --message <text>
178
178
  phase <accept|reject> --plan <key> --phase <id> --input <file>
179
179
  phase reopen --plan <key> --phase <id> --reason <text> [--override-reason <text>]
180
180
  phase close-unaudited --plan <key> --phase <id> --reason <text>
@@ -329,8 +329,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
329
329
  + ' | baseline --reason <text> [--except <plan_key>]...',
330
330
  'todo phase status': 'todo phase status --plan <key> [--json]',
331
331
  'todo phase review': 'todo phase review --plan <key> --phase <id> --reason <text>',
332
- 'todo phase accept': 'todo phase accept --plan <key> --phase <id> --evidence <file> | --input <file>',
333
- 'todo phase reject': 'todo phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --input <file>',
332
+ 'todo phase accept': 'todo phase accept --plan <key> --phase <id> --evidence <file> | --message <text> | --input <file>',
333
+ 'todo phase reject': 'todo phase reject --plan <key> --phase <id> --reason <text> --evidence <file> | --message <text> | --input <file>',
334
334
  'todo phase reopen': 'todo phase reopen --plan <key> --phase <id> --reason <text> [--override-reason <text>]',
335
335
  'todo phase close-unaudited': 'todo phase close-unaudited --plan <key> --phase <id> --reason <text>',
336
336
  'todo phase baseline': 'todo phase baseline --reason <text> [--except <plan_key>]...',
package/src/todo-cli.mjs CHANGED
@@ -354,8 +354,8 @@ const TODO_FLAG_SPECS = Object.freeze({
354
354
  split: Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
355
355
  note: NOTE_FLAG_SPEC,
356
356
  // a28: the rest of the writes, and the reads whose --json is optional (their output is JSON either way).
357
- 'phase accept': Object.freeze({ known: ['plan', 'phase', 'evidence', 'input'], required: ['plan', 'phase'] }),
358
- 'phase reject': Object.freeze({ known: ['plan', 'phase', 'evidence', 'reason', 'input'], required: ['plan', 'phase'] }),
357
+ 'phase accept': Object.freeze({ known: ['plan', 'phase', 'evidence', 'message', 'input'], required: ['plan', 'phase'] }),
358
+ 'phase reject': Object.freeze({ known: ['plan', 'phase', 'evidence', 'message', 'reason', 'input'], required: ['plan', 'phase'] }),
359
359
  'phase reopen': Object.freeze({ known: ['plan', 'phase', 'reason', 'override-reason'], required: ['plan', 'phase', 'reason'] }),
360
360
  'evidence promote': Object.freeze({ known: ['plan', 'task', 'evidence'], required: ['plan', 'task', 'evidence'] }),
361
361
  'independence compile': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
@@ -489,18 +489,19 @@ function explainArgumentRefusal(argv) {
489
489
  }
490
490
  }
491
491
  if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
492
- const given = ['evidence', 'input'].filter((name) => typeof flags[name] === 'string' && flags[name].length > 0);
492
+ const given = ['evidence', 'message', 'input'].filter((name) => typeof flags[name] === 'string' && flags[name].length > 0);
493
493
  if (given.length === 0) {
494
494
  return { pointer: '--evidence', rule: 'flag_missing',
495
- next_action: `Add --evidence <file> (or --input <decision file>): \`${repairedCommand(head, { ...spec, required: [...spec.required, 'evidence', ...(argv[1] === 'reject' ? ['reason'] : [])] }, flags)}\`.` };
495
+ next_action: `Add --evidence <file> (or --message <text>, or --input <decision file>): \`${repairedCommand(head, { ...spec, required: [...spec.required, 'evidence', ...(argv[1] === 'reject' ? ['reason'] : [])] }, flags)}\`.` };
496
496
  }
497
- if (given.length === 2) {
498
- return { pointer: '--input', rule: 'flags_exclusive',
499
- next_action: `Pass either --evidence or --input, not both: \`${repairedCommand(head, spec, { ...flags, input: undefined })}\`.` };
497
+ if (given.length > 1) {
498
+ const [keep, drop] = given;
499
+ return { pointer: `--${drop}`, rule: 'flags_exclusive',
500
+ next_action: `Pass one of --evidence, --message or --input: \`${repairedCommand(head, spec, { ...flags, ...Object.fromEntries(given.filter((name) => name !== keep).map((name) => [name, undefined])) })}\`.` };
500
501
  }
501
- if (argv[1] === 'reject' && given[0] === 'evidence' && !(typeof flags.reason === 'string' && flags.reason.length > 0)) {
502
+ if (argv[1] === 'reject' && given[0] !== 'input' && !(typeof flags.reason === 'string' && flags.reason.length > 0)) {
502
503
  return { pointer: '--reason', rule: 'flag_missing',
503
- next_action: `A reject with --evidence needs --reason <text>: \`${repairedCommand(head, { ...spec, required: [...spec.required, 'reason'] }, flags)}\`.` };
504
+ next_action: `A reject with --${given[0]} needs --reason <text>: \`${repairedCommand(head, { ...spec, required: [...spec.required, 'reason'] }, flags)}\`.` };
504
505
  }
505
506
  if (given[0] === 'input' && flags.reason !== undefined) {
506
507
  return { pointer: '--reason', rule: 'flag_unknown',
@@ -876,8 +877,9 @@ async function readStructureSetDraft(repoRoot, inputRef) {
876
877
  function auditGateGuidance(planKey, phaseId, auditRequired = false) {
877
878
  const target = `--plan ${planKey} --phase ${phaseId}`;
878
879
  const audit = `lattice todo phase review ${target} --reason <text> → accept ${target} --evidence <file>`;
879
- // ADR 0200 gate 5: an enforced plan's heavy phase refuses close-unaudited, so only the audit is offered.
880
- if (auditRequired) return `全ToDoがdone。このplanはenforcedでheavyの段階なので監査する: ${audit}`;
880
+ // ADR 0200 gate 5: an enforced plan's heavy phase refuses close-unaudited, so only the audit is offered,
881
+ // with the --message route for a seat that cannot write a file into the Store root.
882
+ if (auditRequired) return `全ToDoがdone。このplanはenforcedでheavyの段階なので監査する: ${audit}(fileを置けないなら --message <text>)`;
881
883
  return `全ToDoがdone。監査せず閉じるなら: lattice todo phase close-unaudited ${target} --reason <text>`
882
884
  + `(監査するなら ${audit})`;
883
885
  }
@@ -1585,7 +1587,8 @@ const PHASE_DECISION_EXPECTED = Object.freeze({
1585
1587
  reject: '{ "schema": "lattice.phase_reject_input.v1", "review_event_digest": "<phase reviewのevent_digest>",'
1586
1588
  + ' "reason": "<text>", "decision_evidence": <evidence記述子>, "input_digest": "" }',
1587
1589
  note: 'input_digestは入口が計算する。証拠fileがcommit済みなら、`--evidence <file>`で'
1588
- + 'review_event_digest・記述子・必須slotを機械が埋める。evidence記述子の形はEVIDENCE_DESCRIPTOR_EXPECTEDを見る。',
1590
+ + 'review_event_digest・記述子・必須slotを機械が埋める。fileを置けないなら`--message <text>`でも同じく埋まる'
1591
+ + '(commitまではuncommitted)。evidence記述子の形はEVIDENCE_DESCRIPTOR_EXPECTEDを見る。',
1589
1592
  });
1590
1593
 
1591
1594
  async function phaseDecision({ repoRoot, env, planKey, phaseId, outcome, inputRef }) {
@@ -1622,7 +1625,9 @@ async function phaseDecision({ repoRoot, env, planKey, phaseId, outcome, inputRe
1622
1625
  * fileから作る。必須slotが1つならその証拠で埋める。複数slotへ1つの証拠を流用すると
1623
1626
  * 「各slotを別々に確かめた」ことを偽るので、その場合は`--input`で明示させる。
1624
1627
  */
1625
- async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outcome, evidenceRef, reason }) {
1628
+ async function phaseDecisionFromEvidence({
1629
+ repoRoot, env, planKey, phaseId, outcome, evidenceRef = null, evidenceMessage = null, reason,
1630
+ }) {
1626
1631
  const store = await readTodoStore({ repoRoot });
1627
1632
  const member = store.members.find(({ plan }) => plan.plan_key === planKey);
1628
1633
  if (member === undefined) {
@@ -1649,8 +1654,9 @@ async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outc
1649
1654
  next_action: `lattice todo phase accept --plan ${planKey} --phase ${phaseId} --input <file>`,
1650
1655
  });
1651
1656
  }
1657
+ // A --message becomes message evidence exactly as in `todo done`: no file inside the Store root is needed.
1652
1658
  const evidence = await resolveDoneEvidence({
1653
- repoRoot, evidenceRef, evidenceMessage: null, planKey, taskId: `${phaseId}-${outcome}`,
1659
+ repoRoot, evidenceRef, evidenceMessage, planKey, taskId: `${phaseId}-${outcome}`,
1654
1660
  });
1655
1661
  const payload = outcome === 'accept'
1656
1662
  ? { review_event_digest: state.review_event_digest, decision_evidence: evidence,
@@ -1659,6 +1665,12 @@ async function phaseDecisionFromEvidence({ repoRoot, env, planKey, phaseId, outc
1659
1665
  return phaseMutation({ repoRoot, env, planKey, phaseId, kind: `phase_${outcome}`, payload });
1660
1666
  }
1661
1667
 
1668
+ /** A phase decision's evidence: committed, uncommitted (no ref reaches it yet, e.g. `--message` on a root with no commit) or null. */
1669
+ function decisionEvidenceState(repoRoot, store, evidence) {
1670
+ if (evidence === null || evidence === undefined) return null;
1671
+ return isTodoEvidenceUncommitted({ repoRoot, store, evidence }) ? 'uncommitted' : 'committed';
1672
+ }
1673
+
1662
1674
  async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload }) {
1663
1675
  if (kind === 'phase_close_unaudited') {
1664
1676
  // ADR 0200 gate 5: an enforced plan keeps the audit its author required for a heavy phase.
@@ -1668,7 +1680,8 @@ async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload })
1668
1680
  if (phaseAuditRequired(member, phase?.gate_policy)) {
1669
1681
  throw new TodoStoreError('TODO_TRANSITION_REFUSED', 'enforced_heavy_phase_unaudited', undefined, {
1670
1682
  plan_key: planKey, phase_id: phaseId,
1671
- next_action: `Audit it: \`lattice todo phase review --plan ${planKey} --phase ${phaseId} --reason <text>\` then \`lattice todo phase accept --plan ${planKey} --phase ${phaseId} --evidence <file>\`;`
1683
+ next_action: `Audit it: \`lattice todo phase review --plan ${planKey} --phase ${phaseId} --reason <text>\` then \`lattice todo phase accept --plan ${planKey} --phase ${phaseId} --evidence <file>\``
1684
+ + ` (or \`--message <text>\` when no file can be written into the Store root);`
1672
1685
  + ' or revise the phase to a non-heavy gate_policy with `lattice plan revise` (recorded).',
1673
1686
  });
1674
1687
  }
@@ -1687,7 +1700,10 @@ async function phaseMutation({ repoRoot, env, planKey, phaseId, kind, payload })
1687
1700
  plan_key: event.plan_key, plan_version: event.plan_version, phase_id: event.phase_id,
1688
1701
  kind: event.kind, sequence: event.sequence, event_digest: event.event_digest,
1689
1702
  journal_head_digest: event.event_digest, snapshot_digest: snapshot.snapshot_digest,
1690
- status: phase.status, result_digest: '',
1703
+ status: phase.status,
1704
+ decision_evidence_state: phase.decision_evidence === null || phase.decision_evidence === undefined ? null
1705
+ : decisionEvidenceState(repoRoot, await readTodoStore({ repoRoot }), phase.decision_evidence),
1706
+ result_digest: '',
1691
1707
  };
1692
1708
  result.result_digest = todoSelfDigest(result, 'result_digest');
1693
1709
  return result;
@@ -2017,6 +2033,7 @@ async function phaseStatus({ repoRoot, planKey }) {
2017
2033
  // v4/v5の実Phaseがgate_readyになった場合も同じ理由で同じ案内が要る。
2018
2034
  const phases = member.phases.map((phase) => ({
2019
2035
  ...phase,
2036
+ decision_evidence_state: decisionEvidenceState(repoRoot, store, phase.decision_evidence),
2020
2037
  acceptance_stale: phaseAcceptanceStale(member.plan, member.journal.events, phase, member.tasks),
2021
2038
  guidance: phaseAcceptanceStale(member.plan, member.journal.events, phase, member.tasks)
2022
2039
  ? staleAcceptanceGuidance(member.plan.plan_key, phase.phase_id)
@@ -4727,6 +4744,11 @@ async function verify({ repoRoot, requestedPlanKey }) {
4727
4744
  uncommittedEvidence.push({ plan_key: planKey, task_id: taskId, repo_id: evidence.repo_id, path: evidence.path,
4728
4745
  next_action: `Commit ${evidence.path} (repository ${evidence.repo_id}), then rerun \`lattice todo verify --json\`.` });
4729
4746
  }
4747
+ for (const { phase_id: phaseId, decision_evidence: evidence } of member.phases) {
4748
+ if (decisionEvidenceState(repoRoot, store, evidence) !== 'uncommitted') continue;
4749
+ uncommittedEvidence.push({ plan_key: planKey, phase_id: phaseId, repo_id: evidence.repo_id, path: evidence.path,
4750
+ next_action: `Commit ${evidence.path} (repository ${evidence.repo_id}), then rerun \`lattice todo verify --json\`.` });
4751
+ }
4730
4752
  const unverified = member.tasks.find((task) => task.evidence_unverified && !pending.includes(task));
4731
4753
  if (unverified !== undefined) {
4732
4754
  throw new TodoStoreError('STORE_INCONSISTENT', 'evidence_unverified', 'evidence_unverified', {
@@ -5204,21 +5226,29 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
5204
5226
  } else if (argv[0] === 'phase' && ['accept', 'reject'].includes(argv[1])) {
5205
5227
  const outcome = argv[1];
5206
5228
  const flags = matchFlagCommand(argv, ['phase', outcome], {
5207
- known: ['plan', 'phase', 'input', 'evidence', 'reason'], required: ['plan', 'phase'],
5229
+ known: ['plan', 'phase', 'input', 'evidence', 'message', 'reason'], required: ['plan', 'phase'],
5208
5230
  });
5231
+ const reasonFits = outcome === 'accept' ? flags?.reason === undefined
5232
+ : typeof flags?.reason === 'string' && flags.reason.length > 0;
5209
5233
  const base = flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.phase);
5210
- if (base && isAuthoringPathToken(flags.input) && flags.evidence === undefined && flags.reason === undefined) {
5234
+ if (base && isAuthoringPathToken(flags.input) && flags.evidence === undefined && flags.message === undefined
5235
+ && flags.reason === undefined) {
5211
5236
  action = (repoRoot) => phaseDecision({
5212
5237
  repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
5213
5238
  outcome, inputRef: flags.input,
5214
5239
  });
5215
- } else if (base && flags.input === undefined && isAuthoringPathToken(flags.evidence)
5216
- && (outcome === 'accept' ? flags.reason === undefined
5217
- : typeof flags.reason === 'string' && flags.reason.length > 0)) {
5240
+ } else if (base && flags.input === undefined && flags.message === undefined
5241
+ && isAuthoringPathToken(flags.evidence) && reasonFits) {
5218
5242
  action = (repoRoot) => phaseDecisionFromEvidence({
5219
5243
  repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
5220
5244
  outcome, evidenceRef: flags.evidence, reason: flags.reason ?? null,
5221
5245
  });
5246
+ } else if (base && flags.input === undefined && flags.evidence === undefined
5247
+ && typeof flags.message === 'string' && flags.message.length > 0 && reasonFits) {
5248
+ action = (repoRoot) => phaseDecisionFromEvidence({
5249
+ repoRoot, env, planKey: flags.plan, phaseId: flags.phase,
5250
+ outcome, evidenceMessage: flags.message, reason: flags.reason ?? null,
5251
+ });
5222
5252
  }
5223
5253
  } else if (argv[0] === 'phase' && argv[1] === 'reopen' && phaseReopenFlags(argv) !== null) {
5224
5254
  const flags = phaseReopenFlags(argv);