joycraft 1.2.2 → 1.4.1
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/README.md +123 -57
- package/dist/joycraft-release.json +1 -1
- package/package.json +3 -3
- package/payload/.agents/skills/joycraft-context/SKILL.md +5 -6
- package/payload/.agents/skills/joycraft-entry/SKILL.md +15 -20
- package/payload/.agents/skills/joycraft-implement/SKILL.md +8 -10
- package/payload/.agents/skills/joycraft-session-end/SKILL.md +8 -13
- package/payload/.agents/skills/joycraft-testing/SKILL.md +0 -6
- package/payload/.agents/skills/joycraft-verify/SKILL.md +5 -8
- package/payload/.joycraft/references/architecture.md +2 -4
- package/payload/.joycraft/references/context.md +11 -34
- package/payload/.joycraft/references/dispatch.md +7 -40
- package/payload/.joycraft/references/gates.md +60 -0
- package/payload/.joycraft/references/retro.md +6 -15
- package/payload/.joycraft/references/settings.md +60 -0
- package/payload/.joycraft/references/setup.md +4 -4
- package/payload/.joycraft/references/worktrees.md +1 -1
- package/payload/.joycraft/runtime/dispatch-start.mjs +61 -4
- package/payload/.joycraft/runtime/gate.mjs +308 -0
- package/payload/.joycraft/runtime/status.mjs +1 -1
- package/payload/PIN +20 -17
- package/payload/scripts/export.mjs +5 -2
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
For normal native work, the host launches the worker and the child then uses the
|
|
4
4
|
dispatch-start entry point from its actual root before any tasked edit. A
|
|
5
5
|
coordinator uses it itself only when it is the worker actor. It validates delivery
|
|
6
|
-
and returns a ready
|
|
7
|
-
|
|
6
|
+
and returns a ready decision plus the bounded packet; it never launches a worker,
|
|
7
|
+
alters queue status, or accepts work.
|
|
8
8
|
For a mutable worker or stateful runtime check, first apply the conditional
|
|
9
9
|
[worker-isolation policy](worktrees.md); this preflight does not create a
|
|
10
10
|
worktree or a resource lease. A `read-only` workspace keeps declared source
|
|
@@ -18,7 +18,6 @@ those specs with `accept-waiver` instead.
|
|
|
18
18
|
|
|
19
19
|
- [Start a native dispatch](#start-a-native-dispatch)
|
|
20
20
|
- [Call the portable dispatch API](#call-the-portable-dispatch-api)
|
|
21
|
-
- [Bind the hook source view](#bind-the-hook-source-view)
|
|
22
21
|
- [Validate capabilities before dispatch](#validate-capabilities-before-dispatch)
|
|
23
22
|
- [Check the reviewer report](#check-the-reviewer-report)
|
|
24
23
|
|
|
@@ -90,6 +89,7 @@ it before the first implementer mutation, and startup preserves it. The separate
|
|
|
90
89
|
workspace `--base-revision` option keeps its documented topology check.
|
|
91
90
|
Implementer dispatch requires each dependency to be `done`; reviewer dispatch
|
|
92
91
|
does not require the target itself to be done. Unknown roles are rejected.
|
|
92
|
+
Reviewer startup prints `reviewRound` and `reviewLimit: 3`; a round is one distinct set of reviewed inputs, so a commit that changes none of the spec's verification inputs keeps the round, and a fourth round exits 2.
|
|
93
93
|
|
|
94
94
|
When a reviewer startup exits non-zero or returns `ready: false`, run it once
|
|
95
95
|
more, alone, with a fresh packet path. If it fails again, stop that spec's
|
|
@@ -101,17 +101,8 @@ cause and the repair it tried. The coordinator tells the user at the first hold,
|
|
|
101
101
|
in the conversation, while other workers keep running; it does not wait for the
|
|
102
102
|
session end. The session-end summary lists every held spec again.
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
prompt history for an enforced startup is explicit
|
|
107
|
-
`ready: false`, exit code 2, and `unenforced`; it is not a permission request,
|
|
108
|
-
an invented prompt, or a substitute session ID. Continue discovery and other
|
|
109
|
-
unrelated authorized work, including manual/disabled workflows, but do not
|
|
110
|
-
dispatch the claimed enforced worker. Do not
|
|
111
|
-
select an arbitrary task to make a native relationship appear valid. A child
|
|
112
|
-
binding uses its own root and a real prompt; it may inherit the same native
|
|
113
|
-
parent session authority only when an observed linked coordinator relationship
|
|
114
|
-
is valid. A unique new root session needs its own actual prompt.
|
|
104
|
+
A valid startup returns `hooks: { enabled: false, reason: "hooks-not-installed" }`
|
|
105
|
+
and `ready: true`. It is not a cryptographic attestation.
|
|
115
106
|
|
|
116
107
|
When the host reports a native agent/invocation ID, also pass
|
|
117
108
|
`--implementer-host <host> --implementer-agent <actual-agent-id>`. For a root
|
|
@@ -142,8 +133,8 @@ from a legacy self-attested call.
|
|
|
142
133
|
|
|
143
134
|
Call the portable API from a Codex, Claude, Pi, OMP, or Copilot adapter. Normal
|
|
144
135
|
native startup calls `startDispatch(options, nativeEvent)` so the runtime can
|
|
145
|
-
validate the observed session
|
|
146
|
-
|
|
136
|
+
validate the observed session and agent relationship before it returns a
|
|
137
|
+
packet:
|
|
147
138
|
|
|
148
139
|
```js
|
|
149
140
|
import { startDispatch } from './.joycraft/runtime/dispatch-start.mjs';
|
|
@@ -171,30 +162,6 @@ When `AGENTS.md` has a `## Review loop` section or this machine has
|
|
|
171
162
|
`{ path, section, local? }`, the shared section plus, when present,
|
|
172
163
|
`local: { path, record }` with this machine's host tools.
|
|
173
164
|
|
|
174
|
-
## Bind the hook source view
|
|
175
|
-
|
|
176
|
-
Dispatch-start prepares and binds its hash-bound `hookSourceView` with actual
|
|
177
|
-
native IDs. The lower-level manual bind command remains only for an explicit
|
|
178
|
-
non-native boundary. It uses the actual native session ID reported at startup,
|
|
179
|
-
never a generated UUID:
|
|
180
|
-
|
|
181
|
-
```sh
|
|
182
|
-
node .joycraft/runtime/hooks/cli.mjs bind-source \
|
|
183
|
-
--session <actual-native-session-id> --packet <project-relative-packet.json>
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
Bind a known parent session before launching children when the host exposes
|
|
187
|
-
parent inheritance. Otherwise, bind the child after it reports its own actual
|
|
188
|
-
session ID. For children sharing a parent session but working on different
|
|
189
|
-
specs, add `--agent <actual-native-child-id>` when binding each child. Its task
|
|
190
|
-
view remains separate while human prompts still inherit from the parent.
|
|
191
|
-
Rebind after the brief changes. The hook view currently receives only
|
|
192
|
-
hash-checked brief and decision pointers; the worker packet retains the exact
|
|
193
|
-
decision records. An unknown ID leaves the dependent
|
|
194
|
-
Jev check advisory and unverified; it does not permit a substitute ID. The view
|
|
195
|
-
makes selected saved answers available to Jev, but never grants permission or
|
|
196
|
-
an expected review outcome.
|
|
197
|
-
|
|
198
165
|
## Validate capabilities before dispatch
|
|
199
166
|
|
|
200
167
|
`claims.capabilities` must include `filesystem:read`,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Gates
|
|
2
|
+
|
|
3
|
+
Joycraft's rule is that only an accepted review completes a spec. The gate
|
|
4
|
+
check makes the rule a command, so it does not depend on the agent.
|
|
5
|
+
|
|
6
|
+
## What the gate checks
|
|
7
|
+
|
|
8
|
+
`node .joycraft/runtime/gate.mjs check` exits 2 and names each problem on
|
|
9
|
+
stderr. Each message names its next step:
|
|
10
|
+
|
|
11
|
+
- a `done` spec with no accepted report, owner acceptance or waiver: set it
|
|
12
|
+
back to `in-review`, get an independent review, then run the completing
|
|
13
|
+
command that the message names;
|
|
14
|
+
- a spec whose queue status and frontmatter status are different: pending
|
|
15
|
+
journal: run the named `recover` command, stop on a conflict; accepted: run
|
|
16
|
+
`node .joycraft/runtime/status.mjs --fix`; unaccepted `done`: the step above
|
|
17
|
+
first; else set the frontmatter to the queue's status and tell the user;
|
|
18
|
+
- a current queue or spec file that does not parse: repair it and tell the user.
|
|
19
|
+
|
|
20
|
+
A spec held at `in-review` is never a problem. Queues older than
|
|
21
|
+
`schemaVersion: 1` are skipped. With no problem, it exits 0 and prints nothing.
|
|
22
|
+
Any agent can run the check, and the session-end skill runs it. Without a hook,
|
|
23
|
+
that step depends on the agent.
|
|
24
|
+
|
|
25
|
+
## The Stop hook
|
|
26
|
+
|
|
27
|
+
The hook is for Claude Code only for now. When it is on, Claude Code runs the
|
|
28
|
+
gate check each time it is about to stop. On exit 2, Claude Code gives the
|
|
29
|
+
message to the agent, and the agent must do the step that the message names.
|
|
30
|
+
The hook is not a sandbox: a shell command can still write the queue file. The
|
|
31
|
+
check finds that result at the next stop.
|
|
32
|
+
|
|
33
|
+
## Turn the gates on
|
|
34
|
+
|
|
35
|
+
The user says "Turn on Joycraft's gates", or says yes to the offer in setup.
|
|
36
|
+
|
|
37
|
+
1. Run `node .joycraft/runtime/gate.mjs hook --plan`. It writes nothing.
|
|
38
|
+
- `change: "none"` and a `message`: tell the user the message. On a host
|
|
39
|
+
other than Claude Code, the message says that the hook is not available
|
|
40
|
+
and how to run the check by hand.
|
|
41
|
+
- `change: "add"`: continue.
|
|
42
|
+
2. Show the change to `.claude/settings.json` (`before` and `after`) on a page,
|
|
43
|
+
as [showing a page](artifacts.md#showing-a-page) says. In two lines, say
|
|
44
|
+
what the Stop hook does and how to turn it off.
|
|
45
|
+
3. On the user's yes, run `node .joycraft/runtime/gate.mjs hook --on`. Do not
|
|
46
|
+
edit `.claude/settings.json` by hand.
|
|
47
|
+
|
|
48
|
+
`.claude/settings.json` is the user's file. `--on` adds one Stop hook whose
|
|
49
|
+
command runs `gate.mjs check`, and it changes no other byte. A second `--on`
|
|
50
|
+
changes nothing. If the file is not valid JSON, the command stops and writes
|
|
51
|
+
nothing; tell the user.
|
|
52
|
+
|
|
53
|
+
## Turn the gates off
|
|
54
|
+
|
|
55
|
+
The user says "Turn off Joycraft's gates". That request is the yes. Run
|
|
56
|
+
`node .joycraft/runtime/gate.mjs hook --off` and tell the user its message.
|
|
57
|
+
When nobody changed the file after `--on`, the file is again byte for byte as
|
|
58
|
+
it was before `--on`. `.joycraft/local/gate-hook.json` keeps the record for
|
|
59
|
+
this. Without a usable record, it removes Joycraft's Stop hook and any
|
|
60
|
+
`hooks.Stop` list or `hooks` object left empty, and its message names each one.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Use `joycraft-retro` on a requested session worth learning from, including a
|
|
4
4
|
successful session with unexpected friction. It proposes environment improvements;
|
|
5
|
-
it does not run on every session end
|
|
5
|
+
it does not run on every session end or change acceptance.
|
|
6
6
|
|
|
7
7
|
## Prepare native session evidence
|
|
8
8
|
|
|
@@ -22,9 +22,9 @@ node .joycraft/runtime/retro.mjs prepare --source /absolute/path/session.jsonl -
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Line selection reduces the prepared context, not source-read memory: this small
|
|
25
|
-
helper reads the supplied file into memory. Use an existing episode export
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
helper reads the supplied file into memory. Use an existing episode export for
|
|
26
|
+
sources too large for that approach, retaining the original source references
|
|
27
|
+
and any selection limits.
|
|
28
28
|
|
|
29
29
|
Read `coverage.json` first, then `conversation.md` and `tools.jsonl`. The source
|
|
30
30
|
hash and physical line references let you return to exact raw evidence. The
|
|
@@ -45,17 +45,8 @@ inspect material before sharing it. It creates no permission or decision state.
|
|
|
45
45
|
Other harness formats can be read directly; do not describe an unsupported
|
|
46
46
|
format as normalized or invent native coverage.
|
|
47
47
|
|
|
48
|
-
Keep any linked session/worker files
|
|
49
|
-
|
|
50
|
-
Existing hook metrics can summarize explicit receipts without replaying paid
|
|
51
|
-
checks:
|
|
52
|
-
|
|
53
|
-
```sh
|
|
54
|
-
node .joycraft/runtime/hooks/metrics.mjs --log /absolute/path/events.jsonl
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Provider-reported usage is not an invoice; absent calls, timing or usage remain
|
|
58
|
-
unknown. Do not equate a missing receipt with a free or absent call.
|
|
48
|
+
Keep any linked session/worker files and final review reports as separate
|
|
49
|
+
sources. A single file may not contain all workers or continuations.
|
|
59
50
|
|
|
60
51
|
## Judge a candidate
|
|
61
52
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Settings by request
|
|
2
|
+
|
|
3
|
+
The user never edits Joycraft settings or runs Joycraft commands by hand. They
|
|
4
|
+
say what they want; you make the change, show it, and check it.
|
|
5
|
+
|
|
6
|
+
## `joycraft.yaml`
|
|
7
|
+
|
|
8
|
+
The file is the user's. Joycraft only reads it. Change it only when the user asks,
|
|
9
|
+
and keep their comments and order. Map plain requests to settings:
|
|
10
|
+
|
|
11
|
+
| The user says | Setting |
|
|
12
|
+
|---|---|
|
|
13
|
+
| "Keep briefs and specs in `working/features`" | `paths.features` |
|
|
14
|
+
| "Put finished features in `working/archive`" | `paths.archive` |
|
|
15
|
+
| "Our project knowledge lives in `knowledge/`" | `paths.context` |
|
|
16
|
+
| "After each feature is archived, sync our wiki" / "run `<command>`" | `hooks.afterArchive` |
|
|
17
|
+
| "This page describes `src/auction`" / "flag the auction page when that code changes" | `cleanup.impact` |
|
|
18
|
+
| "Let AGENTS.md be up to 1500 words" | `cleanup.entryWords` |
|
|
19
|
+
|
|
20
|
+
1. Read `joycraft.yaml`. If it does not exist, start from
|
|
21
|
+
`.joycraft/templates/joycraft.yaml` and keep only the settings the user changes.
|
|
22
|
+
2. For `hooks.afterArchive`, find the command in the project first: a wiki or doc
|
|
23
|
+
script, a `package.json` script, or the tool the user named. If none exists, ask
|
|
24
|
+
what should run; do not write a script unless the user asks for one. The command
|
|
25
|
+
gets `JOYCRAFT_FEATURE`, `JOYCRAFT_ARCHIVE_PATH` and `JOYCRAFT_SOURCE_PATH`.
|
|
26
|
+
3. For `cleanup.impact`, check that each `docs` page exists and each `source` glob
|
|
27
|
+
matches files.
|
|
28
|
+
4. Moving `paths.*` does not move existing files. Say which folders hold files now,
|
|
29
|
+
and offer to move them in the same change.
|
|
30
|
+
5. Show the change as a short diff and write it on the user's yes.
|
|
31
|
+
6. Run `node .joycraft/runtime/config.mjs`. If it stops, fix the file and run it
|
|
32
|
+
again. Tell the user the settings now in effect, in one or two lines.
|
|
33
|
+
|
|
34
|
+
To answer "what are my Joycraft settings?", run `config.mjs` and say what differs
|
|
35
|
+
from the defaults.
|
|
36
|
+
|
|
37
|
+
## A wiki the user keeps
|
|
38
|
+
|
|
39
|
+
Joycraft has no wiki of its own, and it works with one. When the user mentions their
|
|
40
|
+
wiki, offer two things: a context-map row that says when to read it, and an
|
|
41
|
+
`afterArchive` command that updates it when a feature is archived (above). In a doc
|
|
42
|
+
audit, the wiki is a context home; `paths.features` and `paths.archive` are
|
|
43
|
+
working material and history, not current knowledge.
|
|
44
|
+
|
|
45
|
+
## Remove Joycraft
|
|
46
|
+
|
|
47
|
+
On "uninstall Joycraft" or "remove Joycraft":
|
|
48
|
+
|
|
49
|
+
1. Read `.joycraft/installation.json`. Its `files` list holds each installed path
|
|
50
|
+
and the `sha256` it had at install.
|
|
51
|
+
2. Show the user what goes: the listed files, with each file whose bytes changed
|
|
52
|
+
since install marked as edited, Joycraft's Stop hook in `.claude/settings.json`
|
|
53
|
+
when the gates are on, and `.joycraft/` itself. Say what stays: `AGENTS.md`,
|
|
54
|
+
`CLAUDE.md`, `docs/` and `joycraft.yaml` are theirs.
|
|
55
|
+
3. Offer to remove the Joycraft lines from `AGENTS.md` and `CLAUDE.md` (the context
|
|
56
|
+
map rows that point into `.joycraft/`, and the Joycraft rules). Show that diff
|
|
57
|
+
separately.
|
|
58
|
+
4. On the user's yes, first run `node .joycraft/runtime/gate.mjs hook --off`. It
|
|
59
|
+
removes Joycraft's Stop hook. When the gates are off, it changes nothing. Then
|
|
60
|
+
delete the files, then `.joycraft/`. Do not commit.
|
|
@@ -320,15 +320,15 @@ the owning brief and do not ask it again.
|
|
|
320
320
|
## Finish setup and continue
|
|
321
321
|
|
|
322
322
|
Step 5 of [Set up the context map](#set-up-the-context-map) is the finish
|
|
323
|
-
check; also check that command claims match their cited source. Setup does not
|
|
324
|
-
dependencies, or replace the user's workflow.
|
|
325
|
-
|
|
323
|
+
check; also check that command claims match their cited source. Setup does not
|
|
324
|
+
change credentials, install dependencies, or replace the user's workflow.
|
|
325
|
+
When `.joycraft/installation.json` lists the `claude` host, offer the [gates](gates.md) once, in one line; turn them on only on the user's yes.
|
|
326
326
|
|
|
327
327
|
## Upgrade and agent onboarding
|
|
328
328
|
|
|
329
329
|
Updates go through the Joycraft CLI; follow [update guidance](update.md). The
|
|
330
330
|
installation manifest `.joycraft/installation.json` records the installed bytes;
|
|
331
|
-
it is dispatch input, not proof that
|
|
331
|
+
it is dispatch input, not proof that a review was independent.
|
|
332
332
|
|
|
333
333
|
A new worker reads `.joycraft/preferences.json` before work, reuses explicit
|
|
334
334
|
model, effort, role, concurrency, verification and question-style choices, and inspects the
|
|
@@ -128,7 +128,7 @@ guidance](https://code.claude.com/docs/en/hooks#reference-scripts-by-path).
|
|
|
128
128
|
|
|
129
129
|
On hosts without that native capability, create an equivalent manual Git linked
|
|
130
130
|
worktree at an explicit, verified ref. Build each packet from its actual root:
|
|
131
|
-
`workerRoot`, manifest path, source paths,
|
|
131
|
+
`workerRoot`, manifest path, source paths, commands,
|
|
132
132
|
receipts, and report paths must resolve there. A coordinator may not substitute
|
|
133
133
|
the shared checkout merely because its sources look equivalent.
|
|
134
134
|
|
|
@@ -2,10 +2,50 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import { existsSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { assertReviewAllowed, visibleReports } from './completion.mjs';
|
|
5
6
|
import { readLease } from './coordinator.mjs';
|
|
6
7
|
import { prepareDispatch } from './dispatch-preflight.mjs';
|
|
7
8
|
import { traceSpec } from './trace.mjs';
|
|
8
|
-
import { localPath, readQueue, relativePath, requireValue, validateNativeActor } from './identity.mjs';
|
|
9
|
+
import { canonical, isObject, localPath, readLocal, readQueue, relativePath, requireValue, sha256, snapshot, validateNativeActor } from './identity.mjs';
|
|
10
|
+
|
|
11
|
+
export const reviewLimit = 3;
|
|
12
|
+
|
|
13
|
+
/** A review round is one distinct set of reviewed inputs: each bound input's
|
|
14
|
+
* path and normalized sha256. HEAD is left out (implementationRevision, and so
|
|
15
|
+
* subject.identity), so a commit that changes no input keeps the round. Status
|
|
16
|
+
* is already outside the normalized queue and spec hashes. Returns null for a
|
|
17
|
+
* report with no bound inputs. */
|
|
18
|
+
export function reviewRoundKey(subject) {
|
|
19
|
+
const inputs = subject?.inputs;
|
|
20
|
+
if (!Array.isArray(inputs) || inputs.length === 0
|
|
21
|
+
|| !inputs.every(input => isObject(input) && typeof input.path === 'string' && typeof input.sha256 === 'string')) return null;
|
|
22
|
+
const bound = inputs.map(input => ({ path: input.path, sha256: input.sha256 }))
|
|
23
|
+
.sort((left, right) => left.path.localeCompare(right.path, 'en'));
|
|
24
|
+
return `inputs:${sha256(canonical(bound))}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Earlier reviews of one spec, keyed by reviewRoundKey: repeat reviews of one
|
|
28
|
+
* set of inputs are one round. A report with no bound inputs is its own round,
|
|
29
|
+
* keyed by its path. The spec's own accepted PASS report is not a round. Reports
|
|
30
|
+
* are read from the worker root and the coordinator root, where visibleReports
|
|
31
|
+
* looks for them. */
|
|
32
|
+
function earlierReviews({ roots, queuePath, spec }) {
|
|
33
|
+
const rounds = new Map();
|
|
34
|
+
for (const root of roots) {
|
|
35
|
+
for (const { path: file, report } of visibleReports({ root, queuePath, specId: spec.id })) {
|
|
36
|
+
const accepted = spec.acceptedReport;
|
|
37
|
+
if (report.verdict === 'PASS' && accepted?.path === file && sha256(readLocal(root, file)) === accepted.sha256) continue;
|
|
38
|
+
const shown = root === roots[0] ? file : path.join(root, file);
|
|
39
|
+
const key = reviewRoundKey(report.subject) ?? `path:${file}`;
|
|
40
|
+
rounds.set(key, [...(rounds.get(key) ?? []), shown]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return rounds;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class ReviewLimitError extends Error {
|
|
47
|
+
constructor(message) { super(message); this.exitCode = 2; }
|
|
48
|
+
}
|
|
9
49
|
|
|
10
50
|
// The native hook runtime is optional; without it, startup takes the manual path.
|
|
11
51
|
async function hookRuntime() {
|
|
@@ -40,7 +80,7 @@ export async function startDispatch(options, nativeEvent) {
|
|
|
40
80
|
const rel = path.relative(root, parent);
|
|
41
81
|
requireValue(rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel), 'Packet output parent must stay inside the worker root');
|
|
42
82
|
requireValue(gitIgnored(root, outPath), `Packet output must be git-ignored so it never becomes a scope path: ${outPath}; use .joycraft/local/packets/`);
|
|
43
|
-
const { queue } = readQueue({ root, queuePath: options.queuePath, specId: options.specId });
|
|
83
|
+
const { queue, queuePath, spec, specPath } = readQueue({ root, queuePath: options.queuePath, specId: options.specId });
|
|
44
84
|
requireValue(options.role === 'implementer' || options.role === 'reviewer', 'Task startup role must be implementer or reviewer');
|
|
45
85
|
// A claimed queue takes work only from its coordinator, so a second session's
|
|
46
86
|
// instructions cannot reach this worker. An unclaimed queue keeps 1.0.0 behavior.
|
|
@@ -48,9 +88,26 @@ export async function startDispatch(options, nativeEvent) {
|
|
|
48
88
|
requireValue(!lease || options.coordinatorSession === lease.sessionId,
|
|
49
89
|
lease && `Queue ${queue.feature} is coordinated by session ${lease.sessionId}${lease.host ? ` on ${lease.host}` : ''}; pass --coordinator-session ${lease.sessionId} only when that session dispatched this task`);
|
|
50
90
|
const coordinator = lease ? { sessionId: lease.sessionId, ...(lease.host ? { host: lease.host } : {}) } : null;
|
|
91
|
+
// A spec gets at most three reviews. A done spec keeps its earlier behavior, and
|
|
92
|
+
// a no-review waiver keeps its own refusal, so both are checked first.
|
|
93
|
+
let rounds;
|
|
94
|
+
if (options.role === 'reviewer' && spec.status !== 'done') {
|
|
95
|
+
const roots = [root];
|
|
96
|
+
if (options.coordinatorRoot !== undefined && existsSync(options.coordinatorRoot)) {
|
|
97
|
+
const coordinatorRoot = realpathSync(options.coordinatorRoot);
|
|
98
|
+
if (coordinatorRoot !== root) roots.push(coordinatorRoot);
|
|
99
|
+
}
|
|
100
|
+
for (const each of roots) assertReviewAllowed({ root: each, queuePath });
|
|
101
|
+
rounds = earlierReviews({ roots, queuePath, spec });
|
|
102
|
+
if (rounds.size > reviewLimit || (rounds.size === reviewLimit && !rounds.has(reviewRoundKey(snapshot({ root, queuePath, specId: spec.id }))))) {
|
|
103
|
+
throw new ReviewLimitError(`Review limit reached: ${queue.feature} spec ${spec.id} (${specPath}) has had ${rounds.size} reviews of different reviewed inputs (${[...rounds.values()].flat().join(', ')}); the limit is ${reviewLimit}. Do not start another review. Record the open findings under "## Decision needed" in ${specPath}, leave the spec in-review, and continue with independent ready work.`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
51
106
|
// Change scope is opt-in per spec: startup never writes it, and a reviewer
|
|
52
107
|
// without one reviews against the verification inputs alone.
|
|
53
108
|
const packet = prepareDispatch({ ...options, outPath: output });
|
|
109
|
+
const review = rounds === undefined ? {}
|
|
110
|
+
: { reviewRound: rounds.size + (rounds.has(reviewRoundKey(packet.subject)) ? 0 : 1), reviewLimit };
|
|
54
111
|
const runtime = await hookRuntime();
|
|
55
112
|
const config = runtime ? await runtime.readConfig(root) : { enabled: false };
|
|
56
113
|
const hooks = config.enabled
|
|
@@ -62,7 +119,7 @@ export async function startDispatch(options, nativeEvent) {
|
|
|
62
119
|
try { const { criteria, untraced, unknownTags, missingFiles, note } = traceSpec({ root, queuePath: options.queuePath, specId: options.specId }); trace = { criteria, untraced, unknownTags, missingFiles, ...(note ? { note } : {}) }; }
|
|
63
120
|
catch (error) { trace = { error: error.message }; }
|
|
64
121
|
}
|
|
65
|
-
return { schemaVersion: 1, packetPath: outPath, packet, hooks, coordinator, ...(trace ? { trace } : {}),
|
|
122
|
+
return { schemaVersion: 1, packetPath: outPath, packet, hooks, coordinator, ...review, ...(trace ? { trace } : {}),
|
|
66
123
|
ready: !config.enabled || hooks.eligible === true };
|
|
67
124
|
}
|
|
68
125
|
|
|
@@ -109,5 +166,5 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
109
166
|
}
|
|
110
167
|
|
|
111
168
|
if (process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href) {
|
|
112
|
-
main().catch(error => { process.stderr.write(`Task startup stopped: ${error.message}\n`); process.exitCode = 1; });
|
|
169
|
+
main().catch(error => { process.stderr.write(`Task startup stopped: ${error.message}\n`); process.exitCode = error instanceof ReviewLimitError ? 2 : 1; });
|
|
113
170
|
}
|