Skip to content

Commit ef60164

Browse files
MrPickeringclaude
andcommitted
Review: scope the outline context to the chapter's own scenes; add book-outline (0.3.1)
The outline context read every scene outline in the book. Editing one scene's outline staled every chapter's continuity and critic reviews, and each chapter's reviewer read every other chapter's locked beats. On a 38-chapter book with four scene outlines, one outline edit changed 76 review packets; it now changes the 2 packets of the chapter that owns the scene, and packets stop growing with the number of outlines. - outline: book-level notes under outline/, then only this chapter's scene outlines from project.outline_scene_root, in scene order. The hash follows. - book-outline: new context key carrying the whole outline, for custom reviewers that need the entire book. - Tests written first and failing on the old code. npm test: 404 pass, 2 skipped (Windows symlinks); preflight passes. - Version 0.3.1. Engine feature: Weaver's review context and its scene outline slot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Aa54HhwywkhcZGhKFiJ9Zb Session-Id: 186d8cba-8c5e-491b-9c79-f136c08c4048 Agent: claude-code
1 parent aacc426 commit ef60164

11 files changed

Lines changed: 237 additions & 31 deletions

‎README.md‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ Add a reviewer at `quality/reviewers/<id>.md`, for example:
645645
id: character-audit
646646
title: Character audit
647647
verdicts: [CLEAR, FLAGS]
648-
context: [world-bible, outline, style-guide, facts, previous-state]
648+
context: [world-bible, outline, book-outline, style-guide, facts, previous-state]
649649
queue: definite
650650
---
651651
Check every speaking character against the registry and world bible.
@@ -659,13 +659,24 @@ required; ids are kebab-case, match the filename, and cannot replace a built-in.
659659
The two distinct verdict words use letters, digits, underscores or hyphens and
660660
start with a letter; the first means nothing to report. They must differ by more
661661
than capital letters or underscores at their edges. `context` is any subset
662-
of the five keys shown, defaults to `[world-bible]`, and can be `[]`.
662+
of the six keys shown, defaults to `[world-bible]`, and can be `[]`.
663663
The registry and chapter reader text are always included. `world-bible` reads
664664
top-level Markdown notes, excluding voice profiles and unchanged starters;
665-
`outline` reads Markdown recursively, excluding unchanged starters;
666-
`style-guide` reads all top-level Markdown. Continuity and critic also receive
667-
authored outline notes. With no authored outline, their packets keep the old
668-
layout. Invalid reviewers are skipped with named warnings in `check` and `doctor`.
665+
`outline` reads book-level Markdown recursively under `outline/`, excluding
666+
the scene outline root, then adds only the current chapter's scene outlines in
667+
scene order. The scene outline root is `project.outline_scene_root`, defaulting
668+
to `outline/scenes`. Unchanged template starters are excluded. Editing a scene
669+
outline makes only that chapter's outline-reading reviews stale; editing a
670+
book-level note makes every chapter's outline-reading reviews stale.
671+
`book-outline` reads all Markdown recursively under `outline/`, plus all scene
672+
outlines if the scene root is outside that folder, excluding unchanged starters.
673+
Custom reviewers can request it when they need the entire book's outline;
674+
edits anywhere in that context make their reviews stale across chapters.
675+
`style-guide` reads all top-level Markdown. Built-in continuity and critic use
676+
the scoped `outline`; no built-in uses `book-outline`. With no authored outline
677+
in scope, built-in packets keep the old layout. Custom `outline` contexts keep
678+
the `_No project outline notes._` placeholder when empty. Invalid reviewers are
679+
skipped with named warnings in `check` and `doctor`.
669680

670681
`queue: definite` queues only definite findings. `top-2` or `top-3` queues up to
671682
that many definite and craft findings when the verdict is the second word,

‎engine/review.mjs‎

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright 2026 Mark Pickering and PICKBITS LLC. Part of PickBits Weaver.
33
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
4-
import { dirname, join } from "node:path";
4+
import { dirname, isAbsolute, join, relative, sep } from "node:path";
55
import { fileURLToPath } from "node:url";
66
import { loadCharacters } from "./characters.mjs";
77
import { runHostBatch } from "./host.mjs";
@@ -43,12 +43,25 @@ function factsContext(root, chapter) {
4343
return { text, hash: sha256(text) };
4444
}
4545

46-
function markdownContext(root, folder, { recursive = false, excludeStarters = false } = {}) {
46+
function withinDirectory(directory, path) {
47+
const name = relative(directory, path);
48+
return name !== ".." && !name.startsWith(`..${sep}`) && !isAbsolute(name);
49+
}
50+
51+
function markdownFileContext(root, path, heading, { excludeStarters = false } = {}) {
52+
if (!existsSync(join(root, path))) return "";
53+
const text = readFileSync(join(root, path), "utf8");
54+
const starter = join(PACKAGE_ROOT, "templates", "book", path);
55+
if (excludeStarters && existsSync(starter) && text === readFileSync(starter, "utf8")) return "";
56+
return `### ${heading}\n${text.trim()}`;
57+
}
58+
59+
function markdownContext(root, folder, { recursive = false, excludeStarters = false, excludeRoot, headingRoot = join(root, folder) } = {}) {
4760
const lines = [];
4861
const names = [];
4962
const walk = (prefix = "") => {
5063
const directory = join(root, folder, prefix);
51-
if (!existsSync(directory)) return;
64+
if ((excludeRoot && withinDirectory(excludeRoot, directory)) || !existsSync(directory)) return;
5265
for (const entry of readdirSync(directory, { withFileTypes: true })) {
5366
const name = prefix ? `${prefix}/${entry.name}` : entry.name;
5467
if (recursive && entry.isDirectory()) walk(name);
@@ -57,14 +70,37 @@ function markdownContext(root, folder, { recursive = false, excludeStarters = fa
5770
};
5871
walk();
5972
for (const name of names.sort()) {
60-
const text = readFileSync(join(root, folder, name), "utf8");
61-
const starter = join(PACKAGE_ROOT, "templates", "book", folder, name);
62-
if (excludeStarters && existsSync(starter) && text === readFileSync(starter, "utf8")) continue;
63-
lines.push(`### ${name}\n${text.trim()}`);
73+
const path = join(folder, name);
74+
const heading = relative(headingRoot, join(root, path)).replaceAll("\\", "/");
75+
const text = markdownFileContext(root, path, heading, { excludeStarters });
76+
if (text) lines.push(text);
6477
}
6578
return lines.join("\n\n");
6679
}
6780

81+
function chapterOutline(root, project, scenes) {
82+
const sceneFolder = project.outline_scene_root || "outline/scenes";
83+
const sceneRoot = join(root, sceneFolder);
84+
const outlineRoot = join(root, "outline");
85+
const notes = markdownContext(root, "outline", { recursive: true, excludeStarters: true, excludeRoot: sceneRoot });
86+
const headingRoot = withinDirectory(outlineRoot, sceneRoot) ? outlineRoot : root;
87+
const outlines = scenes.map((scene) => {
88+
const path = join(sceneFolder, `${scene.id}.md`);
89+
const heading = relative(headingRoot, join(root, path)).replaceAll("\\", "/");
90+
return markdownFileContext(root, path, heading, { excludeStarters: true });
91+
});
92+
return [notes, ...outlines].filter(Boolean).join("\n\n");
93+
}
94+
95+
function bookOutline(root, project) {
96+
const notes = markdownContext(root, "outline", { recursive: true, excludeStarters: true });
97+
const sceneFolder = project.outline_scene_root || "outline/scenes";
98+
const outlineRoot = join(root, "outline");
99+
if (withinDirectory(outlineRoot, join(root, sceneFolder))) return notes;
100+
const outlines = markdownContext(root, sceneFolder, { recursive: true, excludeStarters: true, excludeRoot: outlineRoot, headingRoot: root });
101+
return [notes, outlines].filter(Boolean).join("\n\n");
102+
}
103+
68104
export function worldBible(root) {
69105
return markdownContext(root, "world-bible", { excludeStarters: true }) || "_No project world-bible notes._";
70106
}
@@ -107,11 +143,12 @@ export function buildReviewPacket(root, project, chapter, lens, inputs = reviewI
107143
let title, text, hash;
108144
if (key === "world-bible") { title = "World bible"; text = worldBible(root); }
109145
if (key === "outline") {
110-
title = "Outline"; text = markdownContext(root, "outline", { recursive: true, excludeStarters: true });
146+
title = "Outline"; text = chapterOutline(root, project, inputs.chapterScenes);
111147
// Keep legacy built-in packets byte-identical when there is no authored outline.
112148
if (!text && definition.builtin) continue;
113149
text ||= "_No project outline notes._";
114150
}
151+
if (key === "book-outline") { title = "Book outline"; text = bookOutline(root, project) || "_No project outline notes._"; }
115152
if (key === "style-guide") { title = "Style guide"; text = markdownContext(root, "style-guide") || "_No style-guide notes._"; }
116153
if (key === "facts") { title = "Earlier facts"; text = inputs.facts.text; hash = inputs.facts.hash || ""; }
117154
if (key === "previous-state") { title = "Previous chapter narrative state"; text = inputs.previous; }

‎engine/reviewers.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const BUILT_INS = [
1010
{ id: "style", title: "Style", verdicts: ["CONSISTENT", "DRIFT"], context: ["world-bible"], queue: "definite" },
1111
{ id: "critic", title: "Critic", verdicts: ["PASS", "FAIL"], context: ["world-bible", "outline"], queue: "critic" }
1212
];
13-
const CONTEXT = new Set(["world-bible", "outline", "style-guide", "facts", "previous-state"]);
13+
const CONTEXT = new Set(["world-bible", "outline", "book-outline", "style-guide", "facts", "previous-state"]);
1414
const KEYS = new Set(["id", "title", "verdicts", "context", "queue"]);
1515

1616
function parseReviewer(text, filename) {

‎integrity.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "https://pickbits.ai/schemas/weaver/integrity-1.json",
3-
"generator": "PickBits Weaver 0.3.0",
4-
"version": "0.3.0",
3+
"generator": "PickBits Weaver 0.3.1",
4+
"version": "0.3.1",
55
"files": {
66
"LICENSE": "3954ad2ee7d56cfda60326c71dcfd3d7edd79a44727f51b5ca5e4b7c33b8c6d6",
77
"NOTICE": "83abe7f22edf5a06f7b4814e8b4b4b124e1b612bd81dd4c6542c0b119fab4976",
8-
"README.md": "852413fdcf46811825a4067a456e8653aedd5426e523e3802c6527165b0c9f0f",
8+
"README.md": "711d81e4325fa51850afa1512d68f0552cc7d8f44d95e82f072e3739ab6da813",
99
"SECURITY.md": "5c9c72ffaa8dfdc744360ea666d2082c68bba2479c61d13810bbd595498afe2b",
1010
"contracts/backup.schema.json": "74d93556ee06389a93660f054573e7df90cc849b0553bff4e09f914766ea2f64",
1111
"contracts/characters.schema.json": "f9bd6fcc9c2ad363fd805d8d5209c9a292204b0beaf9035a4b6ceadacfd36c7b",
@@ -52,8 +52,8 @@
5252
"engine/release.mjs": "da2860f3413757efe1d18daa6a6fbe62d01c9bcb5d263b1323185ab23ca61219",
5353
"engine/repair.mjs": "a19ef192be78f62deddf40e49357900e896610b9118ad2e2cae528361df6d810",
5454
"engine/report.mjs": "26655e9e23b66353101372c2ae625bddc04d6f1bd4cb19531ab9869b70812052",
55-
"engine/review.mjs": "9ada7f04d560de07719cbedbe3c3024a079118d4d0599af4e6ca347dd7242a7f",
56-
"engine/reviewers.mjs": "295491a58a61f49cefd3bf89ac652cbab907f09b97432faacf017fc5a348b4b0",
55+
"engine/review.mjs": "1b4b88a697562eaf7882830b2791ba6c5f47f9409add009d0c7b95d0668952bb",
56+
"engine/reviewers.mjs": "7bd60531c718ea59cbc7cbd217b64e8d22f0ccf864543c964b677d1e1ecd1e9a",
5757
"engine/rule-regression.mjs": "c109071055dcb248cef2a468bbd65aab4da6efc95be698fa211317acbb2442fc",
5858
"engine/rules.mjs": "f3d550427b327e59464e49decd6996d2d0ec70f565440069b640d096dc9412c0",
5959
"engine/rulings.mjs": "444021aa1775c52a093db4e06374541cacccd15c4ffb51cb433b797e2b242911",
@@ -63,7 +63,7 @@
6363
"engine/studio.mjs": "6c02f758290393463d14001e5b494828f1c3998cf3112c1bb4c887414622a841",
6464
"engine/voice.mjs": "a9bfee13c2ffb0ee3857a21b2611511bfb73d95f2dc5a2ef8ddd9190abe822ea",
6565
"loop.manifest.json": "340b33bb8b03c60ce4997b9182baa18435fc3d6716d660ea8d15ae466663abc0",
66-
"package.json": "246c25758e86da79cbc2ef1e661982102c002413cbf4529ca0fd1f4b094101eb",
66+
"package.json": "b810300b5173d84fd5d80ed0c14f70c5bf3e7f145a45c015f127438b007e92c0",
6767
"prompts/architect.md": "51ed331812edfb4801fd60948293eb40f960a2735d949376d80488dc1c3724e4",
6868
"prompts/reviewers/continuity.md": "b3e77bcfcfb8433e71ba7c5028962d5ca9882989c05eadfa204effc54573273b",
6969
"prompts/reviewers/critic.md": "9a921c7d05a0656d67a8f31f27e06af87842afc223b8646c64db6de291897f7d",

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pickbitsai/weaver",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "PickBits Weaver: a provenance-aware, revision-safe book writing pipeline",
55
"keywords": [
66
"agentic-workflow",

‎test/approvals.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test("changes and approve commit only one chapter, recompute words, add trailer,
7171
const show = git(root, ["show", "--format=%B", "--name-only", "HEAD"], { GIT_CONFIG_GLOBAL: globalConfig });
7272
assert.equal(show.status, 0, show.stderr);
7373
assert.match(show.stdout, /Approve chapter 1: Opening pass/);
74-
assert.match(show.stdout, /Approved-with: PickBits Weaver 0\.3\.0/);
74+
assert.match(show.stdout, /Approved-with: PickBits Weaver 0\.3\.1/);
7575
assert.match(show.stdout, /manuscript[\\/]chapter-01[\\/]scene-01[\\/]scene\.md/);
7676
assert.doesNotMatch(show.stdout, /chapter-02/);
7777
assert.equal(git(root, ["config", "--local", "--get", "user.name"], { GIT_CONFIG_GLOBAL: globalConfig }).stdout.trim(), "Author");

‎test/backup.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test("setup copies history, hides its record, and rejects unsafe addresses witho
114114
assert.equal(normalPath(address), normalPath(bare));
115115
const record = readBackupRecord(root);
116116
assert.equal(record.$schema, "https://pickbits.ai/schemas/weaver/backup-1.json");
117-
assert.equal(record.generator, "PickBits Weaver 0.3.0");
117+
assert.equal(record.generator, "PickBits Weaver 0.3.1");
118118
assert.equal(record.remote_name, "weaver-backup");
119119
assert.equal(record.attempts.length, 1);
120120
assert.equal(record.attempts[0].result, "ok");

‎test/consumer-install.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ try {
138138
});
139139
const studioHealth = await fetch(new URL("api/health", studioUrl));
140140
assert.equal(studioHealth.status, 200);
141-
assert.deepEqual(await studioHealth.json(), { service: "pickbits-weaver-studio", generator: "PickBits Weaver 0.3.0", book: "consumer-book" });
141+
assert.deepEqual(await studioHealth.json(), { service: "pickbits-weaver-studio", generator: "PickBits Weaver 0.3.1", book: "consumer-book" });
142142
studioChild.kill();
143143
studioChild = null;
144144

‎test/doctor.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ test("doctor JSON output is machine-readable and identifies Weaver", () => {
140140
const result = runWeaver(["doctor", "--json", "--root", book]);
141141
assert.equal(result.status, 0, result.stderr);
142142
const report = JSON.parse(result.stdout);
143-
assert.equal(report.generator, "PickBits Weaver 0.3.0");
143+
assert.equal(report.generator, "PickBits Weaver 0.3.1");
144144
assert.equal(report.ok, true);
145145
} finally {
146146
rmSync(book, { recursive: true, force: true });

0 commit comments

Comments
 (0)