@intentius/chant 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.
Files changed (164) hide show
  1. package/dist/cli/handlers/components.d.ts +8 -0
  2. package/dist/cli/handlers/components.d.ts.map +1 -1
  3. package/dist/cli/handlers/operator.d.ts +14 -0
  4. package/dist/cli/handlers/operator.d.ts.map +1 -1
  5. package/dist/cli/handlers/run.d.ts.map +1 -1
  6. package/dist/cli/main.d.ts.map +1 -1
  7. package/dist/cli/mcp/workspace-tools.d.ts +6 -4
  8. package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
  9. package/dist/cli/registry.d.ts +31 -0
  10. package/dist/cli/registry.d.ts.map +1 -1
  11. package/dist/components/verbs/vuln-scan.d.ts +72 -0
  12. package/dist/components/verbs/vuln-scan.d.ts.map +1 -1
  13. package/dist/lifecycle/git.d.ts +40 -5
  14. package/dist/lifecycle/git.d.ts.map +1 -1
  15. package/dist/lifecycle/lease.d.ts +72 -16
  16. package/dist/lifecycle/lease.d.ts.map +1 -1
  17. package/dist/lifecycle/member-ledger.d.ts +3 -2
  18. package/dist/lifecycle/member-ledger.d.ts.map +1 -1
  19. package/dist/lifecycle/plan-ledger.d.ts +114 -0
  20. package/dist/lifecycle/plan-ledger.d.ts.map +1 -0
  21. package/dist/lifecycle/work-lease.d.ts +140 -0
  22. package/dist/lifecycle/work-lease.d.ts.map +1 -0
  23. package/dist/op/activities/activity-contracts.d.ts +2 -2
  24. package/dist/op/builders.d.ts.map +1 -1
  25. package/dist/op/discover.d.ts +25 -0
  26. package/dist/op/discover.d.ts.map +1 -1
  27. package/dist/op/index.d.ts +9 -3
  28. package/dist/op/index.d.ts.map +1 -1
  29. package/dist/op/lifecycle-receipt-store.d.ts +34 -0
  30. package/dist/op/lifecycle-receipt-store.d.ts.map +1 -0
  31. package/dist/op/local-executor.d.ts +19 -0
  32. package/dist/op/local-executor.d.ts.map +1 -1
  33. package/dist/op/local-output.d.ts.map +1 -1
  34. package/dist/op/op-ir.d.ts +10 -1
  35. package/dist/op/op-ir.d.ts.map +1 -1
  36. package/dist/op/operator.d.ts +29 -0
  37. package/dist/op/operator.d.ts.map +1 -1
  38. package/dist/op/runtime.d.ts +9 -0
  39. package/dist/op/runtime.d.ts.map +1 -1
  40. package/dist/op/runtimes/local.d.ts.map +1 -1
  41. package/dist/op/step-output-ref.d.ts +2 -2
  42. package/dist/op/step-output-ref.d.ts.map +1 -1
  43. package/dist/op/steward.d.ts +140 -0
  44. package/dist/op/steward.d.ts.map +1 -0
  45. package/dist/op/types.d.ts +51 -0
  46. package/dist/op/types.d.ts.map +1 -1
  47. package/dist/op/work-lease-decl.d.ts +18 -0
  48. package/dist/op/work-lease-decl.d.ts.map +1 -0
  49. package/dist/op/work-lease-run.d.ts +173 -0
  50. package/dist/op/work-lease-run.d.ts.map +1 -0
  51. package/dist/workspace/box-isolation.d.ts +99 -0
  52. package/dist/workspace/box-isolation.d.ts.map +1 -0
  53. package/dist/workspace/checks/box-isolation.d.ts +18 -0
  54. package/dist/workspace/checks/box-isolation.d.ts.map +1 -0
  55. package/dist/workspace/checks/boxes.d.ts +71 -0
  56. package/dist/workspace/checks/boxes.d.ts.map +1 -0
  57. package/dist/workspace/checks/records.d.ts +1 -0
  58. package/dist/workspace/checks/records.d.ts.map +1 -1
  59. package/dist/workspace/checks.d.ts +10 -1
  60. package/dist/workspace/checks.d.ts.map +1 -1
  61. package/dist/workspace/decide.d.ts +184 -0
  62. package/dist/workspace/decide.d.ts.map +1 -0
  63. package/dist/workspace/decision-points.schema.json +137 -0
  64. package/dist/workspace/declaration.d.ts +51 -0
  65. package/dist/workspace/declaration.d.ts.map +1 -1
  66. package/dist/workspace/declaration.schema.json +172 -0
  67. package/dist/workspace/declared-kinds.d.ts +12 -0
  68. package/dist/workspace/declared-kinds.d.ts.map +1 -1
  69. package/dist/workspace/points-cli.d.ts +113 -0
  70. package/dist/workspace/points-cli.d.ts.map +1 -0
  71. package/dist/workspace/points.d.ts +320 -0
  72. package/dist/workspace/points.d.ts.map +1 -0
  73. package/dist/workspace/reason-codes.d.ts +26 -0
  74. package/dist/workspace/reason-codes.d.ts.map +1 -1
  75. package/dist/workspace/record-assets.d.ts.map +1 -1
  76. package/dist/workspace/records-cli.d.ts +12 -0
  77. package/dist/workspace/records-cli.d.ts.map +1 -1
  78. package/dist/workspace/records.d.ts +8 -2
  79. package/dist/workspace/records.d.ts.map +1 -1
  80. package/dist/workspace/status-stewards.d.ts +121 -0
  81. package/dist/workspace/status-stewards.d.ts.map +1 -0
  82. package/dist/workspace/status.d.ts +52 -1
  83. package/dist/workspace/status.d.ts.map +1 -1
  84. package/dist/workspace/work-cli.d.ts +78 -0
  85. package/dist/workspace/work-cli.d.ts.map +1 -0
  86. package/package.json +1 -1
  87. package/src/cli/handlers/components.test.ts +93 -0
  88. package/src/cli/handlers/components.ts +44 -3
  89. package/src/cli/handlers/operator.ts +107 -2
  90. package/src/cli/handlers/run.test.ts +19 -0
  91. package/src/cli/handlers/run.ts +53 -1
  92. package/src/cli/main.test.ts +40 -0
  93. package/src/cli/main.ts +78 -2
  94. package/src/cli/mcp/workspace-tools.test.ts +14 -1
  95. package/src/cli/mcp/workspace-tools.ts +49 -5
  96. package/src/cli/registry.ts +31 -0
  97. package/src/components/verbs/vuln-scan.test.ts +124 -1
  98. package/src/components/verbs/vuln-scan.ts +142 -1
  99. package/src/lifecycle/git.ts +65 -15
  100. package/src/lifecycle/lease.test.ts +22 -0
  101. package/src/lifecycle/lease.ts +133 -29
  102. package/src/lifecycle/member-ledger.ts +3 -2
  103. package/src/lifecycle/plan-ledger.test.ts +148 -0
  104. package/src/lifecycle/plan-ledger.ts +158 -0
  105. package/src/lifecycle/work-lease.test.ts +236 -0
  106. package/src/lifecycle/work-lease.ts +426 -0
  107. package/src/op/builders.ts +5 -0
  108. package/src/op/discover.ts +71 -0
  109. package/src/op/index.ts +16 -3
  110. package/src/op/lifecycle-receipt-store.test.ts +60 -0
  111. package/src/op/lifecycle-receipt-store.ts +61 -0
  112. package/src/op/local-executor.ts +216 -18
  113. package/src/op/local-output.ts +13 -0
  114. package/src/op/op-ir.ts +14 -0
  115. package/src/op/operator.ts +75 -4
  116. package/src/op/runtime.ts +6 -0
  117. package/src/op/runtimes/local.ts +3 -0
  118. package/src/op/step-output-ref.ts +6 -2
  119. package/src/op/steward.test.ts +212 -0
  120. package/src/op/steward.ts +253 -0
  121. package/src/op/types.ts +53 -0
  122. package/src/op/work-lease-decl.ts +80 -0
  123. package/src/op/work-lease-run.test.ts +326 -0
  124. package/src/op/work-lease-run.ts +395 -0
  125. package/src/workspace/box-isolation.test.ts +261 -0
  126. package/src/workspace/box-isolation.ts +205 -0
  127. package/src/workspace/check-contract.test.ts +3 -1
  128. package/src/workspace/check.schema.json +15 -7
  129. package/src/workspace/checks/box-isolation.ts +68 -0
  130. package/src/workspace/checks/boxes.test.ts +197 -0
  131. package/src/workspace/checks/boxes.ts +307 -0
  132. package/src/workspace/checks/records.ts +25 -0
  133. package/src/workspace/checks.test.ts +7 -0
  134. package/src/workspace/checks.ts +19 -2
  135. package/src/workspace/decide.test.ts +224 -0
  136. package/src/workspace/decide.ts +576 -0
  137. package/src/workspace/decision-points.schema.json +137 -0
  138. package/src/workspace/declaration.schema.json +172 -0
  139. package/src/workspace/declaration.ts +137 -0
  140. package/src/workspace/declared-kinds.ts +25 -2
  141. package/src/workspace/intent.schema.json +4 -1
  142. package/src/workspace/point-answer.schema.json +95 -0
  143. package/src/workspace/points-cli.ts +273 -0
  144. package/src/workspace/points-write.schema.json +489 -0
  145. package/src/workspace/points.schema.json +710 -0
  146. package/src/workspace/points.test.ts +264 -0
  147. package/src/workspace/points.ts +564 -0
  148. package/src/workspace/read-contract.test.ts +18 -1
  149. package/src/workspace/reason-codes.test.ts +14 -1
  150. package/src/workspace/reason-codes.ts +33 -0
  151. package/src/workspace/record-assets.test.ts +3 -2
  152. package/src/workspace/record-assets.ts +4 -1
  153. package/src/workspace/records-cli.ts +15 -2
  154. package/src/workspace/records-contract.test.ts +3 -2
  155. package/src/workspace/records.schema.json +17 -0
  156. package/src/workspace/records.ts +33 -3
  157. package/src/workspace/status-contract.test.ts +178 -0
  158. package/src/workspace/status-stewards.ts +225 -0
  159. package/src/workspace/status.schema.json +230 -4
  160. package/src/workspace/status.ts +106 -5
  161. package/src/workspace/work-cli.test.ts +180 -0
  162. package/src/workspace/work-cli.ts +246 -0
  163. package/src/workspace/work-lease.schema.json +233 -0
  164. package/src/workspace/work-readiness-chud.test.ts +145 -0
@@ -0,0 +1,233 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://intentius.io/chant/schemas/workspace/work-lease/v1/work-lease.schema.json",
4
+ "title": "chant workspace work output",
5
+ "description": "What `chant workspace work claim|renew|release <id> --holder <name> --json` prints (#2732, ws-055): the work lease it wrote, the reason it was refused, or the reason the command could not run. Version 1 of the write contract for work leases. The lease is the ref refs/chant/lease/[_members/<member>/]work/<id>; each write also appends to _leases/<id>.jsonl on chant/lifecycle. Readers ignore fields they do not know; a field is only ever added within a version. The refusal and error codes are closed lists, each in the one closed list of `reason-codes.ts`.",
6
+ "oneOf": [
7
+ {
8
+ "$ref": "#/$defs/result"
9
+ },
10
+ {
11
+ "$ref": "#/$defs/refusal"
12
+ },
13
+ {
14
+ "$ref": "#/$defs/failure"
15
+ }
16
+ ],
17
+ "$defs": {
18
+ "lease": {
19
+ "type": "object",
20
+ "required": [
21
+ "holder",
22
+ "token",
23
+ "acquiredAt",
24
+ "expiresAt"
25
+ ],
26
+ "properties": {
27
+ "holder": {
28
+ "type": "string",
29
+ "description": "Who holds the lease, as --holder gave it."
30
+ },
31
+ "token": {
32
+ "type": "string",
33
+ "description": "The fencing token: new on every claim, kept by every renew."
34
+ },
35
+ "acquiredAt": {
36
+ "type": "string",
37
+ "description": "When the lease was claimed, ISO 8601."
38
+ },
39
+ "expiresAt": {
40
+ "type": "string",
41
+ "description": "When the lease expires unless renewed, ISO 8601."
42
+ }
43
+ }
44
+ },
45
+ "result": {
46
+ "description": "The lease was written. Exit code 0.",
47
+ "type": "object",
48
+ "required": [
49
+ "$schema",
50
+ "contract",
51
+ "item",
52
+ "event",
53
+ "kind",
54
+ "ref",
55
+ "lease",
56
+ "history"
57
+ ],
58
+ "properties": {
59
+ "$schema": {
60
+ "const": "https://intentius.io/chant/schemas/workspace/work-lease/v1/work-lease.schema.json"
61
+ },
62
+ "contract": {
63
+ "const": 1
64
+ },
65
+ "item": {
66
+ "type": "string",
67
+ "description": "The work item's id."
68
+ },
69
+ "event": {
70
+ "enum": [
71
+ "claim",
72
+ "renew",
73
+ "release"
74
+ ]
75
+ },
76
+ "kind": {
77
+ "type": "string",
78
+ "description": "The work kind file, relative to the repository root, with / separators."
79
+ },
80
+ "ref": {
81
+ "type": "string",
82
+ "description": "The lease ref, in the ledger of the member owning the work kind."
83
+ },
84
+ "lease": {
85
+ "description": "The lease after a claim or renew; the lease that was given back after a release.",
86
+ "$ref": "#/$defs/lease"
87
+ },
88
+ "history": {
89
+ "type": "object",
90
+ "required": [
91
+ "path",
92
+ "commit",
93
+ "pushed"
94
+ ],
95
+ "properties": {
96
+ "path": {
97
+ "type": "string",
98
+ "description": "The history file on chant/lifecycle, _leases/<id>.jsonl under the member's prefix."
99
+ },
100
+ "commit": {
101
+ "type": "string",
102
+ "description": "The chant/lifecycle commit that appended the line."
103
+ },
104
+ "pushed": {
105
+ "type": "boolean",
106
+ "description": "Whether chant/lifecycle reached the remote. False with no remote, and when the remote refused it; the lease stands either way."
107
+ }
108
+ }
109
+ },
110
+ "refused": false,
111
+ "error": false
112
+ }
113
+ },
114
+ "refusal": {
115
+ "description": "The lease was refused. Exit code 2. Nothing was written.",
116
+ "type": "object",
117
+ "required": [
118
+ "$schema",
119
+ "contract",
120
+ "item",
121
+ "event",
122
+ "kind",
123
+ "ref",
124
+ "refused"
125
+ ],
126
+ "properties": {
127
+ "$schema": {
128
+ "const": "https://intentius.io/chant/schemas/workspace/work-lease/v1/work-lease.schema.json"
129
+ },
130
+ "contract": {
131
+ "const": 1
132
+ },
133
+ "item": {
134
+ "type": "string",
135
+ "description": "The work item's id."
136
+ },
137
+ "event": {
138
+ "enum": [
139
+ "claim",
140
+ "renew",
141
+ "release"
142
+ ]
143
+ },
144
+ "kind": {
145
+ "type": "string",
146
+ "description": "The work kind file, relative to the repository root, with / separators."
147
+ },
148
+ "ref": {
149
+ "type": "string",
150
+ "description": "The lease ref, in the ledger of the member owning the work kind."
151
+ },
152
+ "refused": {
153
+ "type": "object",
154
+ "required": [
155
+ "code",
156
+ "message",
157
+ "heldBy"
158
+ ],
159
+ "properties": {
160
+ "code": {
161
+ "enum": [
162
+ "lease-held",
163
+ "lease-not-held",
164
+ "lease-token-mismatch",
165
+ "lease-race",
166
+ "lease-push-rejected"
167
+ ]
168
+ },
169
+ "message": {
170
+ "type": "string",
171
+ "description": "Names the holder when someone holds the lease."
172
+ },
173
+ "heldBy": {
174
+ "description": "The live lease, when there is one.",
175
+ "oneOf": [
176
+ {
177
+ "type": "null"
178
+ },
179
+ {
180
+ "$ref": "#/$defs/lease"
181
+ }
182
+ ]
183
+ }
184
+ }
185
+ },
186
+ "lease": false,
187
+ "error": false
188
+ }
189
+ },
190
+ "failure": {
191
+ "description": "The command could not run. Exit code 1. Nothing was written.",
192
+ "type": "object",
193
+ "required": [
194
+ "$schema",
195
+ "contract",
196
+ "error"
197
+ ],
198
+ "properties": {
199
+ "$schema": {
200
+ "const": "https://intentius.io/chant/schemas/workspace/work-lease/v1/work-lease.schema.json"
201
+ },
202
+ "contract": {
203
+ "const": 1
204
+ },
205
+ "error": {
206
+ "type": "object",
207
+ "required": [
208
+ "code",
209
+ "message"
210
+ ],
211
+ "properties": {
212
+ "code": {
213
+ "enum": [
214
+ "write-usage-invalid",
215
+ "kind-unreadable",
216
+ "work-kind-missing",
217
+ "work-kind-ambiguous",
218
+ "work-item-unknown",
219
+ "work-item-closed",
220
+ "not-a-git-repository"
221
+ ]
222
+ },
223
+ "message": {
224
+ "type": "string"
225
+ }
226
+ }
227
+ },
228
+ "lease": false,
229
+ "refused": false
230
+ }
231
+ }
232
+ }
233
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The work kind's `ready`/`blockedBy` against chud's ready queue (ws-055,
3
+ * #2734).
4
+ *
5
+ * chud's `readyQueue` (packages/runtime/src/ready.mjs at jhgaylor/chud
6
+ * 43afcf1) puts a contract in the ready set once it is approved and in
7
+ * force, every `depends_on` id is `met` (drivers.mjs's `memberState`), and no
8
+ * unit is open against it; a contract that is itself met leaves the queue.
9
+ *
10
+ * Of those rules, the work kind's `ready` and `blockedBy` (work.ts) can
11
+ * express two directly, with no new field:
12
+ *
13
+ * - dependencies closed: a work item's `needs` id counts as closed once its
14
+ * `state` is the kind's `done` state, same as `depends_on` counts a
15
+ * dependency closed once it is `met`. A `needs` id that never reaches
16
+ * `done` (here, one that is `dropped`) blocks forever, the same way a
17
+ * retired contract does.
18
+ * - a record that is itself already `done` (or `dropped`, or merely
19
+ * `in-progress`) is not `ready`: `ready` requires `state === "open"`, the
20
+ * same "already met/already running leaves the queue" rule ready.mjs
21
+ * states for a contract that is itself met.
22
+ *
23
+ * The rules ready.mjs adds on top -- approval before a dependency counts
24
+ * (memberState's draft/failing cases), re-checking that a `met` dependency's
25
+ * newest evidence still passes, and refusing a contract while a unit is open
26
+ * against it -- have no equivalent in a `needs` link. The full table of
27
+ * every ready.mjs rule and its home (a `needs` link, the runner, or "not
28
+ * applicable") is on INTENTIUS/chant#2734.
29
+ *
30
+ * This fixture mirrors a small chud contract graph as work items and checks
31
+ * `queryRecords`'s `ready`/`blockedBy` against a minimal, local
32
+ * re-implementation of the expressible subset of ready.mjs's rule (met
33
+ * depends_on, self not already met), so a regression in either the work
34
+ * kind's readiness formula or this reading of ready.mjs's rule shows up as a
35
+ * mismatch.
36
+ */
37
+
38
+ import { readFileSync } from "node:fs";
39
+ import { join } from "node:path";
40
+ import { afterAll, beforeAll, describe, expect, test } from "vitest";
41
+ import { cleanScratch, REPO, repo } from "./__fixtures__/contract-repo";
42
+ import { queryRecords } from "./records-cli";
43
+
44
+ const REF = join(REPO, "reference-workspace");
45
+ const WORK = "work/work.kind.mjs";
46
+
47
+ function work(id: string, fields: Record<string, unknown>): string {
48
+ const data = {
49
+ schema: 1,
50
+ id,
51
+ title: `Work ${id}`,
52
+ state: "open",
53
+ implements: [],
54
+ needs: [],
55
+ constrains: ["member:app"],
56
+ evidence: [],
57
+ opened_on: "2026-09-24",
58
+ source: { kind: "workspace", member: "app" },
59
+ supersedes: [],
60
+ ...fields,
61
+ };
62
+ return `---\n${JSON.stringify(data, null, 2)}\n---\n\n# ${id}\n`;
63
+ }
64
+
65
+ /**
66
+ * The expressible subset of ready.mjs's rule, on a graph shaped like
67
+ * `depends_on`: ready once the item is `open` (not already met, not already
68
+ * running) and every dependency is `done` (chud's "met"). A dependency that
69
+ * is `dropped` never becomes done, so it blocks forever -- the same effect
70
+ * ready.mjs gets from a retired dependency.
71
+ */
72
+ function chudReadyIsh(items: { id: string; state: string; needs: string[] }[]): { ready: Set<string>; blockedBy: Map<string, string[]> } {
73
+ const stateOf = new Map(items.map((i) => [i.id, i.state]));
74
+ const ready = new Set<string>();
75
+ const blockedBy = new Map<string, string[]>();
76
+ for (const item of items) {
77
+ const unmet = item.needs.filter((id) => stateOf.get(id) !== "done");
78
+ blockedBy.set(item.id, unmet);
79
+ if (item.state === "open" && unmet.length === 0) ready.add(item.id);
80
+ }
81
+ return { ready, blockedBy };
82
+ }
83
+
84
+ let root: string;
85
+
86
+ beforeAll(() => {
87
+ root = repo({
88
+ "chant.workspace.json": JSON.stringify({ name: "w", schema: 1, members: [] }, null, 2),
89
+ "decisions/decision.kind.mjs": readFileSync(join(REF, "decisions", "decision.kind.mjs"), "utf-8"),
90
+ "decisions/decision.schema.json": readFileSync(join(REF, "decisions", "decision.schema.json"), "utf-8"),
91
+ "work/work.kind.mjs": readFileSync(join(REF, "work", "work.kind.mjs"), "utf-8"),
92
+ "work/work.schema.json": readFileSync(join(REF, "work", "work.schema.json"), "utf-8"),
93
+ // W-001: already done, so it leaves the ready queue -- ready.mjs's "a
94
+ // contract that is itself met is done, not ready".
95
+ "work/W-001-base.md": work("W-001", { state: "done", closed_on: "2026-09-24", evidence: [{ title: "shipped", url: "https://example.com/w1" }] }),
96
+ // W-002: needs W-001, which is done -- both rules agree this is ready.
97
+ "work/W-002-after-base.md": work("W-002", { needs: ["W-001"] }),
98
+ // W-003: needs W-004, which is dropped and so never turns done -- blocked
99
+ // forever, the same as a retired dependency in ready.mjs.
100
+ "work/W-003-needs-dropped.md": work("W-003", { needs: ["W-004"] }),
101
+ "work/W-004-dropped.md": work("W-004", { state: "dropped", closed_on: "2026-09-24" }),
102
+ // W-005: needs W-002, which is open (not done yet) -- blocked.
103
+ "work/W-005-needs-open.md": work("W-005", { needs: ["W-002"] }),
104
+ // W-006: already in-progress -- not ready, the same "already running"
105
+ // leaves-the-queue rule as a met contract with an open unit does not
106
+ // apply here in the same way, but "not open, so not ready" is shared.
107
+ "work/W-006-in-progress.md": work("W-006", { state: "in-progress" }),
108
+ // W-007: needs W-006, which is in-progress, not done -- blocked.
109
+ "work/W-007-needs-in-progress.md": work("W-007", { needs: ["W-006"] }),
110
+ });
111
+ });
112
+ afterAll(cleanScratch);
113
+
114
+ describe("work kind ready/blockedBy vs. chud's ready queue, expressible rules (#2734)", () => {
115
+ test("matches on every item, for the rules a needs link can express", async () => {
116
+ const doc = await queryRecords({ kind: WORK, cwd: root });
117
+ if ("error" in doc) throw new Error(doc.error.message);
118
+ expect(doc.summary).toEqual({ total: 7, valid: 7, invalid: 0, superseded: 0 });
119
+
120
+ const items = doc.records.map((r) => ({ id: r.id!, state: r.state!, needs: (r.data as { needs?: string[] }).needs ?? [] }));
121
+ const chud = chudReadyIsh(items);
122
+
123
+ for (const r of doc.records) {
124
+ const id = r.id!;
125
+ expect(r.ready, `${id}.ready`).toBe(chud.ready.has(id));
126
+ expect(
127
+ (r.blockedBy ?? []).map((b) => b.id),
128
+ `${id}.blockedBy`,
129
+ ).toEqual(chud.blockedBy.get(id));
130
+ }
131
+ });
132
+
133
+ test("individually: done leaves the queue, a dropped need blocks forever, an in-progress need still blocks", async () => {
134
+ const doc = await queryRecords({ kind: WORK, cwd: root });
135
+ if ("error" in doc) throw new Error(doc.error.message);
136
+ const by = Object.fromEntries(doc.records.map((r) => [r.id, r]));
137
+
138
+ expect(by["W-001"]).toMatchObject({ ready: false, blockedBy: [] }); // done: no longer ready
139
+ expect(by["W-002"]).toMatchObject({ ready: true, blockedBy: [] }); // needs W-001, which is done
140
+ expect(by["W-003"]).toMatchObject({ ready: false, blockedBy: [{ id: "W-004", state: "dropped" }] }); // needs a dropped item: blocked forever
141
+ expect(by["W-005"]).toMatchObject({ ready: false, blockedBy: [{ id: "W-002", state: "open" }] }); // needs an open (not yet done) item
142
+ expect(by["W-006"]).toMatchObject({ ready: false, blockedBy: [] }); // in-progress: not ready, but not "blocked" either
143
+ expect(by["W-007"]).toMatchObject({ ready: false, blockedBy: [{ id: "W-006", state: "in-progress" }] });
144
+ });
145
+ });