@quolu/lattice 0.52.1 → 0.52.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/todo-cli.mjs +17 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.52.1",
3
+ "version": "0.52.2",
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/todo-cli.mjs CHANGED
@@ -434,9 +434,21 @@ async function readRevisionInput(repoRoot, inputRef, {
434
434
  return revision;
435
435
  }
436
436
 
437
+ // --evidenceが受け取るのは生の証拠ファイルではなくJSON記述子。ここを間違えた呼び出しAIが
438
+ // json_parse_failed/schema_invalidだけを見て手詰まりになるので、期待形をエラーに同梱する(ADR 0130)。
439
+ const EVIDENCE_DESCRIPTOR_EXPECTED = Object.freeze({
440
+ shape: '{ "evidence_id": "<identifier>", "repo_id": "<identifier>", "path": "<repo相対path>",'
441
+ + ' "git_blob_oid": "<40/64桁hex>", "content_digest": "<sha256 64桁hex>",'
442
+ + ' "media_type": "text/markdown", "anchor_digest": null }',
443
+ note: '証拠ファイル本体ではなく、コミット済みblobを指すJSON記述子を渡す。'
444
+ + '対象ファイルをcommitした後、git_blob_oidは `git rev-parse HEAD:<path>`、'
445
+ + 'content_digestはblob bytesのsha256(hex)で得る。refsから到達可能なblobだけが検証を通る',
446
+ });
447
+
437
448
  async function readEvidenceInput(repoRoot, inputRef) {
438
449
  return readJsonInput(repoRoot, inputRef, {
439
450
  validate: validateEvidenceDescriptor, invalidCode: 'INVALID_EVIDENCE',
451
+ expected: EVIDENCE_DESCRIPTOR_EXPECTED,
440
452
  });
441
453
  }
442
454
 
@@ -474,15 +486,18 @@ async function readJsonInput(repoRoot, inputRef, { validate, invalidCode, expect
474
486
  if (text.startsWith('\uFEFF') || text.includes('\r')) {
475
487
  throw new TodoStoreError('INVALID_JSON', 'non_portable_json_bytes');
476
488
  }
489
+ // parse失敗は「JSONでないファイル(証拠本体など)をそのまま渡した」誤用が大半なので、
490
+ // 期待形を知っている入口では expected を同梱して次の一手を示す(ADR 0130)。
491
+ const parseFailureDetail = expected === null ? undefined : { expected };
477
492
  const parseErrors = [];
478
493
  const tree = parseTree(text, parseErrors, { allowTrailingComma: false, disallowComments: true });
479
494
  if (parseErrors.length > 0 || tree === undefined) {
480
- throw new TodoStoreError('INVALID_JSON', 'json_parse_failed');
495
+ throw new TodoStoreError('INVALID_JSON', 'json_parse_failed', undefined, parseFailureDetail);
481
496
  }
482
497
  if (hasDuplicateJsonKey(tree)) throw new TodoStoreError('INVALID_JSON', 'duplicate_key');
483
498
  let descriptor;
484
499
  try { descriptor = JSON.parse(text); } catch {
485
- throw new TodoStoreError('INVALID_JSON', 'json_parse_failed');
500
+ throw new TodoStoreError('INVALID_JSON', 'json_parse_failed', undefined, parseFailureDetail);
486
501
  }
487
502
  if (!validate(descriptor)) {
488
503
  // 「schema_invalid」だけを返すと、呼び出したAIは何をどう直せばよいか分からない。