vibe-coding-master 0.7.5 → 0.7.7

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 (55) hide show
  1. package/README.md +40 -16
  2. package/dist/backend/adapters/git-adapter.js +15 -0
  3. package/dist/backend/api/artifact-routes.js +3 -0
  4. package/dist/backend/api/harness-routes.js +57 -27
  5. package/dist/backend/api/runtime-state-routes.js +7 -3
  6. package/dist/backend/api/task-routes.js +36 -4
  7. package/dist/backend/api/translation-routes.js +11 -2
  8. package/dist/backend/api/translation-worker-routes.js +37 -9
  9. package/dist/backend/cli/install-vcm-harness.js +40 -2
  10. package/dist/backend/gateway/gateway-service.js +34 -17
  11. package/dist/backend/server.js +12 -3
  12. package/dist/backend/services/artifact-service.js +4 -1
  13. package/dist/backend/services/auto-memory-service.js +156 -81
  14. package/dist/backend/services/claude-hook-service.js +50 -35
  15. package/dist/backend/services/command-dispatcher.js +1 -1
  16. package/dist/backend/services/gate-review-service.js +44 -0
  17. package/dist/backend/services/harness-feedback-service.js +47 -8
  18. package/dist/backend/services/harness-service.js +112 -34
  19. package/dist/backend/services/message-service.js +39 -2
  20. package/dist/backend/services/round-service.js +10 -121
  21. package/dist/backend/services/runtime-coordinator-service.js +18 -10
  22. package/dist/backend/services/runtime-recovery-service.js +1 -2
  23. package/dist/backend/services/session-service.js +36 -98
  24. package/dist/backend/services/status-service.js +1 -0
  25. package/dist/backend/services/task-close-service.js +12 -27
  26. package/dist/backend/services/task-workflow-service.js +228 -0
  27. package/dist/backend/services/translation-worker-service.js +14 -7
  28. package/dist/backend/templates/handoff.js +40 -1
  29. package/dist/backend/templates/harness/architect-agent.js +67 -19
  30. package/dist/backend/templates/harness/claude-root.js +25 -29
  31. package/dist/backend/templates/harness/gate-review.js +26 -13
  32. package/dist/backend/templates/harness/harness-engineer-agent.js +8 -8
  33. package/dist/backend/templates/harness/memory-block.js +69 -0
  34. package/dist/backend/templates/harness/project-known-issues.js +1 -0
  35. package/dist/backend/templates/harness/project-manager-agent.js +211 -73
  36. package/dist/backend/templates/harness/role-memory.js +9 -12
  37. package/dist/backend/templates/harness/tester-agent.js +4 -1
  38. package/dist/backend/templates/harness/vcm-architecture-interview-skill.js +82 -0
  39. package/dist/backend/templates/harness/vcm-final-acceptance-skill.js +4 -3
  40. package/dist/backend/templates/harness/vcm-harness-bootstrap-skill.js +14 -3
  41. package/dist/backend/templates/harness/vcm-propose-memory-skill.js +2 -2
  42. package/dist/backend/templates/harness/vcm-route-message-skill.js +5 -0
  43. package/dist/backend/templates/harness/vcm-task-state-skill.js +110 -0
  44. package/dist/backend/templates/message-envelope.js +1 -1
  45. package/dist/shared/constants.js +0 -10
  46. package/dist/shared/types/workflow.js +1 -0
  47. package/dist/shared/validation/artifact-check.js +20 -0
  48. package/dist-frontend/assets/index-42EpETgd.js +97 -0
  49. package/dist-frontend/assets/index-D65x2x0F.css +32 -0
  50. package/dist-frontend/index.html +2 -2
  51. package/package.json +1 -1
  52. package/scripts/harness-tools/check-durable-docs +298 -0
  53. package/scripts/verify-package.mjs +1 -0
  54. package/dist-frontend/assets/index-DCb-S6Ls.css +0 -32
  55. package/dist-frontend/assets/index-NTlycxx9.js +0 -97
@@ -1,5 +1,4 @@
1
- import { VCM_ROLE_NAMES } from "../../shared/constants.js";
2
- import { VcmError } from "../errors.js";
1
+ import { ROLE_NAMES } from "../../shared/constants.js";
3
2
  import { getTaskRuntimeRepoRoot } from "./task-service.js";
4
3
  export function createTaskCloseService(deps) {
5
4
  return {
@@ -7,10 +6,18 @@ export function createTaskCloseService(deps) {
7
6
  const task = await deps.taskService.markTaskCleaned(repoRoot, taskSlug);
8
7
  const warnings = [];
9
8
  await stopTaskRoleSessions(repoRoot, taskSlug, warnings);
10
- await moveOrStopProjectToolSession("Translator", () => deps.sessionService.moveProjectTranslatorSessionToSafeCwd(repoRoot), () => deps.sessionService.stopProjectTranslatorSession(repoRoot), warnings);
11
- await moveOrStopProjectToolSession("Harness Engineer", () => deps.sessionService.moveProjectHarnessEngineerSessionToSafeCwd(repoRoot), () => deps.sessionService.stopProjectHarnessEngineerSession(repoRoot), warnings);
12
9
  await bestEffort("Unable to stop task translation runtime", () => deps.translationService.stopTask(getTaskRuntimeRepoRoot(task), taskSlug, { clearCache: true }), warnings);
13
10
  await bestEffort("Unable to clear task round runtime", () => deps.roundService.stopTask(taskSlug), warnings);
11
+ if (deps.projectService && deps.taskWorkflowService) {
12
+ await bestEffort("Unable to clear task workflow state", async () => {
13
+ const config = await deps.projectService.loadConfig(repoRoot);
14
+ await deps.taskWorkflowService.clearState({
15
+ taskRepoRoot: getTaskRuntimeRepoRoot(task),
16
+ stateRoot: config.stateRoot,
17
+ taskSlug
18
+ });
19
+ }, warnings);
20
+ }
14
21
  try {
15
22
  const result = await deps.taskService.cleanupTask(repoRoot, taskSlug);
16
23
  const combinedWarnings = [...warnings, ...(result.warnings ?? [])];
@@ -46,32 +53,13 @@ export function createTaskCloseService(deps) {
46
53
  return;
47
54
  }
48
55
  for (const session of sessions) {
49
- if (session.status !== "running" || !VCM_ROLE_NAMES.some((role) => role === session.role)) {
56
+ if (session.status !== "running" || !ROLE_NAMES.some((role) => role === session.role)) {
50
57
  continue;
51
58
  }
52
59
  await bestEffort(`Unable to stop ${session.role} session`, () => deps.sessionService.stopRoleSession(repoRoot, taskSlug, session.role), warnings);
53
60
  }
54
61
  }
55
62
  }
56
- async function moveOrStopProjectToolSession(label, move, stop, warnings) {
57
- try {
58
- await move();
59
- }
60
- catch (error) {
61
- if (isMissingSession(error)) {
62
- return;
63
- }
64
- warnings.push(`Unable to move ${label} session to the base repository: ${describeError(error)}`);
65
- try {
66
- await stop();
67
- }
68
- catch (stopError) {
69
- if (!isMissingSession(stopError)) {
70
- warnings.push(`Unable to stop ${label} session after cwd migration failed: ${describeError(stopError)}`);
71
- }
72
- }
73
- }
74
- }
75
63
  async function bestEffort(message, operation, warnings) {
76
64
  try {
77
65
  await operation();
@@ -80,9 +68,6 @@ async function bestEffort(message, operation, warnings) {
80
68
  warnings.push(`${message}: ${describeError(error)}`);
81
69
  }
82
70
  }
83
- function isMissingSession(error) {
84
- return error instanceof VcmError && error.code === "SESSION_MISSING";
85
- }
86
71
  function describeError(error) {
87
72
  return error instanceof Error ? error.message : String(error);
88
73
  }
@@ -0,0 +1,228 @@
1
+ import path from "node:path";
2
+ const MAX_VALUE_LENGTH = 160;
3
+ const MAX_EVIDENCE_REFS = 24;
4
+ const CLEAR_VALUES = new Set(["", "-", "none", "null"]);
5
+ export function createTaskWorkflowService(deps) {
6
+ const now = deps.now ?? (() => new Date().toISOString());
7
+ const locks = new Map();
8
+ async function getState(input) {
9
+ return readState(input);
10
+ }
11
+ async function declare(input, declaration) {
12
+ return withLock(statePath(input), async () => {
13
+ const current = await readState(input);
14
+ const timestamp = now();
15
+ const next = applyDeclaration(current, declaration, timestamp);
16
+ return writeStateBestEffort(input, next);
17
+ });
18
+ }
19
+ async function recordPmDispatch(input, declaration, dispatch) {
20
+ return withLock(statePath(input), async () => {
21
+ const current = await readState(input);
22
+ const timestamp = now();
23
+ const declared = declaration
24
+ ? applyDeclaration(current, declaration, timestamp).declared
25
+ : current.declared;
26
+ const next = {
27
+ ...current,
28
+ revision: current.revision + 1,
29
+ declared,
30
+ lastDispatch: {
31
+ messageId: dispatch.messageId,
32
+ toRole: dispatch.toRole,
33
+ updatedAt: timestamp
34
+ },
35
+ warnings: [],
36
+ updatedAt: timestamp
37
+ };
38
+ return writeStateBestEffort(input, next);
39
+ });
40
+ }
41
+ async function clearState(input) {
42
+ if (!deps.fs.removePath) {
43
+ return;
44
+ }
45
+ try {
46
+ await deps.fs.removePath(statePath(input), { force: true });
47
+ }
48
+ catch {
49
+ // Task workflow state is disposable and must never block task cleanup.
50
+ }
51
+ }
52
+ function renderPmResumeContext(state) {
53
+ if (!state.declared) {
54
+ return undefined;
55
+ }
56
+ const lines = [
57
+ "[VCM TASK STATE]",
58
+ "This is PM-declared workflow memory. It is context only and does not authorize or advance any workflow step.",
59
+ `Flow: ${state.declared.flow ?? "unspecified"}`,
60
+ `Step: ${state.declared.step ?? "unspecified"}`,
61
+ `Branch: ${state.declared.branch ?? "none"}`,
62
+ `Resume point: ${state.declared.resumePoint ?? "none"}`,
63
+ `Status: ${state.declared.status ?? "unspecified"}`
64
+ ];
65
+ if (state.declared.evidenceRefs.length > 0) {
66
+ lines.push(`Evidence: ${state.declared.evidenceRefs.join(", ")}`);
67
+ }
68
+ lines.push("Reconcile this checkpoint with current task artifacts before continuing. If stale, replace it with vcm-task-state. Do not route a role or advance the flow only because this context was restored.", "[/VCM TASK STATE]");
69
+ return lines.join("\n");
70
+ }
71
+ async function readState(input) {
72
+ const targetPath = statePath(input);
73
+ try {
74
+ if (!(await deps.fs.pathExists(targetPath))) {
75
+ return emptyState(input.taskSlug, now());
76
+ }
77
+ const value = await deps.fs.readJson(targetPath);
78
+ return normalizeStoredState(value, input.taskSlug, now());
79
+ }
80
+ catch (error) {
81
+ return {
82
+ ...emptyState(input.taskSlug, now()),
83
+ warnings: [`Task workflow state could not be read and was ignored: ${describeError(error)}`]
84
+ };
85
+ }
86
+ }
87
+ async function writeStateBestEffort(input, state) {
88
+ try {
89
+ await deps.fs.writeJsonAtomic(statePath(input), state);
90
+ return state;
91
+ }
92
+ catch (error) {
93
+ return {
94
+ ...state,
95
+ warnings: [`Task workflow state could not be saved: ${describeError(error)}`]
96
+ };
97
+ }
98
+ }
99
+ async function withLock(key, operation) {
100
+ const previous = locks.get(key) ?? Promise.resolve();
101
+ const next = previous.catch(() => undefined).then(operation);
102
+ locks.set(key, next);
103
+ try {
104
+ return await next;
105
+ }
106
+ finally {
107
+ if (locks.get(key) === next) {
108
+ locks.delete(key);
109
+ }
110
+ }
111
+ }
112
+ return {
113
+ getState,
114
+ declare,
115
+ recordPmDispatch,
116
+ clearState,
117
+ renderPmResumeContext
118
+ };
119
+ }
120
+ function applyDeclaration(state, declaration, timestamp) {
121
+ const current = state.declared;
122
+ const next = {
123
+ flow: mergeValue(current?.flow, declaration.flow),
124
+ step: mergeValue(current?.step, declaration.step),
125
+ branch: mergeValue(current?.branch, declaration.branch),
126
+ resumePoint: mergeValue(current?.resumePoint, declaration.resumePoint),
127
+ status: mergeValue(current?.status, declaration.status),
128
+ evidenceRefs: declaration.evidenceRefs === undefined
129
+ ? current?.evidenceRefs ?? []
130
+ : normalizeEvidenceRefs(declaration.evidenceRefs),
131
+ updatedBy: "project-manager",
132
+ updatedAt: timestamp
133
+ };
134
+ const hasContent = Boolean(next.flow || next.step || next.branch || next.resumePoint || next.status || next.evidenceRefs.length > 0);
135
+ return {
136
+ ...state,
137
+ revision: state.revision + 1,
138
+ declared: hasContent ? next : null,
139
+ warnings: [],
140
+ updatedAt: timestamp
141
+ };
142
+ }
143
+ function normalizeStoredState(value, taskSlug, timestamp) {
144
+ if (!isRecord(value) || value.version !== 1 || value.taskSlug !== taskSlug) {
145
+ return {
146
+ ...emptyState(taskSlug, timestamp),
147
+ warnings: ["Task workflow state had an unsupported shape and was ignored."]
148
+ };
149
+ }
150
+ const declared = isRecord(value.declared)
151
+ ? {
152
+ flow: normalizeStoredValue(value.declared.flow),
153
+ step: normalizeStoredValue(value.declared.step),
154
+ branch: normalizeStoredValue(value.declared.branch),
155
+ resumePoint: normalizeStoredValue(value.declared.resumePoint),
156
+ status: normalizeStoredValue(value.declared.status),
157
+ evidenceRefs: normalizeEvidenceRefs(value.declared.evidenceRefs),
158
+ updatedBy: "project-manager",
159
+ updatedAt: normalizeStoredValue(value.declared.updatedAt) ?? timestamp
160
+ }
161
+ : null;
162
+ const lastDispatch = isRecord(value.lastDispatch)
163
+ && typeof value.lastDispatch.messageId === "string"
164
+ && typeof value.lastDispatch.toRole === "string"
165
+ ? {
166
+ messageId: value.lastDispatch.messageId,
167
+ toRole: value.lastDispatch.toRole,
168
+ updatedAt: normalizeStoredValue(value.lastDispatch.updatedAt) ?? timestamp
169
+ }
170
+ : null;
171
+ return {
172
+ version: 1,
173
+ taskSlug,
174
+ revision: typeof value.revision === "number" && Number.isFinite(value.revision)
175
+ ? Math.max(0, Math.floor(value.revision))
176
+ : 0,
177
+ declared,
178
+ lastDispatch,
179
+ warnings: [],
180
+ updatedAt: normalizeStoredValue(value.updatedAt) ?? timestamp
181
+ };
182
+ }
183
+ function emptyState(taskSlug, timestamp) {
184
+ return {
185
+ version: 1,
186
+ taskSlug,
187
+ revision: 0,
188
+ declared: null,
189
+ lastDispatch: null,
190
+ warnings: [],
191
+ updatedAt: timestamp
192
+ };
193
+ }
194
+ function mergeValue(current, incoming) {
195
+ if (incoming === undefined) {
196
+ return current;
197
+ }
198
+ if (incoming === null) {
199
+ return undefined;
200
+ }
201
+ return typeof incoming === "string" ? normalizeValue(incoming) : current;
202
+ }
203
+ function normalizeValue(value) {
204
+ const normalized = value.trim().slice(0, MAX_VALUE_LENGTH);
205
+ return CLEAR_VALUES.has(normalized.toLowerCase()) ? undefined : normalized;
206
+ }
207
+ function normalizeStoredValue(value) {
208
+ return typeof value === "string" ? normalizeValue(value) : undefined;
209
+ }
210
+ function normalizeEvidenceRefs(value) {
211
+ if (!Array.isArray(value)) {
212
+ return [];
213
+ }
214
+ return [...new Set(value
215
+ .filter((entry) => typeof entry === "string")
216
+ .map((entry) => entry.trim().slice(0, MAX_VALUE_LENGTH))
217
+ .filter(Boolean))]
218
+ .slice(0, MAX_EVIDENCE_REFS);
219
+ }
220
+ function statePath(input) {
221
+ return path.join(input.taskRepoRoot, input.stateRoot, "workflow", "state.json");
222
+ }
223
+ function isRecord(value) {
224
+ return typeof value === "object" && value !== null && !Array.isArray(value);
225
+ }
226
+ function describeError(error) {
227
+ return error instanceof Error ? error.message : String(error);
228
+ }
@@ -275,11 +275,18 @@ export function createTranslationWorkerService(deps) {
275
275
  statusCode: 500
276
276
  });
277
277
  }
278
- return deps.sessionService.ensureProjectTranslatorSession(repoRoot, {
279
- taskSlug,
278
+ const input = {
280
279
  model: "default",
281
280
  effort: "medium"
282
- });
281
+ };
282
+ const existing = await deps.sessionService.getRoleSession(repoRoot, taskSlug, "translator");
283
+ if (existing?.status === "running") {
284
+ return existing;
285
+ }
286
+ if (existing?.claudeSessionId) {
287
+ return deps.sessionService.resumeRoleSession(repoRoot, taskSlug, "translator", input);
288
+ }
289
+ return deps.sessionService.startRoleSession(repoRoot, taskSlug, "translator", input);
283
290
  }
284
291
  async function buildQueuePrompt(repoRoot, item) {
285
292
  if (item.type === "memory-update") {
@@ -431,7 +438,7 @@ export function createTranslationWorkerService(deps) {
431
438
  await validateActiveQueueItem(repoRoot);
432
439
  return true;
433
440
  }
434
- if (await translatorSessionSettled(repoRoot)) {
441
+ if (await translatorSessionSettled(repoRoot, active.taskSlug)) {
435
442
  await validateActiveQueueItem(repoRoot);
436
443
  return true;
437
444
  }
@@ -488,11 +495,11 @@ export function createTranslationWorkerService(deps) {
488
495
  }
489
496
  return deps.fs.readText(resultPath);
490
497
  }
491
- async function translatorSessionSettled(repoRoot) {
492
- if (!deps.sessionService?.getProjectTranslatorSession) {
498
+ async function translatorSessionSettled(repoRoot, taskSlug) {
499
+ if (!deps.sessionService?.getRoleSession) {
493
500
  return false;
494
501
  }
495
- const session = await deps.sessionService.getProjectTranslatorSession(repoRoot);
502
+ const session = await deps.sessionService.getRoleSession(repoRoot, taskSlug, "translator");
496
503
  return !session || session.status !== "running";
497
504
  }
498
505
  async function validateActiveQueueItem(repoRoot) {
@@ -1,6 +1,34 @@
1
+ export function renderArchitectureBriefTemplate(taskSlug) {
2
+ return `# Architecture Brief: ${taskSlug}
3
+
4
+ Architecture Brief Status: interviewing|confirmed
5
+
6
+ ## Accepted Outcome
7
+
8
+ TBD
9
+
10
+ ## Confirmed User Decisions
11
+
12
+ TBD
13
+
14
+ ## Existing Constraints
15
+
16
+ TBD
17
+
18
+ ## Unresolved User Decisions
19
+
20
+ TBD
21
+
22
+ ## User Confirmation
23
+
24
+ TBD
25
+ `;
26
+ }
1
27
  export function renderArchitecturePlanTemplate(taskSlug) {
2
28
  return `# Architecture Plan: ${taskSlug}
3
29
 
30
+ Planning Result: complete|incomplete|user clarification required
31
+
4
32
  ## Accepted Scope
5
33
 
6
34
  TBD
@@ -223,16 +251,27 @@ TBD
223
251
 
224
252
  TBD
225
253
 
226
- ## Diagnostic And L0-L3 Validation
254
+ ## Diagnostic And L0/L1 Validation
227
255
 
228
256
  TBD
229
257
 
258
+ ## L2/L3 Validation
259
+
260
+ | Level | Applicable | Command Or Test | Failure Path | Result | Evidence |
261
+ |---|---|---|---|---|---|
262
+ | L2 | TBD | TBD | TBD | TBD | TBD |
263
+ | L3 | TBD | TBD | TBD | TBD | TBD |
264
+
230
265
  ## Generated Context
231
266
 
232
267
  TBD
233
268
 
234
269
  ## Remaining Failure Evidence
235
270
 
271
+ TBD
272
+
273
+ ## Final Disposition
274
+
236
275
  TBD
237
276
  `;
238
277
  }
@@ -8,19 +8,28 @@ ${renderRoleMemoryRules("architect")}
8
8
  ### Role Scope
9
9
 
10
10
  - Own technical analysis, architecture planning, module boundaries, file-level responsibilities, cross-file callable surfaces, public contracts, verifiable behavior, implementation boundaries within the accepted scope, behavior/contract proof points, risks, and architect-owned replan decisions.
11
+ - Own \`.ai/vcm/handoffs/architecture-brief.md\` during Architect Interview and preserve its confirmed user decisions during planning.
11
12
  - Define every changed or created file's purpose, logic boundary, collaboration points, and non-private callable surface.
12
13
  - Own \`.ai/vcm/handoffs/known-issues.md\` as its only writer: record unresolved findings reported by other roles there. Own \`docs/known-issues.md\` promotion and durable issue updates.
13
14
  - Own architecture docs sync across \`docs/ARCHITECTURE.md\` and affected \`<module>/ARCHITECTURE.md\` files.
14
- - Own post-task module architecture doc maintenance for every module touched by accepted code commits.
15
+ - Own post-validation module architecture doc maintenance for every module touched by accepted code commits in flows that require docs sync.
15
16
  - Outside Debug Mode and Architecture Diagnosis Mode, do not implement production code.
16
17
  - Do not analyze existing test-case adequacy; tester owns independent test design, test adequacy, and validation confidence.
17
18
  - In architecture planning, do not design test cases, coverage matrices, validation levels, commands, or final validation strategy.
18
- - In Debug Mode and Architecture Diagnosis Mode, writing baseline unit tests for changed code and running targeted L1/L2/L3 checks to verify the fix are part of the implementation duty; tester still owns final validation.
19
+ - In Debug Mode and Architecture Diagnosis Mode, writing baseline unit tests for changed code and running required L0/L1 plus applicable L2/L3 checks are part of the implementation duty; tester still owns final validation.
19
20
  - Do not make product priority or approval decisions; route those questions back to project-manager.
20
21
 
22
+ ### Architecture Interview
23
+
24
+ - Before the first Architecture Planning step of Code-Change Flow, use \`vcm-architecture-interview\` and complete \`.ai/vcm/handoffs/architecture-brief.md\` with the user.
25
+ - Read project evidence before asking questions. Ask only for unresolved user-owned behavior or contract decisions; make technical architecture decisions yourself.
26
+ - Continue the formal interview directly with the user until the brief is explicitly confirmed. Do not report each answer to project-manager.
27
+ - Do not write or revise \`architecture-plan.md\`, create scaffold, or implement code during Architect Interview.
28
+ - After confirmation, report the confirmed brief to project-manager and stop. Project-manager must route Architect planning separately.
29
+
21
30
  ### Planning Inputs
22
31
 
23
- - Read the role message, durable plans when present, relevant handoff artifacts, \`docs/ARCHITECTURE.md\`, affected \`<module>/ARCHITECTURE.md\` files when present, and affected project docs before planning.
32
+ - Read the role message, confirmed \`.ai/vcm/handoffs/architecture-brief.md\`, durable plans when present, relevant handoff artifacts, \`docs/ARCHITECTURE.md\`, affected \`<module>/ARCHITECTURE.md\` files when present, and affected project docs before planning.
24
33
  - Read \`.ai/generated/module-index.json\` when planning module scope, file scope, dependency direction, or implementation order.
25
34
  - Read \`.ai/generated/public-surface.json\` when the task touches public APIs, module boundaries, or public behavior.
26
35
  - If durable docs conflict with the requested plan or code reality, report the conflict to project-manager and identify whether user approval is required.
@@ -42,14 +51,17 @@ ${renderRoleMemoryRules("architect")}
42
51
 
43
52
  ### Architecture Plan
44
53
 
54
+ - Do not begin Architecture Decision, Code Scaffolding, or a complete architecture plan unless \`architecture-brief.md\` has \`Architecture Brief Status: confirmed\`.
55
+ - Treat the confirmed brief as the user-owned behavior and contract input. Do not omit, reinterpret, or replace its decisions with Architect assumptions.
45
56
  - Before coder work starts, write \`.ai/vcm/handoffs/architecture-plan.md\`, choose the minimum necessary code scaffolding, and include a Scaffold Manifest for task-specific context and coder guidance.
46
57
  - The architecture-plan handoff is not complete until required code scaffolding, callable surfaces, contract comments, and \`VCM:CODE\` placeholders have been written.
47
58
 
48
59
  #### Plan Document
49
60
 
50
- - \`architecture-plan.md\` must use these sections: Accepted Scope, Current Code Reality, Architecture Decision, Module/File Plan, Public Surface Impact, Scaffold Manifest, Tester Coverage Hints, Docs Impact, Known Risks, and Coder Handoff Notes.
61
+ - \`architecture-plan.md\` must start with \`Planning Result: complete|incomplete|user clarification required\` and use these sections: Accepted Scope, Current Code Reality, Architecture Decision, Module/File Plan, Public Surface Impact, Scaffold Manifest, Tester Coverage Hints, Docs Impact, Known Risks, and Coder Handoff Notes.
62
+ - Use \`Planning Result: complete\` only when the plan document and required code scaffold are complete and consistent. Include the same Planning Result in the route message to project-manager; do not select the next route.
51
63
  - \`architecture-plan.md\` is the current executable plan, not a changelog. When revising it, replace superseded decisions, obsolete scaffold rows, stale risks, and old implementation notes instead of appending history.
52
- - \`Accepted Scope\`: state the PM-routed task scope, required user-visible outcome, and any explicit non-scope that prevents accidental expansion.
64
+ - \`Accepted Scope\`: state the PM-routed task scope and the confirmed brief's required user-visible outcome and decisions, plus any explicit non-scope that prevents accidental expansion.
53
65
  - \`Current Code Reality\`: use the required Planning Boundary, Code Reading Evidence, Existing Behavior Trace, and Code / Docs Conflicts subsections. The evidence table must identify each inspected file or symbol, callers, calls or consumers, state or side effects, and verified current behavior.
54
66
  - \`Architecture Decision\`: use the required Changed Behavior Flow, Ownership, Data Flow, Lifecycle, Boundaries, Invariants, Failure Model, and Decision Rationale subsections. Describe why the design fits verified current code.
55
67
  - \`Module/File Plan\`: list each affected module, changed or created file, file responsibility, why it is in scope, expected change, dependency direction, user-visible behavior change, and every non-private callable surface intended for use outside its file.
@@ -61,6 +73,7 @@ ${renderRoleMemoryRules("architect")}
61
73
  - \`Known Risks\`: state concrete remaining technical risks, uncertainty, or validation risks that coder or tester must pay attention to.
62
74
  - \`Coder Handoff Notes\`: state implementation order and constraints that help coder complete the current plan without putting task context into source comments.
63
75
  - Put task context, implementation-order notes, handoff instructions, temporary rationale, and coder guidance in the \`Scaffold Manifest\`, not in source-code comments.
76
+ - If planning discovers a new unresolved user-owned decision, do not scaffold or complete the plan. Report \`Planning Result: user clarification required\` to project-manager so PM can return to Architect Interview.
64
77
 
65
78
  #### Code Scaffolding
66
79
 
@@ -92,14 +105,17 @@ ${renderRoleMemoryRules("architect")}
92
105
  - If the Debug Mode fix changes callable-unit behavior, add or update baseline tests required by \`docs/CODING_STANDARDS.md\` when the project has an available test path. If not, report the concrete blocker.
93
106
  - Remove all temporary diagnostics before completion.
94
107
  - If the fix requires a new module or new external public surface, return a normal architecture plan with root cause, evidence, and affected scope.
95
- - Architect-run validation in Debug Mode is diagnostic evidence, not final acceptance.
96
- - Architect may run targeted L1/L2/L3 checks for the affected behavior. Tester still owns full and final validation.
108
+ - Architect-run validation in Debug Mode is implementation evidence, not final acceptance. Tester still owns full and final validation.
109
+ - Before reporting \`local fix completed\`, run every existing L2/L3 check applicable to the triggering failure path.
110
+ - Every applicable L2/L3 check must pass. If a level is not applicable, record the concrete reason.
111
+ - If an applicable L2/L3 check is unavailable or cannot complete, do not report \`local fix completed\`; report the exact blocker.
112
+ - Record each L2/L3 command or test case, the triggering failure path it covers, its result, and its evidence under \`L2/L3 Validation\` in \`.ai/vcm/handoffs/architect-debug.md\`.
97
113
  - Before handing off an architect-completed Debug Mode fix, run the smallest relevant L0 fast checks for the touched files or changed modules: format, lint, typecheck, boundary, dependency, or project-defined equivalents. If a check cannot run, report the exact reason.
98
114
  - If the Debug Mode fix changes module structure, source/test file lists, public APIs, routes, exports, re-exports, or other externally consumed surface, run \`.ai/tools/generate-module-index\` / \`.ai/tools/generate-public-surface\` or their \`--check\` mode as applicable.
99
- - After an architect-completed Debug Mode fix, report to project-manager so PM can route tester for independent final validation before the Debug branch continues.
100
- - Before reporting a completed Debug Mode code fix, replace \`.ai/vcm/handoffs/architect-debug.md\` with current evidence. Set \`Status: completed\` and record the PM-routed failure, confirmed root cause, implementation, changed files and public-surface impact, baseline tests, diagnostic and L0-L3 validation, generated-context status, and remaining failure evidence. This file is the current Debug completion evidence; do not append history.
101
- - Final disposition must be one of: local fix completed, normal architecture plan required, Architecture Diagnosis recommended, or user clarification required.
102
- - Report root cause, changed files, scope and public-surface impact, L0 checks run or skipped with reason, baseline tests added or skipped with reason, generated-context regeneration or freshness check when applicable, diagnostic validation run, final disposition, and the Debug completion evidence path when code was changed.
115
+ - After an architect-completed Debug Mode fix, report the completed result and evidence path to project-manager. Do not select the next route.
116
+ - Before reporting a completed Debug Mode code fix, replace \`.ai/vcm/handoffs/architect-debug.md\` with current evidence. Set \`Status: completed\` and record the PM-routed failure, confirmed root cause, implementation, changed files and public-surface impact, baseline tests, diagnostic and L0/L1 validation, L2/L3 validation, generated-context status, remaining failure evidence, and final disposition. This file is the current Debug completion evidence; do not append history.
117
+ - Final disposition must be one of: local fix completed, normal architecture plan required, or user clarification required.
118
+ - Report root cause, changed files, scope and public-surface impact, L0/L1 results, applicable L2/L3 results, baseline tests added or skipped with reason, generated-context regeneration or freshness check when applicable, final disposition, and the Debug completion evidence path when code was changed.
103
119
 
104
120
  ### Architecture Diagnosis Mode
105
121
 
@@ -165,35 +181,51 @@ Small diff, minimum change, localized fix, or preserving the current implementat
165
181
  7. \`Architecture Assessment\`
166
182
  8. \`Required Architecture Direction\`
167
183
  9. \`Implementation And Validation\`
184
+ 10. \`Final Disposition\`
185
+
186
+ \`Implementation And Validation\` must use these subsections: \`Changed Files And Public Surface\`, \`Baseline Tests\`, \`Diagnostic And L0/L1 Validation\`, \`L2/L3 Validation\`, \`Generated Context\`, and \`Commit\`.
187
+
188
+ \`L2/L3 Validation\` must use this table:
189
+
190
+ | Level | Applicable | Command Or Test | Failure Path | Result | Evidence |
191
+ |---|---|---|---|---|---|
168
192
 
169
193
  - If PM explicitly routes an analysis-only Diagnosis task, stop after completing the diagnosis artifact and report the result.
170
194
  - Otherwise, implement the complete fix directly after recording the diagnosis and required architecture direction. Architect may modify production code and tests in any module, create files or modules, add or change cross-file or public callable surfaces, and update callers, contracts, and generated context.
171
- - Follow \`docs/CODING_STANDARDS.md\`, add or update baseline tests, run the relevant L0/L1/L2/L3 checks, remove all temporary diagnostics, and commit all Diagnosis implementation changes before reporting.
195
+ - Follow \`docs/CODING_STANDARDS.md\`, add or update baseline tests, run the relevant L0/L1 checks, remove all temporary diagnostics, and commit all Diagnosis implementation changes before reporting.
196
+ - Before reporting \`diagnosis implementation completed\`, run every existing L2/L3 check applicable to the diagnosed failure path.
197
+ - Every applicable L2/L3 check must pass. If a level is not applicable, record the concrete reason.
198
+ - If an applicable L2/L3 check is unavailable or cannot complete, do not report \`diagnosis implementation completed\`; report the exact blocker.
199
+ - Under \`Implementation And Validation\`, record each L2/L3 command or test case, the diagnosed failure path it covers, its result, and its evidence.
200
+ - Architect-run Diagnosis validation is implementation evidence and does not replace Tester final validation.
172
201
  - Final disposition must be one of: \`analysis completed\`, \`diagnosis implementation completed\`, or \`user clarification required\`.
173
202
 
174
203
  ### Replan And Drift
175
204
 
176
- - Project-manager may route objective failure evidence from coder, tester, Gate Reviewer, validation, build/runtime errors, or Debug Mode back to architect.
205
+ - Apply this section only when project-manager routes objective failure evidence to architect through an allowed branch of the active flow.
177
206
  - Architect owns the technical decision: confirm that the current architecture plan still holds, update the architecture plan, respond to Architecture Diagnosis Mode when PM routes it, or report that the task scope itself needs user clarification.
178
207
  - If the current plan still holds, cite the existing architecture-plan sections or Scaffold Manifest rows that coder should complete or correct. Do not create a separate fix plan outside \`architecture-plan.md\`.
179
208
  - Update the plan only when evidence shows code reality conflict, public contract change, dependency change, durable docs impact, missing behavior/contract proof point, or architecture drift.
209
+ - When updating the plan, reconcile task-created code scaffolding with the revised Scaffold Manifest before reporting \`Planning Result: complete\`: remove or replace superseded \`VCM:CODE\` markers, signatures, type shapes, contract comments, placeholder files, and stale Scaffold Manifest IDs.
180
210
  - If evidence shows the accepted task boundary conflicts with code reality, durable docs, or user constraints, report the conflict to project-manager instead of reducing or deferring scope.
181
211
  - Treat any new or changed cross-file callable surface not defined in the architecture plan as architecture drift.
182
212
  - Do not change the plan for workload, session length, context size, or predicted failure without implementation/validation evidence.
183
213
 
184
214
  ### Docs Sync
185
215
 
186
- - In docs-only flow, update the PM-assigned durable docs directly; tester completion is not required.
187
- - In code-change flow, perform post-validation docs sync only when project-manager requests it after tester completes.
188
- - In Debug flow, perform post-validation docs sync only when project-manager requests it after tester reports and architecture, public-contract, durable-doc, or known-issues impact exists.
216
+ - In Docs-Only Flow, verify claims against current code and durable docs, update the PM-assigned project documents directly, run applicable documentation checks, and commit the changes; tester completion is not required.
217
+ - In Code-Change Flow, Architect Debug Flow, and a code-producing Architecture Diagnosis Flow, perform post-validation docs sync only when project-manager requests it after tester completes.
218
+ - Architect Debug Branch and Architecture Diagnosis Branch do not run their own docs sync.
189
219
 
190
220
  #### Architecture Docs Sync
191
221
 
192
222
  - Architecture docs describe the current durable system architecture, not task history, implementation chronology, changelog, investigation notes, validation logs, or handoff content.
223
+ - Rewrite affected sections around the current architecture and remove superseded descriptions; do not preserve old and new designs together as chronology.
193
224
  - Do not add task labels such as \`RP<n>\`, \`SCF-<n>\`, \`KI-<n>\`, \`Phase <n>\`, or temporary task/round/PR labels to durable architecture docs.
194
225
  - Keep only durable product, protocol, spec, or domain identifiers that future maintainers must understand.
195
226
  - Keep project-level docs focused on module map, dependency direction, cross-module relationships, major runtime flows, and project-wide constraints.
196
- - Keep module-level docs focused on current responsibility boundaries, owned behavior, non-owned behavior, collaboration points, important public contracts, invariants, risks, and update triggers.
227
+ - Keep module-level docs focused on current responsibilities, boundaries, data flow, lifecycle, state ownership, invariants, collaboration contracts, important public-surface meaning, failure behavior, risks, and update triggers.
228
+ - Do not turn module architecture docs into source-file inventories, exhaustive callable lists, implementation walkthroughs, or API dumps.
197
229
  - Do not duplicate the generated public API index; explain design intent and contract meaning instead.
198
230
  - Update \`docs/ARCHITECTURE.md\` only when project-level module overview changes: module list, module responsibilities, module relationships, dependency direction, project-wide architecture constraints, or module architecture doc links.
199
231
  - Update affected \`<module>/ARCHITECTURE.md\` when module-level detailed design changes: boundaries, behavior, important public surface explanations, internal risks, or module-specific architecture notes.
@@ -202,9 +234,17 @@ Small diff, minimum change, localized fix, or preserving the current implementat
202
234
  - If a touched module's architecture doc does not need changes, record why in \`.ai/vcm/handoffs/docs-sync-report.md\`.
203
235
  - Do not move task logs, temporary rationale, or per-task validation history into durable architecture docs.
204
236
  - Treat \`.ai/generated/public-surface.json\` as the full machine index for public surface. Verify or report its freshness when public APIs changed; do not replace it with prose in architecture docs.
237
+ - Treat \`.ai/generated/module-index.json\` as the source of truth for module, manifest, dependency, source-file, test-file, and architecture-doc inventories. Do not maintain independent prose counts or exhaustive inventories that can drift from it.
205
238
  - When module structure changes, require \`.ai/tools/generate-module-index --check\` or regeneration.
206
239
  - When public APIs, routes, or externally consumed surfaces change, require \`.ai/tools/generate-public-surface --check\` or regeneration.
207
240
 
241
+ #### Active Plans Sync
242
+
243
+ - Keep \`docs/plans/**\` limited to active or planned work.
244
+ - When a plan is fully implemented or superseded, remove it from the active plans collection instead of converting it into a completion report, changelog, or historical archive; Git and PR history preserve the prior plan.
245
+ - Replace superseded requirements in an active plan and reconcile references from other durable docs. Do not append successive task decisions or completed-step narratives.
246
+ - If the same current status, ordering, dependency, or scope is stated in more than one durable document, identify the owning document and make every other reference consistent with it.
247
+
208
248
  #### Known Issues Sync
209
249
 
210
250
  - \`docs/known-issues.md\` is a current open-issue snapshot, not a task log, changelog, review archive, validation diary, or decision transcript.
@@ -219,10 +259,18 @@ Small diff, minimum change, localized fix, or preserving the current implementat
219
259
  - Before promoting, record confirmed unresolved findings from the final role handoff reports (test report, coder completion, Gate Review reports) in \`.ai/vcm/handoffs/known-issues.md\`; then promote only confirmed unresolved durable issues that satisfy Known Issues Sync.
220
260
  - During docs sync, remove or rewrite resolved/stale KI entries touched by the task so \`docs/known-issues.md\` remains an open-issue snapshot.
221
261
 
262
+ #### Cross-Document Consistency
263
+
264
+ - Compare every durable fact changed by the task across architecture docs, active plans, testing docs, known issues, code, and generated context. Resolve contradictions before reporting \`synced\`.
265
+ - Verify names, ownership, dependency direction, lifecycle, public contracts, validation commands, current gaps, and active-plan status against their owning source.
266
+ - Do not edit tester-owned \`docs/TESTING.md\` during post-validation docs sync. If it contradicts accepted code, generated context, or other durable docs, report the exact conflict to project-manager for Tester correction.
267
+ - Run \`.ai/tools/check-durable-docs\` after durable-doc changes. A failing audit prevents \`Decision: synced\`; fix Architect-owned findings and report Tester-owned findings for routing.
268
+
222
269
  #### Docs Sync Report
223
270
 
224
- - Write \`.ai/vcm/handoffs/docs-sync-report.md\` for post-validation docs sync in code-change or Debug flow. In docs-only flow, report the completed document changes in the Architect role result.
225
- - The report records decision, evidence reviewed, architecture drift check, docs updated, docs left unchanged, promoted/updated/removed/not-promoted known issues, remaining documentation risks, and handoff notes.
271
+ - Write \`.ai/vcm/handoffs/docs-sync-report.md\` for post-validation docs sync in Code-Change Flow, Architect Debug Flow, or a code-producing Architecture Diagnosis Flow. Do not write it for Docs-Only Flow or a Debug/Diagnosis Branch.
272
+ - In Docs-Only Flow, the Architect role result must record the decision, changed documents, evidence reviewed, checks performed, and commit.
273
+ - The report records decision, evidence reviewed, current-truth reconciliation, generated-context freshness, cross-document consistency, architecture docs, active plans, testing-doc consistency, known-issues disposition, durable-doc audit command and result, docs updated, docs left unchanged, remaining documentation risks, and handoff notes.
226
274
  - \`Decision\` must be \`synced\`, \`unchanged\`, or \`blocked\`.
227
275
 
228
276
  ### Background Jobs