@intentius/chant 0.124.24 → 0.124.25

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 (96) hide show
  1. package/dist/cli/main.d.ts.map +1 -1
  2. package/dist/cli/main.js +21 -7
  3. package/dist/cli/mcp/workspace-tools.d.ts +3 -3
  4. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  5. package/dist/cli/mcp/workspace-tools.js +27 -4
  6. package/dist/effect-receipt.d.ts +13 -0
  7. package/dist/effect-receipt.d.ts.map +1 -1
  8. package/dist/effect-receipt.js +19 -0
  9. package/dist/lexicon-module.d.ts +7 -1
  10. package/dist/lexicon-module.d.ts.map +1 -1
  11. package/dist/lexicon-module.js +7 -2
  12. package/dist/lifecycle/receipt-plan.d.ts.map +1 -1
  13. package/dist/lifecycle/receipt-plan.js +4 -2
  14. package/dist/op/local-executor.d.ts.map +1 -1
  15. package/dist/op/local-executor.js +64 -5
  16. package/dist/op/receipt-store.d.ts +5 -0
  17. package/dist/op/receipt-store.d.ts.map +1 -1
  18. package/dist/op/receipt-store.js +4 -3
  19. package/dist/op/step-output-ref.d.ts +26 -18
  20. package/dist/op/step-output-ref.d.ts.map +1 -1
  21. package/dist/op/step-output-ref.js +86 -63
  22. package/dist/wave-runtime.mjs +213 -213
  23. package/dist/workspace/agent-cli.d.ts.map +1 -1
  24. package/dist/workspace/agent-cli.js +3 -0
  25. package/dist/workspace/conformance/__writer_fixture__/answers/answer.schema.json +16 -1
  26. package/dist/workspace/conformance/writer.js +1 -1
  27. package/dist/workspace/decide.d.ts +51 -9
  28. package/dist/workspace/decide.d.ts.map +1 -1
  29. package/dist/workspace/decide.js +125 -14
  30. package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
  31. package/dist/workspace/lineage-upgrade.js +20 -11
  32. package/dist/workspace/point-answer.schema.json +16 -1
  33. package/dist/workspace/points-cli.d.ts +5 -3
  34. package/dist/workspace/points-cli.d.ts.map +1 -1
  35. package/dist/workspace/points-cli.js +16 -7
  36. package/dist/workspace/points-write.schema.json +39 -4
  37. package/dist/workspace/points.schema.json +42 -3
  38. package/dist/workspace/reason-codes.d.ts +2 -1
  39. package/dist/workspace/reason-codes.d.ts.map +1 -1
  40. package/dist/workspace/reason-codes.js +2 -1
  41. package/dist/workspace/records-cli.d.ts +12 -2
  42. package/dist/workspace/records-cli.d.ts.map +1 -1
  43. package/dist/workspace/records-cli.js +27 -7
  44. package/dist/workspace/records-write.d.ts.map +1 -1
  45. package/dist/workspace/records-write.js +2 -3
  46. package/dist/workspace/records.d.ts +10 -4
  47. package/dist/workspace/records.d.ts.map +1 -1
  48. package/dist/workspace/records.js +16 -3
  49. package/dist/workspace/records.schema.json +2 -1
  50. package/dist/workspace/trust/verify-cli.d.ts.map +1 -1
  51. package/dist/workspace/trust/verify-cli.js +2 -1
  52. package/dist/workspace/trust/verify.d.ts +22 -0
  53. package/dist/workspace/trust/verify.d.ts.map +1 -1
  54. package/dist/workspace/trust/verify.js +94 -14
  55. package/dist/workspace/write-scope.d.ts +3 -1
  56. package/dist/workspace/write-scope.d.ts.map +1 -1
  57. package/dist/workspace/write-scope.js +11 -4
  58. package/package.json +1 -1
  59. package/src/cli/compiled-cli.e2e.test.ts +45 -1
  60. package/src/cli/main.test.ts +10 -0
  61. package/src/cli/main.ts +21 -7
  62. package/src/cli/mcp/workspace-tools.e2e.test.ts +1 -1
  63. package/src/cli/mcp/workspace-tools.ts +27 -4
  64. package/src/effect-receipt.ts +22 -0
  65. package/src/lexicon-module.ts +9 -2
  66. package/src/lifecycle/receipt-plan.test.ts +9 -0
  67. package/src/lifecycle/receipt-plan.ts +4 -1
  68. package/src/op/effect-step.test.ts +95 -1
  69. package/src/op/local-executor.test.ts +65 -0
  70. package/src/op/local-executor.ts +68 -5
  71. package/src/op/receipt-store.ts +13 -3
  72. package/src/op/step-output-ref.test.ts +68 -24
  73. package/src/op/step-output-ref.ts +85 -65
  74. package/src/workspace/agent-cli.ts +2 -0
  75. package/src/workspace/conformance/__writer_fixture__/answers/answer.schema.json +16 -1
  76. package/src/workspace/conformance/writer.ts +1 -1
  77. package/src/workspace/decide.test.ts +87 -3
  78. package/src/workspace/decide.ts +142 -17
  79. package/src/workspace/lineage-upgrade.test.ts +21 -0
  80. package/src/workspace/lineage-upgrade.ts +19 -11
  81. package/src/workspace/point-answer.schema.json +16 -1
  82. package/src/workspace/points-cli.ts +16 -8
  83. package/src/workspace/points-write.schema.json +39 -4
  84. package/src/workspace/points.schema.json +42 -3
  85. package/src/workspace/reason-codes.ts +2 -1
  86. package/src/workspace/record-assets.test.ts +14 -0
  87. package/src/workspace/records-cli.ts +28 -7
  88. package/src/workspace/records-write-commands.e2e.test.ts +32 -0
  89. package/src/workspace/records-write.ts +2 -3
  90. package/src/workspace/records.schema.json +2 -1
  91. package/src/workspace/records.ts +17 -4
  92. package/src/workspace/trust/trust.test.ts +105 -0
  93. package/src/workspace/trust/verify-cli.ts +2 -1
  94. package/src/workspace/trust/verify.ts +106 -13
  95. package/src/workspace/write-scope.test.ts +18 -0
  96. package/src/workspace/write-scope.ts +16 -5
@@ -371,6 +371,24 @@ describe("chant workspace agent: what a session reloads from (#2548)", () => {
371
371
  agent.expectValid(doc);
372
372
  expect(code(doc)).toBe("agent-unknown");
373
373
  });
374
+
375
+ test("a declaration that fails validation is declaration-invalid, with the problem, not declaration-missing (#3433)", async () => {
376
+ const broken = JSON.stringify({ name: "studio", schema: 1, members: [{ name: "app", dir: "app" }], agents: AGENTS });
377
+ for (const committed of [false, true]) {
378
+ const dir = repo({ "chant.workspace.json": broken, "app/server.mjs": "export {};\n" }, committed);
379
+ if (committed) git(dir, "branch", "-M", "main");
380
+ const doc = await agentSession({ cwd: dir, name: "app-agent" });
381
+ agent.expectValid(doc);
382
+ expect(code(doc), committed ? "committed on main" : "uncommitted").toBe("declaration-invalid");
383
+ expect("error" in doc ? doc.error.message : "").toMatch(/kind/);
384
+ }
385
+ });
386
+
387
+ test("no declaration at all is still declaration-missing", async () => {
388
+ const doc = await agentSession({ cwd: repo({ "app/server.mjs": "export {};\n" }), name: "app-agent" });
389
+ agent.expectValid(doc);
390
+ expect(code(doc)).toBe("declaration-missing");
391
+ });
374
392
  });
375
393
 
376
394
  describe("principal classes a plugin defines (#3080)", () => {
@@ -352,18 +352,28 @@ export interface ScopeSource {
352
352
  policy: TrustPolicy;
353
353
  /** The principal classes: the core four and those the declaration's pins supply, path pins read where the declaration was (#3080). */
354
354
  classes: ClassRegistry;
355
+ /** Why the working tree's declaration couldn't be read when `declaration` is null: declaration-missing, or declaration-invalid with the problem (#3433). */
356
+ failure?: WorkspaceReadError;
355
357
  }
356
358
 
357
- function readAt(cwd: string, at?: string): { declaration: Declaration; rootOnDisk: string; root: string; tree: WorkspaceTree } | null {
359
+ type ReadAt = { declaration: Declaration; rootOnDisk: string; root: string; tree: WorkspaceTree };
360
+
361
+ /** The declaration at `at` (the working tree without it), or the read error that says why there is none. */
362
+ function readOrFailure(cwd: string, at?: string): ReadAt | WorkspaceReadError {
358
363
  try {
359
364
  const located = locateWorkspace(cwd, at);
360
365
  return { declaration: readDeclaration(located.tree), rootOnDisk: located.rootOnDisk, root: located.root, tree: located.tree };
361
366
  } catch (err) {
362
- if (err instanceof WorkspaceReadError) return null;
367
+ if (err instanceof WorkspaceReadError) return err;
363
368
  throw err;
364
369
  }
365
370
  }
366
371
 
372
+ function readAt(cwd: string, at?: string): ReadAt | null {
373
+ const read = readOrFailure(cwd, at);
374
+ return read instanceof WorkspaceReadError ? null : read;
375
+ }
376
+
367
377
  /**
368
378
  * The scope for a write from `cwd`: the declaration and the trust policy at
369
379
  * the base revision (`origin/HEAD`, `main` or `master`), so a write can't
@@ -375,7 +385,7 @@ export function scopeSource(cwd: string, at?: string): ScopeSource {
375
385
  const top = gitRoot(cwd);
376
386
  const base = top ? resolveBase(top, at) : null;
377
387
  const policy = top && base ? policyAtBase(top, base) : emptyPolicy(null);
378
- const withClasses = (read: NonNullable<ReturnType<typeof readAt>>) => {
388
+ const withClasses = (read: ReadAt) => {
379
389
  const { tree, ...rest } = read;
380
390
  return { ...rest, classes: loadClassRegistry(read.declaration.pins, read.rootOnDisk, { tree }).registry };
381
391
  };
@@ -383,8 +393,9 @@ export function scopeSource(cwd: string, at?: string): ScopeSource {
383
393
  const atBase = readAt(cwd, base.commit);
384
394
  if (atBase) return { ...withClasses(atBase), from: "base", policy };
385
395
  }
386
- const here = readAt(cwd);
387
- return here ? { ...withClasses(here), from: "working-tree", policy } : { declaration: null, from: null, rootOnDisk: null, root: null, policy, classes: coreClassRegistry() };
396
+ const here = readOrFailure(cwd);
397
+ if (here instanceof WorkspaceReadError) return { declaration: null, from: null, rootOnDisk: null, root: null, policy, classes: coreClassRegistry(), failure: here };
398
+ return { ...withClasses(here), from: "working-tree", policy };
388
399
  }
389
400
 
390
401
  const toPosix = (p: string) => (sep === "/" ? p : p.split(sep).join("/"));