vibe-coding-master 0.7.4 → 0.7.6

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 (57) hide show
  1. package/README.md +19 -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 +50 -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 +5 -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 +335 -31
  17. package/dist/backend/services/harness-feedback-service.js +19 -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 +128 -1
  29. package/dist/backend/templates/harness/architect-agent.js +85 -22
  30. package/dist/backend/templates/harness/claude-root.js +25 -29
  31. package/dist/backend/templates/harness/coder-agent.js +5 -7
  32. package/dist/backend/templates/harness/coder-worker-agent.js +3 -3
  33. package/dist/backend/templates/harness/gate-review.js +292 -65
  34. package/dist/backend/templates/harness/harness-engineer-agent.js +8 -8
  35. package/dist/backend/templates/harness/memory-block.js +69 -0
  36. package/dist/backend/templates/harness/project-known-issues.js +1 -0
  37. package/dist/backend/templates/harness/project-manager-agent.js +217 -75
  38. package/dist/backend/templates/harness/role-memory.js +9 -12
  39. package/dist/backend/templates/harness/tester-agent.js +8 -4
  40. package/dist/backend/templates/harness/vcm-architecture-interview-skill.js +82 -0
  41. package/dist/backend/templates/harness/vcm-final-acceptance-skill.js +4 -3
  42. package/dist/backend/templates/harness/vcm-harness-bootstrap-skill.js +14 -3
  43. package/dist/backend/templates/harness/vcm-propose-memory-skill.js +2 -2
  44. package/dist/backend/templates/harness/vcm-route-message-skill.js +5 -0
  45. package/dist/backend/templates/harness/vcm-task-state-skill.js +110 -0
  46. package/dist/backend/templates/message-envelope.js +1 -1
  47. package/dist/shared/constants.js +0 -10
  48. package/dist/shared/types/workflow.js +1 -0
  49. package/dist/shared/validation/artifact-check.js +41 -1
  50. package/dist-frontend/assets/index-BO2AuF-q.js +97 -0
  51. package/dist-frontend/assets/index-C2etsYlK.css +32 -0
  52. package/dist-frontend/index.html +2 -2
  53. package/package.json +1 -1
  54. package/scripts/harness-tools/check-durable-docs +298 -0
  55. package/scripts/verify-package.mjs +1 -0
  56. package/dist-frontend/assets/index-DCb-S6Ls.css +0 -32
  57. package/dist-frontend/assets/index-NTlycxx9.js +0 -97
@@ -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,16 +1,90 @@
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
7
35
 
8
36
  ## Current Code Reality
9
37
 
38
+ ### Planning Boundary
39
+
40
+ TBD
41
+
42
+ ### Code Reading Evidence
43
+
44
+ | File / Symbol | Called By | Calls / Consumers | State / Side Effects | Verified Behavior |
45
+ | --- | --- | --- | --- | --- |
46
+ | TBD | TBD | TBD | TBD | TBD |
47
+
48
+ ### Existing Behavior Trace
49
+
50
+ TBD
51
+
52
+ ### Code / Docs Conflicts
53
+
10
54
  TBD
11
55
 
12
56
  ## Architecture Decision
13
57
 
58
+ ### Changed Behavior Flow
59
+
60
+ TBD
61
+
62
+ ### Ownership
63
+
64
+ TBD
65
+
66
+ ### Data Flow
67
+
68
+ TBD
69
+
70
+ ### Lifecycle
71
+
72
+ TBD
73
+
74
+ ### Boundaries
75
+
76
+ TBD
77
+
78
+ ### Invariants
79
+
80
+ TBD
81
+
82
+ ### Failure Model
83
+
84
+ TBD
85
+
86
+ ### Decision Rationale
87
+
14
88
  TBD
15
89
 
16
90
  ## Module/File Plan
@@ -27,7 +101,7 @@ Task-specific context and coder guidance go here, not in source-code comments.
27
101
  Source-code comments should only describe durable behavior, contracts, invariants,
28
102
  error boundaries, or non-obvious logic that should remain useful after this task.
29
103
 
30
- | ID | File / Action | Why In Scope | Coder Work | Allowed Freedom | Expected VCM:CODE | Durable Comment Needs | Behavior / Contract Proof Points |
104
+ | ID | File / Action | Current Evidence / Why In Scope | Coder Work | Allowed Freedom | Expected VCM:CODE | Durable Comment Needs | Behavior / Contract Proof Points |
31
105
  | --- | --- | --- | --- | --- | --- | --- | --- |
32
106
  | SCF-001 | TBD | TBD | TBD | TBD | TBD | TBD | TBD |
33
107
 
@@ -73,6 +147,10 @@ TBD
73
147
 
74
148
  TBD
75
149
 
150
+ ## Coverage Mapping
151
+
152
+ TBD
153
+
76
154
  ## Commands Run Or Checked
77
155
 
78
156
  TBD
@@ -145,6 +223,55 @@ TBD
145
223
 
146
224
  ## Objective Failures
147
225
 
226
+ TBD
227
+ `;
228
+ }
229
+ export function renderArchitectDebugTemplate(taskSlug) {
230
+ return `# Architect Debug: ${taskSlug}
231
+
232
+ Status: pending|completed
233
+
234
+ ## PM-Routed Failure
235
+
236
+ TBD
237
+
238
+ ## Confirmed Root Cause
239
+
240
+ TBD
241
+
242
+ ## Implementation
243
+
244
+ TBD
245
+
246
+ ## Changed Files And Public Surface
247
+
248
+ TBD
249
+
250
+ ## Baseline Tests
251
+
252
+ TBD
253
+
254
+ ## Diagnostic And L0/L1 Validation
255
+
256
+ TBD
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
+
265
+ ## Generated Context
266
+
267
+ TBD
268
+
269
+ ## Remaining Failure Evidence
270
+
271
+ TBD
272
+
273
+ ## Final Disposition
274
+
148
275
  TBD
149
276
  `;
150
277
  }
@@ -8,45 +8,72 @@ ${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.
24
- - Before writing an architecture plan, read the affected existing source files, runtime entry points, configuration, and call sites needed to verify current code reality. Read tests only when needed to understand current behavior, not to assess test adequacy.
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.
25
33
  - Read \`.ai/generated/module-index.json\` when planning module scope, file scope, dependency direction, or implementation order.
26
34
  - Read \`.ai/generated/public-surface.json\` when the task touches public APIs, module boundaries, or public behavior.
27
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.
28
36
 
37
+ ### Planning Code Reading
38
+
39
+ - Do not plan from session memory, architecture docs, generated context, or code comments alone. Re-read current-worktree source and verify actual behavior from implementation.
40
+ - Define the planning boundary as the affected feature or module and identify every existing or intended observable entry point for the behavior being changed.
41
+ - Read the complete implementation of each relevant existing entry point.
42
+ - Follow every project-owned call path the plan will change through cross-module calls, state reads and writes, persistence, side effects, completion and failure signals, and consumers.
43
+ - For every cross-file or public callable surface the plan will add or change, read its current project-owned callers and consumers.
44
+ - When the plan changes state ownership or lifecycle behavior, read the relevant project-owned creators, readers, writers, completion handlers, failure handlers, cancellation handlers, retry handlers, and recovery handlers.
45
+ - Continue across module boundaries whenever the changed behavior path, state ownership, lifecycle, public contract, or failure path crosses them.
46
+ - Stop at standard-library, third-party, external-service, vendor, or generated-code boundaries and record the boundary contract, inputs, outputs, errors, and side effects relevant to the plan.
47
+ - For new behavior, read the existing integration points and caller or consumer paths it will join.
48
+ - Treat architecture docs, generated context, and comments as navigation evidence, not authority. Record contradictions with implementation in Current Code Reality.
49
+ - Read tests only when needed to understand current behavior, not to assess test adequacy.
50
+ - Do not write Architecture Decision or begin Code Scaffolding while a project-owned symbol remains unresolved on a behavior path the plan will change.
51
+
29
52
  ### Architecture Plan
30
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.
31
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.
32
57
  - The architecture-plan handoff is not complete until required code scaffolding, callable surfaces, contract comments, and \`VCM:CODE\` placeholders have been written.
33
58
 
34
59
  #### Plan Document
35
60
 
36
- - \`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.
37
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.
38
- - \`Accepted Scope\`: state the PM-routed task scope, required user-visible outcome, and any explicit non-scope that prevents accidental expansion.
39
- - \`Current Code Reality\`: state the existing files, runtime entry points, callers, observed behavior evidence, docs, and constraints verified from the current codebase.
40
- - \`Architecture Decision\`: state the selected design, ownership, data flow, lifecycle, boundaries, and why it fits the current architecture.
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.
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.
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.
41
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.
42
68
  - \`Public Surface Impact\`: state changed APIs, routes, commands, events, exports, storage formats, configuration, UI behavior, visibility changes, side effects, error boundaries, expected callers, or explicitly state none.
43
- - \`Scaffold Manifest\`: provide one stable row per implementation unit or file context that coder must complete: row ID, file action, why the file is in scope, coder work, allowed implementation freedom, expected \`VCM:CODE\` placeholders, durable code comment needs, and behavior/contract proof points.
69
+ - \`Scaffold Manifest\`: provide one stable row per implementation unit or file context that coder must complete: row ID, file action, current code or integration-point evidence and why the file is in scope, coder work, allowed implementation freedom, expected \`VCM:CODE\` placeholders, durable code comment needs, and behavior/contract proof points.
44
70
  - Give each Scaffold Manifest row a stable ID such as \`SCF-001\`; use that ID in any related \`VCM:CODE\` marker so coder can report completion by ID.
45
71
  - \`Tester Coverage Hints\`: list behavior scenarios, edge conditions, public-contract risks, or runtime paths tester should consider. Do not design test cases, validation levels, commands, coverage matrices, or final validation strategy.
46
72
  - \`Docs Impact\`: list every touched module and state whether its \`<module>/ARCHITECTURE.md\` is expected to change, stay unchanged, or require code-diff review before deciding; also state whether changes belong in \`docs/ARCHITECTURE.md\`, \`.ai/generated/public-surface.json\`, or no durable architecture doc.
47
73
  - \`Known Risks\`: state concrete remaining technical risks, uncertainty, or validation risks that coder or tester must pay attention to.
48
74
  - \`Coder Handoff Notes\`: state implementation order and constraints that help coder complete the current plan without putting task context into source comments.
49
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.
50
77
 
51
78
  #### Code Scaffolding
52
79
 
@@ -78,13 +105,17 @@ ${renderRoleMemoryRules("architect")}
78
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.
79
106
  - Remove all temporary diagnostics before completion.
80
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.
81
- - Architect-run validation in Debug Mode is diagnostic evidence, not final acceptance.
82
- - 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\`.
83
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.
84
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.
85
- - 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.
86
- - Final disposition must be one of: local fix completed, normal architecture plan required, Architecture Diagnosis recommended, or user clarification required.
87
- - 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, and final disposition.
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.
88
119
 
89
120
  ### Architecture Diagnosis Mode
90
121
 
@@ -150,35 +181,51 @@ Small diff, minimum change, localized fix, or preserving the current implementat
150
181
  7. \`Architecture Assessment\`
151
182
  8. \`Required Architecture Direction\`
152
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
+ |---|---|---|---|---|---|
153
192
 
154
193
  - If PM explicitly routes an analysis-only Diagnosis task, stop after completing the diagnosis artifact and report the result.
155
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.
156
- - 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.
157
201
  - Final disposition must be one of: \`analysis completed\`, \`diagnosis implementation completed\`, or \`user clarification required\`.
158
202
 
159
203
  ### Replan And Drift
160
204
 
161
- - 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.
162
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.
163
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\`.
164
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.
165
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.
166
211
  - Treat any new or changed cross-file callable surface not defined in the architecture plan as architecture drift.
167
212
  - Do not change the plan for workload, session length, context size, or predicted failure without implementation/validation evidence.
168
213
 
169
214
  ### Docs Sync
170
215
 
171
- - In docs-only flow, update the PM-assigned durable docs directly; tester completion is not required.
172
- - In code-change flow, perform post-validation docs sync only when project-manager requests it after tester completes.
173
- - 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.
174
219
 
175
220
  #### Architecture Docs Sync
176
221
 
177
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.
178
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.
179
225
  - Keep only durable product, protocol, spec, or domain identifiers that future maintainers must understand.
180
226
  - Keep project-level docs focused on module map, dependency direction, cross-module relationships, major runtime flows, and project-wide constraints.
181
- - 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.
182
229
  - Do not duplicate the generated public API index; explain design intent and contract meaning instead.
183
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.
184
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.
@@ -187,9 +234,17 @@ Small diff, minimum change, localized fix, or preserving the current implementat
187
234
  - If a touched module's architecture doc does not need changes, record why in \`.ai/vcm/handoffs/docs-sync-report.md\`.
188
235
  - Do not move task logs, temporary rationale, or per-task validation history into durable architecture docs.
189
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.
190
238
  - When module structure changes, require \`.ai/tools/generate-module-index --check\` or regeneration.
191
239
  - When public APIs, routes, or externally consumed surfaces change, require \`.ai/tools/generate-public-surface --check\` or regeneration.
192
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
+
193
248
  #### Known Issues Sync
194
249
 
195
250
  - \`docs/known-issues.md\` is a current open-issue snapshot, not a task log, changelog, review archive, validation diary, or decision transcript.
@@ -204,10 +259,18 @@ Small diff, minimum change, localized fix, or preserving the current implementat
204
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.
205
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.
206
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
+
207
269
  #### Docs Sync Report
208
270
 
209
- - 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.
210
- - 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.
211
274
  - \`Decision\` must be \`synced\`, \`unchanged\`, or \`blocked\`.
212
275
 
213
276
  ### Background Jobs