@rallycry/conveyor-agent 11.1.2 → 11.1.4

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.
@@ -99,7 +99,7 @@ import {
99
99
  subProjectScopePaths,
100
100
  updateRemoteToken,
101
101
  verifyGitCredential
102
- } from "./chunk-PVN7PGMT.js";
102
+ } from "./chunk-QYQLVARY.js";
103
103
  import {
104
104
  reportBootMilestone
105
105
  } from "./chunk-VIUZS7V4.js";
@@ -1515,6 +1515,16 @@ function parseEnvelope(line) {
1515
1515
  request: { id: record.id, tool_name: record.tool_name, tool_input: toolInput }
1516
1516
  };
1517
1517
  }
1518
+ if (record.kind === "notification") {
1519
+ if (typeof record.notification_type !== "string") return null;
1520
+ return {
1521
+ kind: "notification",
1522
+ notification: {
1523
+ notification_type: record.notification_type,
1524
+ message: typeof record.message === "string" ? record.message : ""
1525
+ }
1526
+ };
1527
+ }
1518
1528
  const result = {};
1519
1529
  if (typeof record.tool_name === "string") result.tool_name = record.tool_name;
1520
1530
  if (typeof record.elapsed_time_seconds === "number") {
@@ -1523,14 +1533,16 @@ function parseEnvelope(line) {
1523
1533
  return { kind: "progress", progress: result };
1524
1534
  }
1525
1535
  var HookSocketServer = class {
1526
- constructor(socketPath, onProgress, onPreToolUse) {
1536
+ constructor(socketPath, onProgress, onPreToolUse, onNotification) {
1527
1537
  this.socketPath = socketPath;
1528
1538
  this.onProgress = onProgress;
1529
1539
  this.onPreToolUse = onPreToolUse;
1540
+ this.onNotification = onNotification;
1530
1541
  }
1531
1542
  socketPath;
1532
1543
  onProgress;
1533
1544
  onPreToolUse;
1545
+ onNotification;
1534
1546
  server = null;
1535
1547
  _closed = false;
1536
1548
  async listen() {
@@ -1582,6 +1594,10 @@ var HookSocketServer = class {
1582
1594
  this.onProgress(envelope.progress);
1583
1595
  return;
1584
1596
  }
1597
+ if (envelope.kind === "notification") {
1598
+ this.onNotification?.(envelope.notification);
1599
+ return;
1600
+ }
1585
1601
  void this.respondToPreToolUse(envelope.request, socket);
1586
1602
  }
1587
1603
  async respondToPreToolUse(request, socket) {
@@ -1664,6 +1680,10 @@ process.stdin.on("end", () => {
1664
1680
  }
1665
1681
  if (payload.hook_event_name === "PreToolUse") {
1666
1682
  preToolUse(payload);
1683
+ } else if (payload.hook_event_name === "PermissionRequest") {
1684
+ permissionRequest(payload);
1685
+ } else if (payload.hook_event_name === "Notification") {
1686
+ relayNotification(payload);
1667
1687
  } else {
1668
1688
  relayProgress(typeof payload.tool_name === "string" ? payload.tool_name : "");
1669
1689
  }
@@ -1702,6 +1722,66 @@ function relayProgress(toolName) {
1702
1722
  });
1703
1723
  }
1704
1724
 
1725
+ // Tools whose dialog IS the product: the discovery plan review and the
1726
+ // questionnaire. The CLI ignores a hook allow for them anyway (they require
1727
+ // user interaction); abstaining keeps their existing dialog flows unchanged.
1728
+ const DIALOG_TOOLS = ["ExitPlanMode", "AskUserQuestion"];
1729
+
1730
+ // Answering allow here is safe because a dialog can only open AFTER Conveyor's
1731
+ // PreToolUse verdict was allow \u2014 a PreToolUse deny ends the call first. Plan
1732
+ // spawns route every tool through PreToolUse; build spawns allow everything
1733
+ // but destructive Bash, which their Bash PreToolUse hook denies. So any dialog
1734
+ // left is the CLI's own plan-mode floor or safety check, not a Conveyor
1735
+ // decision, and there is nobody at the terminal to answer it.
1736
+ function permissionRequest(payload) {
1737
+ if (DIALOG_TOOLS.includes(payload.tool_name)) {
1738
+ process.exit(0);
1739
+ return;
1740
+ }
1741
+ process.stdout.write(
1742
+ JSON.stringify({
1743
+ hookSpecificOutput: { hookEventName: "PermissionRequest", decision: { behavior: "allow" } },
1744
+ }),
1745
+ );
1746
+ process.exit(0);
1747
+ }
1748
+
1749
+ function relayNotification(payload) {
1750
+ const socketPath = process.env.CONVEYOR_HOOK_SOCKET;
1751
+ let done = false;
1752
+ const finish = () => {
1753
+ if (done) return;
1754
+ done = true;
1755
+ process.exit(0);
1756
+ };
1757
+ const fallback = setTimeout(finish, 500);
1758
+ if (!socketPath) {
1759
+ clearTimeout(fallback);
1760
+ finish();
1761
+ return;
1762
+ }
1763
+ const client = net.connect(socketPath, () => {
1764
+ const line =
1765
+ JSON.stringify({
1766
+ kind: "notification",
1767
+ notification_type:
1768
+ typeof payload.notification_type === "string" ? payload.notification_type : "",
1769
+ message: typeof payload.message === "string" ? payload.message : "",
1770
+ }) + "\\n";
1771
+ client.write(line, () => {
1772
+ client.end();
1773
+ });
1774
+ });
1775
+ client.on("close", () => {
1776
+ clearTimeout(fallback);
1777
+ finish();
1778
+ });
1779
+ client.on("error", () => {
1780
+ clearTimeout(fallback);
1781
+ finish();
1782
+ });
1783
+ }
1784
+
1705
1785
  function preToolUse(payload) {
1706
1786
  const socketPath = process.env.CONVEYOR_HOOK_SOCKET;
1707
1787
  let done = false;
@@ -1811,14 +1891,24 @@ function buildPreToolUseHooks(helperPath, gateAllTools) {
1811
1891
  hooks: [{ type: "command", command, timeout: 120 }]
1812
1892
  },
1813
1893
  {
1814
- // A hook allow bypasses the permission engine in every mode. Loose by
1815
- // design: the pod is the sandbox, and agents must call update_task etc.
1816
- // The helper answers locally (no socket).
1894
+ // Loose by design: the pod is the sandbox, and agents must call
1895
+ // update_task etc. The helper answers locally (no socket). This allow is
1896
+ // a verdict only — a dialog the CLI still opens is answered by the
1897
+ // PermissionRequest hook.
1817
1898
  matcher: "mcp__.*",
1818
1899
  hooks: [{ type: "command", command, timeout: 30 }]
1819
1900
  }
1820
1901
  ];
1821
1902
  }
1903
+ function buildDialogHooks(helperPath) {
1904
+ const command = `node ${JSON.stringify(helperPath)}`;
1905
+ return {
1906
+ PermissionRequest: [{ matcher: "*", hooks: [{ type: "command", command, timeout: 30 }] }],
1907
+ Notification: [
1908
+ { matcher: "permission_prompt", hooks: [{ type: "command", command, timeout: 10 }] }
1909
+ ]
1910
+ };
1911
+ }
1822
1912
  async function writeHookSettings(dir, opts = {}) {
1823
1913
  const helperPath = join3(dir, "hook-helper.cjs");
1824
1914
  const settingsPath = join3(dir, "settings.json");
@@ -1842,8 +1932,8 @@ async function writeHookSettings(dir, opts = {}) {
1842
1932
  // does NOT relax the planning gate: in discovery/plan mode the spawn passes
1843
1933
  // `--permission-mode plan`, which keeps file edits blocked until the agent
1844
1934
  // exits plan mode regardless of this allow-list. Plan mode still prompts
1845
- // for anything it cannot classify as read-only; the PreToolUse hooks below
1846
- // answer those. In build mode the spawn already bypasses prompts via
1935
+ // for anything it cannot classify as read-only; the PermissionRequest hook
1936
+ // below answers those. In build mode the spawn already bypasses prompts via
1847
1937
  // `--dangerously-skip-permissions`.
1848
1938
  // NOTE: a bare "*" rule is INVALID (the CLI rejects it and parks the TUI on
1849
1939
  // a Settings Warning dialog at boot) — hence the explicit ALLOW_RULES list.
@@ -1862,7 +1952,8 @@ async function writeHookSettings(dir, opts = {}) {
1862
1952
  matcher: "*",
1863
1953
  hooks: [{ type: "command", command: `node ${JSON.stringify(helperPath)}` }]
1864
1954
  }
1865
- ]
1955
+ ],
1956
+ ...buildDialogHooks(helperPath)
1866
1957
  }
1867
1958
  };
1868
1959
  await writeFile3(settingsPath, JSON.stringify(settings, null, 2), "utf8");
@@ -3258,6 +3349,14 @@ var PtySession = class {
3258
3349
  // type chat text into the questionnaire. Fail-safe — a stale flag only
3259
3350
  // costs a teardown + respawn (`--resume` recovers the conversation).
3260
3351
  questionnairePending = false;
3352
+ // Parked-permission-dialog backstop (see handleHookNotification). The last
3353
+ // tool the PreToolUse hook saw over the socket, cleared once that tool runs:
3354
+ // a parked ExitPlanMode/AskUserQuestion dialog is an expected wait, not an
3355
+ // alert. MCP tools are answered without the socket and never set it.
3356
+ lastPreToolUseTool = null;
3357
+ // One alert per parked dialog: set when the backstop fires, cleared when
3358
+ // any tool runs (the dialog was answered) or a new turn starts.
3359
+ permissionAlertArmed = false;
3261
3360
  // Per-turn state: the prompt to feed and the per-turn options subset. Both
3262
3361
  // start from the constructor args (turn 1) and are replaced by beginTurn.
3263
3362
  turnPrompt;
@@ -3447,6 +3546,8 @@ var PtySession = class {
3447
3546
  this.disarmSubmitNudge();
3448
3547
  this.disarmPlanDialogAutoAccept();
3449
3548
  this.questionnairePending = false;
3549
+ this.permissionAlertArmed = false;
3550
+ this.lastPreToolUseTool = null;
3450
3551
  this.closeSyntheticQuestionCards();
3451
3552
  }
3452
3553
  /**
@@ -3703,7 +3804,8 @@ var PtySession = class {
3703
3804
  this.socket = new HookSocketServer(
3704
3805
  socketPath,
3705
3806
  (progress) => this.handleProgress(progress),
3706
- (request) => this.handlePreToolUse(request)
3807
+ (request) => this.handlePreToolUse(request),
3808
+ (notification) => this.handleHookNotification(notification)
3707
3809
  );
3708
3810
  await this.socket.listen();
3709
3811
  const { settingsPath } = await writeHookSettings(this.tempDir, {
@@ -4167,6 +4269,10 @@ var PtySession = class {
4167
4269
  this.disarmPlanDialogAutoAccept();
4168
4270
  }
4169
4271
  if (progress.tool_name === "AskUserQuestion") this.questionnairePending = false;
4272
+ this.permissionAlertArmed = false;
4273
+ if (progress.tool_name !== void 0 && progress.tool_name === this.lastPreToolUseTool) {
4274
+ this.lastPreToolUseTool = null;
4275
+ }
4170
4276
  if (this.pendingSubmitNudge) this.disarmSubmitNudge();
4171
4277
  this.pushEvent({
4172
4278
  type: "tool_progress",
@@ -4184,6 +4290,7 @@ var PtySession = class {
4184
4290
  */
4185
4291
  async handlePreToolUse(request) {
4186
4292
  if (this.pendingSubmitNudge) this.disarmSubmitNudge();
4293
+ this.lastPreToolUseTool = request.tool_name;
4187
4294
  if (request.tool_name === "AskUserQuestion") {
4188
4295
  this.disarmSubmitNudge();
4189
4296
  this.disarmPlanDialogAutoAccept();
@@ -4206,6 +4313,39 @@ var PtySession = class {
4206
4313
  }
4207
4314
  return verdict;
4208
4315
  }
4316
+ /**
4317
+ * The CLI's `permission_prompt` notification: a permission dialog has been
4318
+ * open ~6s with nobody answering it. The PermissionRequest hook answers
4319
+ * every dialog Conveyor can answer, so one still parked means the CLI found
4320
+ * a new way to ask. Raise the existing needs-input alert (a `user_question`
4321
+ * event → `waiting_for_input`/`user_question`) rather than sending a blind
4322
+ * keypress, which could approve or cancel the wrong thing.
4323
+ *
4324
+ * Ignored for the expected parked states — an open questionnaire, the plan
4325
+ * dialog auto-accept loop, a discovery plan review — and while an alert for
4326
+ * the same dialog is already up.
4327
+ */
4328
+ handleHookNotification(notification) {
4329
+ if (notification.notification_type !== "permission_prompt") return;
4330
+ if (this.questionnairePending || this.pendingPlanApproval || this.permissionAlertArmed) return;
4331
+ if (this.lastPreToolUseTool === "ExitPlanMode" || this.lastPreToolUseTool === "AskUserQuestion") {
4332
+ return;
4333
+ }
4334
+ this.permissionAlertArmed = true;
4335
+ const message = notification.message.trim() || "Claude needs your permission";
4336
+ process.stderr.write(`[PtySession] permission dialog parked: ${message}
4337
+ `);
4338
+ this.pushEvent({
4339
+ type: "user_question",
4340
+ questions: [
4341
+ {
4342
+ question: `Claude Code is waiting on a permission dialog (${message}). Answer it in the Claude tab.`,
4343
+ header: "Permission",
4344
+ options: []
4345
+ }
4346
+ ]
4347
+ });
4348
+ }
4209
4349
  /**
4210
4350
  * A hook "allow" does not bypass the CLI's plan-approval dialog — it renders
4211
4351
  * right after the verdict and parks the turn until answered. Press Enter
@@ -10184,11 +10324,14 @@ Co-Authored-By: Claude <noreply@anthropic.com>`;
10184
10324
  url: result.prUrl,
10185
10325
  number: result.prNumber
10186
10326
  });
10327
+ const schemaNote = result.schemaNote ? `
10328
+
10329
+ ${result.schemaNote}` : "";
10187
10330
  const glossaryNote = result.glossaryNote ? `
10188
10331
 
10189
10332
  ${result.glossaryNote}` : "";
10190
10333
  return textResult(
10191
- `Pull request #${result.prNumber} created: ${result.prUrl}${glossaryNote}`
10334
+ `Pull request #${result.prNumber} created: ${result.prUrl}${schemaNote}${glossaryNote}`
10192
10335
  );
10193
10336
  } catch (error) {
10194
10337
  const msg = error instanceof Error ? error.message : "Unknown error";
@@ -8,7 +8,7 @@ import {
8
8
  readWorkspaceBytes,
9
9
  statWorkspacePath,
10
10
  workspacePathExists
11
- } from "./chunk-PVN7PGMT.js";
11
+ } from "./chunk-QYQLVARY.js";
12
12
  import {
13
13
  reportBootMilestone
14
14
  } from "./chunk-VIUZS7V4.js";
@@ -37,7 +37,7 @@ import {
37
37
  workbenchEnabled
38
38
  } from "./chunk-KMB3BU4S.js";
39
39
 
40
- // ../shared/dist/chunk-6WQGDBUG.js
40
+ // ../shared/dist/chunk-E75VFMFL.js
41
41
  import { z } from "zod";
42
42
  import { z as z2 } from "zod";
43
43
  var DEFAULT_SONNET_MODEL = "claude-sonnet-5-5";
@@ -173,6 +173,15 @@ var projectCheckpointSettingsSchema = z.object({
173
173
  }
174
174
  }
175
175
  });
176
+ var repoRelativePathSchema = z.string().trim().min(1).max(300).refine(
177
+ (path) => !path.startsWith("/") && !path.split("/").includes(".."),
178
+ "must be a path inside the repository"
179
+ );
180
+ var schemaDocsSettingsSchema = z.object({
181
+ docsPath: repoRelativePathSchema,
182
+ sourcePaths: z.array(repoRelativePathSchema).max(50),
183
+ contractPaths: z.array(repoRelativePathSchema).max(50).optional()
184
+ });
176
185
  var CARD_DESCRIPTION_MAX = 255;
177
186
  var CARD_DESCRIPTION_LIMIT_MESSAGE = `Card descriptions are capped at ${CARD_DESCRIPTION_MAX} characters \u2014 write 1-2 plain sentences a non-engineer can read; put technical detail in the plan or card chat.`;
178
187
  var CARD_DESCRIPTION_FIELD_HINT = `max ${CARD_DESCRIPTION_MAX} chars, 1-2 plain sentences a non-engineer can read \u2014 put technical detail in the plan`;
@@ -1444,7 +1453,10 @@ var CreatePRResponseSchema = z5.object({
1444
1453
  prUrl: z5.string().url(),
1445
1454
  /** Advisory glossary-upkeep note derived from the PR's changed files matched
1446
1455
  * against tag contextPaths — rendered into the tool result, never stored. */
1447
- glossaryNote: z5.string().optional()
1456
+ glossaryNote: z5.string().optional(),
1457
+ /** Which schema pages, schema sources and contracts the PR changed, when the
1458
+ * project configures `schemaDocs`; the PR body carries the full section. */
1459
+ schemaNote: z5.string().optional()
1448
1460
  });
1449
1461
  var PostToChatResponseSchema = z5.object({
1450
1462
  messageId: z5.string()
@@ -7314,7 +7326,12 @@ var messageDTOSchema = schemaOf()(
7314
7326
  })
7315
7327
  );
7316
7328
  var createPRResponseSchema = schemaOf()(
7317
- z44.object({ prNumber: z44.number(), prUrl: z44.string(), glossaryNote: z44.string().optional() })
7329
+ z44.object({
7330
+ prNumber: z44.number(),
7331
+ prUrl: z44.string(),
7332
+ glossaryNote: z44.string().optional(),
7333
+ schemaNote: z44.string().optional()
7334
+ })
7318
7335
  );
7319
7336
  var taskContextDTOSchema = schemaOf()(
7320
7337
  z44.object({
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  WorkspaceCommandSupervisor,
8
8
  startWorkspaceCommandsAfterConnect,
9
9
  stopWorkspaceCommands
10
- } from "./chunk-DFPOPMTN.js";
10
+ } from "./chunk-J7FBKZ2W.js";
11
11
  import {
12
12
  PtyHarness,
13
13
  SessionRunner,
@@ -25,7 +25,7 @@ import {
25
25
  resolveTuiKindFromEnv,
26
26
  sampleKeyUsage,
27
27
  usesNativeUsageReporting
28
- } from "./chunk-U3X4LTN4.js";
28
+ } from "./chunk-2ZYWKLHC.js";
29
29
  import "./chunk-V5WR2F2P.js";
30
30
  import {
31
31
  inheritedEnv,
@@ -41,7 +41,7 @@ import {
41
41
  createServiceLogger,
42
42
  loadAndAnnotateDiscoveredPorts,
43
43
  loadConveyorConfig
44
- } from "./chunk-PVN7PGMT.js";
44
+ } from "./chunk-QYQLVARY.js";
45
45
  import "./chunk-VIUZS7V4.js";
46
46
  import "./chunk-W4LZ7R6Z.js";
47
47
  import "./chunk-372R6E4C.js";
@@ -1398,7 +1398,7 @@ if (!RUNNER_MODES.includes(CONVEYOR_MODE)) {
1398
1398
  process.exit(1);
1399
1399
  }
1400
1400
  if (CONVEYOR_MODE === "serving") {
1401
- const { runServingSession } = await import("./serve-boot-XQYGJG3S.js");
1401
+ const { runServingSession } = await import("./serve-boot-2HHYC2YQ.js");
1402
1402
  exitContext.runnerMode = "serving";
1403
1403
  exitContext.sessionId = process.env.CONVEYOR_SESSION_ID ?? exitContext.sessionId;
1404
1404
  const outcome = await runServingSession({
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionRunner,
3
3
  unshallowRepo
4
- } from "./chunk-U3X4LTN4.js";
4
+ } from "./chunk-2ZYWKLHC.js";
5
5
  import "./chunk-V5WR2F2P.js";
6
6
  import "./chunk-76JCOHPE.js";
7
7
  import {
@@ -17,7 +17,7 @@ import {
17
17
  stageAndCommit,
18
18
  updateRemoteToken,
19
19
  workspacePathExists
20
- } from "./chunk-PVN7PGMT.js";
20
+ } from "./chunk-QYQLVARY.js";
21
21
  import "./chunk-VIUZS7V4.js";
22
22
  import {
23
23
  runAuthTokenCommand,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WorkspaceCommandSupervisor
3
- } from "./chunk-DFPOPMTN.js";
3
+ } from "./chunk-J7FBKZ2W.js";
4
4
  import {
5
5
  AgentConnection,
6
6
  DEFAULT_LIFECYCLE_CONFIG,
@@ -11,7 +11,7 @@ import {
11
11
  ensureOnTaskBranch,
12
12
  loadAndAnnotateDiscoveredPorts,
13
13
  loadConveyorConfig
14
- } from "./chunk-PVN7PGMT.js";
14
+ } from "./chunk-QYQLVARY.js";
15
15
  import "./chunk-VIUZS7V4.js";
16
16
  import "./chunk-W4LZ7R6Z.js";
17
17
  import "./chunk-MILKMRPU.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-agent",
3
- "version": "11.1.2",
3
+ "version": "11.1.4",
4
4
  "description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
5
5
  "keywords": [
6
6
  "agent",
@@ -201,6 +201,11 @@ and never silence a failure with a filter, a `.skip`, or a "known flake" note:
201
201
  either your diff broke it, or the test is broken or environment-dependent and
202
202
  you fix the test.
203
203
 
204
+ **A schema change regenerates its pages.** Run the project's own generate step
205
+ after changing the schema (in Conveyor, `bun run db:generate` rewrites
206
+ `docs/schema`) and commit the regenerated pages with the change. Never edit a
207
+ schema page by hand: CI fails a pull request whose pages are stale.
208
+
204
209
  **Long gates in a pod: background them the sanctioned way.** Launch a long
205
210
  gate with the harness's `run_in_background` Bash option and end the turn — the
206
211
  runner tracks the launch, holds pod liveness while a gate process is alive,
@@ -291,6 +296,22 @@ in chat and mark it Complete.
291
296
 
292
297
  ## Open the PR
293
298
 
299
+ ### The PR body
300
+
301
+ Write the parts a person reads; Conveyor appends the rest.
302
+
303
+ - `## Summary`: 2-4 sentences on what changed and why.
304
+ - `## User flow`: for a user-facing change, the steps a person takes and what
305
+ they see.
306
+ - `## Screenshots`: the captures from Verify (the existing rule above).
307
+ - `## Happy path & edge cases`: 3-6 bullets: the paths you verified, and the
308
+ edge cases you deliberately did NOT handle, so a reviewer can veto
309
+ over-engineering or ask for one.
310
+
311
+ Never write `## Schema & wire changes` or `## Showcase` yourself: Conveyor
312
+ appends each one when it applies (a project with schema pages whose PR changed
313
+ them; a card with showcase attachments) when it opens the PR. Say why the schema changed in the Summary instead.
314
+
294
315
  ### Readiness policy
295
316
 
296
317
  A newer base alone is not a reason to refresh an already-green branch. Keep that
@@ -151,6 +151,13 @@ Actionability bar — every step must survive a context-free reader:
151
151
  - No "as discussed", no links to this chat, no TODOs the executor must
152
152
  research from scratch.
153
153
 
154
+ **A plan that changes stored data or the wire contract adds a `## Schema
155
+ impact` block** ([references/plan-format.md](references/plan-format.md)): the
156
+ models it touches in a `schema` fence, the proposed delta as a `mermaid`
157
+ `erDiagram`, and one line on which existing field or relation already stores
158
+ the fact. That line is where a denormalization gets caught, such as a coach's
159
+ authority copied into a permission field when a role relation already records it.
160
+
154
161
  **Close with the Builder briefing, and write it for the NEXT session.** Every
155
162
  other section addresses a reader; this one addresses the agent that will inherit
156
163
  this card having read the card and nothing else — no research, no dead ends, no
@@ -2,13 +2,26 @@
2
2
 
3
3
  ## Plan Format
4
4
 
5
- ```markdown
5
+ ````markdown
6
6
  ## Objective
7
7
  One sentence: what this task accomplishes and why.
8
8
 
9
9
  ## Approach
10
10
  High-level strategy with relevant files/patterns/APIs.
11
11
 
12
+ ## Schema impact
13
+ Only when the plan changes stored data or the wire contract; omit it otherwise.
14
+ ```schema
15
+ Task
16
+ ```
17
+ ```mermaid
18
+ erDiagram
19
+ Task {
20
+ String reviewNote "added, optional"
21
+ }
22
+ ```
23
+ Already stored? The existing field or relation that holds this fact today, or "none".
24
+
12
25
  ## Implementation Steps
13
26
  1. Concrete step.
14
27
  2. Concrete step.
@@ -26,7 +39,24 @@ High-level strategy with relevant files/patterns/APIs.
26
39
  - **Already decided:** choices the builder should not reopen, one line of why each.
27
40
  - **Traps:** what looks right and is not.
28
41
  - **Verify in this order:** cheapest disqualifying check first.
29
- ```
42
+ ````
43
+
44
+ ## Schema impact — propose the delta, never a page
45
+
46
+ Only a plan that changes stored data or the wire contract carries this block.
47
+
48
+ - A `schema` fence names the models the plan touches. Each renders as its
49
+ current diagram from the project's generated schema pages, so a reviewer
50
+ sees what exists before the change.
51
+ - A `mermaid` `erDiagram` shows the proposed delta: only the models and fields
52
+ that change, each change named in its quoted comment (`"added"`,
53
+ `"removed"`, `"renamed from x"`).
54
+ - One line answers **which existing field or relation already stores this
55
+ fact?** "None" is a fine answer. A second copy of a fact (a permission column
56
+ beside the role that grants it) needs a stated reason, or it is a
57
+ denormalization to design out now.
58
+ - Never write or edit a schema page in a plan. The builder changes the schema
59
+ and regenerates the pages, which then record what actually shipped.
30
60
 
31
61
  ## Citations — ground every code step in the code
32
62
 
@@ -55,10 +55,16 @@ the loop.
55
55
  1. `mcp__conveyor__get_task` for the plan — you cannot judge "does this do what
56
56
  it says" without the "what it says".
57
57
  2. **Ask the PR what you are reviewing, BEFORE any diff:**
58
- `gh pr view <pr> --json state,baseRefName,headRefOid,files`. The PR's base is
58
+ `gh pr view <pr> --json state,baseRefName,headRefOid,files,body`. The PR's base is
59
59
  often not the project default branch, and asking costs one call instead of
60
60
  six spent guessing.
61
- 3. Get the diff with the **merge-base** form, never two-dot, and **fetch the
61
+ 3. **Read the PR body's `## Schema & wire changes` section first** when it has
62
+ one (Conveyor generates it from the changed files). Check each model and
63
+ contract it lists against the plan's `## Schema impact` block: a model the
64
+ plan never named, or a proposed delta that did not land, is a finding. The
65
+ section lists the files as they were at the last `create_pull_request`
66
+ call; when it disagrees with the diff, the diff wins.
67
+ 4. Get the diff with the **merge-base** form, never two-dot, and **fetch the
62
68
  base first** — a pod clones single-branch, so `origin/<base>` does not exist
63
69
  until you ask for it and the diff fails or silently compares against nothing:
64
70
 
@@ -69,18 +75,18 @@ the loop.
69
75
  Two-dot (`git diff <base>..HEAD`) compares against the base TIP, so it
70
76
  reports already-merged commits as part of this change and sends you reviewing
71
77
  code nobody here wrote.
72
- 4. **When the diff and the PR disagree, the PR wins.** Diff the head SHA
78
+ 5. **When the diff and the PR disagree, the PR wins.** Diff the head SHA
73
79
  directly instead (`git diff <headSha>^ <headSha>`). Your checkout can be
74
80
  stale and so can the remote branch tip — a merged PR's commit may be
75
81
  reachable only by SHA. If the PR reports `MERGED` or `CLOSED`, say so and
76
82
  review the recorded head SHA rather than assuming your tree matches it.
77
- 5. **Read the code under review out of the PR's commit, not the working tree:**
83
+ 6. **Read the code under review out of the PR's commit, not the working tree:**
78
84
  `git show <sha>:<path>` and `git grep <pattern> <sha>`. Grepping the working
79
85
  tree when the PR is based elsewhere returns confident, wrong answers — it has
80
86
  produced false review findings.
81
- 6. Read the surrounding code before judging consistency. A pattern is only a
87
+ 7. Read the surrounding code before judging consistency. A pattern is only a
82
88
  pattern if the neighbours share it.
83
- 7. `mcp__conveyor__get_tag` on the card's tags — a tag's overview and linked
89
+ 8. `mcp__conveyor__get_tag` on the card's tags — a tag's overview and linked
84
90
  rules are what "follows existing patterns" actually means in this project.
85
91
 
86
92
  ## Criteria
@@ -96,6 +102,11 @@ the loop.
96
102
  - **Test coverage** — are new paths tested? Edge cases covered? A test that
97
103
  asserts nothing is worse than no test, because it reads as coverage.
98
104
  - **Typing** — proper types, no unnecessary `any`, correct async/await.
105
+ - **Data model** — a fact stored twice (denormalization), a nullable column
106
+ with no stated reason, a relation that duplicates an existing path, a
107
+ contract member without `describe`, and a hand-edited or stale schema page
108
+ (its generated header line is missing, or the project's generate step leaves
109
+ a diff).
99
110
  - **Naming and readability** — clear names, and no comment that says something
100
111
  the code does not do.
101
112
 
@@ -112,6 +112,14 @@ labels. Each tag carries a `description` (≤255 — the summary), an `overview`
112
112
  overview/description only when your change altered what the term means, add
113
113
  the tag to the card only when the work is genuinely about that area, and
114
114
  skip freely otherwise. Never bulk-assign tags from path matches alone.
115
+ - **The schema note**: on a project with schema pages, the in-pod
116
+ `create_pull_request` also returns a "Schema & wire changes detected" line
117
+ (`schemaNote`) naming the changed models, contracts and schema sources, and
118
+ the PR body carries the generated section (on both surfaces). When it says
119
+ the schema sources changed but no page did, regenerate the pages, commit
120
+ them, and call `create_pull_request` again: it reuses the open PR and
121
+ rewrites the section. A project without schema pages
122
+ can set them up with the public guide `guides/schema-pages`.
115
123
 
116
124
  ## Execute
117
125