@exaudeus/workrail 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/services/compiler/template-registry.d.ts +4 -2
- package/dist/application/services/compiler/template-registry.js +97 -5
- package/dist/application/services/workflow-compiler.d.ts +5 -1
- package/dist/application/services/workflow-compiler.js +20 -7
- package/dist/application/use-cases/raw-workflow-file-scanner.d.ts +1 -1
- package/dist/application/use-cases/raw-workflow-file-scanner.js +2 -0
- package/dist/application/use-cases/validate-workflow-registry.js +2 -1
- package/dist/config/feature-flags.js +8 -0
- package/dist/di/container.js +10 -1
- package/dist/di/tokens.d.ts +1 -0
- package/dist/di/tokens.js +1 -0
- package/dist/engine/engine-factory.d.ts +3 -0
- package/dist/engine/engine-factory.js +295 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +12 -0
- package/dist/engine/types.d.ts +130 -0
- package/dist/engine/types.js +18 -0
- package/dist/infrastructure/storage/file-workflow-storage.d.ts +1 -0
- package/dist/infrastructure/storage/file-workflow-storage.js +18 -3
- package/dist/infrastructure/storage/workflow-resolution.d.ts +9 -6
- package/dist/infrastructure/storage/workflow-resolution.js +14 -1
- package/dist/manifest.json +166 -94
- package/dist/mcp/handlers/shared/request-workflow-reader.d.ts +19 -0
- package/dist/mcp/handlers/shared/request-workflow-reader.js +50 -0
- package/dist/mcp/handlers/v2-checkpoint.d.ts +31 -1
- package/dist/mcp/handlers/v2-checkpoint.js +76 -64
- package/dist/mcp/handlers/v2-execution/continue-advance.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-advance.js +5 -5
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +17 -22
- package/dist/mcp/handlers/v2-execution/index.d.ts +10 -17
- package/dist/mcp/handlers/v2-execution/index.js +44 -54
- package/dist/mcp/handlers/v2-execution/replay.d.ts +4 -15
- package/dist/mcp/handlers/v2-execution/replay.js +52 -128
- package/dist/mcp/handlers/v2-execution/start.d.ts +4 -3
- package/dist/mcp/handlers/v2-execution/start.js +32 -49
- package/dist/mcp/handlers/v2-token-ops.d.ts +45 -24
- package/dist/mcp/handlers/v2-token-ops.js +372 -32
- package/dist/mcp/handlers/v2-workflow.d.ts +1 -1
- package/dist/mcp/handlers/v2-workflow.js +25 -4
- package/dist/mcp/output-schemas.d.ts +104 -283
- package/dist/mcp/output-schemas.js +24 -22
- package/dist/mcp/server.js +8 -0
- package/dist/mcp/tool-descriptions.js +9 -2
- package/dist/mcp/types.d.ts +4 -0
- package/dist/mcp/v2/tools.d.ts +32 -53
- package/dist/mcp/v2/tools.js +27 -37
- package/dist/mcp/v2-response-formatter.js +12 -16
- package/dist/runtime/runtime-mode.d.ts +2 -0
- package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
- package/dist/v2/durable-core/domain/prompt-renderer.js +5 -3
- package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +14 -14
- package/dist/v2/durable-core/schemas/session/events.d.ts +4 -4
- package/dist/v2/durable-core/schemas/session/validation-event.d.ts +2 -2
- package/dist/v2/durable-core/tokens/payloads.d.ts +32 -32
- package/dist/v2/durable-core/tokens/short-token.d.ts +38 -0
- package/dist/v2/durable-core/tokens/short-token.js +126 -0
- package/dist/v2/durable-core/tokens/token-patterns.d.ts +4 -0
- package/dist/v2/durable-core/tokens/token-patterns.js +9 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.d.ts +11 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.js +38 -0
- package/dist/v2/infra/local/data-dir/index.d.ts +1 -0
- package/dist/v2/infra/local/data-dir/index.js +3 -0
- package/dist/v2/infra/local/token-alias-store/index.d.ts +16 -0
- package/dist/v2/infra/local/token-alias-store/index.js +117 -0
- package/dist/v2/ports/data-dir.port.d.ts +1 -0
- package/dist/v2/ports/token-alias-store.port.d.ts +33 -0
- package/dist/v2/ports/token-alias-store.port.js +2 -0
- package/package.json +8 -1
- package/workflows/coding-task-workflow-agentic.lean.v2.json +224 -0
- package/workflows/routines/philosophy-alignment.json +12 -12
- package/workflows/routines/tension-driven-design.json +63 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalTokenAliasStoreV2 = void 0;
|
|
4
|
+
const neverthrow_1 = require("neverthrow");
|
|
5
|
+
const ALIAS_FILE_VERSION = 1;
|
|
6
|
+
function positionKey(tokenKind, sessionId, nodeId, attemptId, aliasSlot) {
|
|
7
|
+
return `${tokenKind}:${aliasSlot ?? ''}:${sessionId}:${nodeId}:${attemptId ?? ''}`;
|
|
8
|
+
}
|
|
9
|
+
class LocalTokenAliasStoreV2 {
|
|
10
|
+
constructor(dataDir, fs) {
|
|
11
|
+
this.dataDir = dataDir;
|
|
12
|
+
this.fs = fs;
|
|
13
|
+
this.index = new Map();
|
|
14
|
+
this.positionIndex = new Map();
|
|
15
|
+
}
|
|
16
|
+
register(entry) {
|
|
17
|
+
if (this.index.has(entry.nonceHex)) {
|
|
18
|
+
return (0, neverthrow_1.errAsync)({
|
|
19
|
+
code: 'ALIAS_DUPLICATE_NONCE',
|
|
20
|
+
nonceHex: entry.nonceHex,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const line = { v: ALIAS_FILE_VERSION, ...entry };
|
|
24
|
+
const lineBytes = encodeJsonlLine(line);
|
|
25
|
+
const filePath = this.dataDir.tokenIndexPath();
|
|
26
|
+
const dir = this.dataDir.keysDir();
|
|
27
|
+
return this.fs.mkdirp(dir)
|
|
28
|
+
.andThen(() => this.fs.openAppend(filePath))
|
|
29
|
+
.andThen((handle) => this.fs.writeAll(handle.fd, lineBytes)
|
|
30
|
+
.andThen(() => this.fs.fsyncFile(handle.fd))
|
|
31
|
+
.andThen(() => this.fs.closeFile(handle.fd))
|
|
32
|
+
.orElse((e) => this.fs.closeFile(handle.fd)
|
|
33
|
+
.mapErr(() => e)
|
|
34
|
+
.andThen(() => (0, neverthrow_1.errAsync)(e))))
|
|
35
|
+
.map(() => {
|
|
36
|
+
this.index.set(entry.nonceHex, entry);
|
|
37
|
+
this.positionIndex.set(positionKey(entry.tokenKind, entry.sessionId, entry.nodeId, entry.attemptId, entry.aliasSlot), entry.nonceHex);
|
|
38
|
+
})
|
|
39
|
+
.mapErr((e) => ({
|
|
40
|
+
code: 'ALIAS_IO_ERROR',
|
|
41
|
+
message: e.message ?? String(e),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
lookup(nonceHex) {
|
|
45
|
+
return this.index.get(nonceHex) ?? null;
|
|
46
|
+
}
|
|
47
|
+
lookupByPosition(tokenKind, sessionId, nodeId, attemptId, aliasSlot) {
|
|
48
|
+
const key = positionKey(tokenKind, sessionId, nodeId, attemptId, aliasSlot);
|
|
49
|
+
const nonceHex = this.positionIndex.get(key);
|
|
50
|
+
if (!nonceHex)
|
|
51
|
+
return null;
|
|
52
|
+
return this.index.get(nonceHex) ?? null;
|
|
53
|
+
}
|
|
54
|
+
loadIndex() {
|
|
55
|
+
const filePath = this.dataDir.tokenIndexPath();
|
|
56
|
+
return this.fs.readFileUtf8(filePath)
|
|
57
|
+
.map((content) => {
|
|
58
|
+
let loaded = 0;
|
|
59
|
+
let skipped = 0;
|
|
60
|
+
for (const line of content.split('\n')) {
|
|
61
|
+
const trimmed = line.trim();
|
|
62
|
+
if (!trimmed)
|
|
63
|
+
continue;
|
|
64
|
+
try {
|
|
65
|
+
const parsed = JSON.parse(trimmed);
|
|
66
|
+
const entry = parseAliasLine(parsed);
|
|
67
|
+
if (entry) {
|
|
68
|
+
this.index.set(entry.nonceHex, entry);
|
|
69
|
+
this.positionIndex.set(positionKey(entry.tokenKind, entry.sessionId, entry.nodeId, entry.attemptId, entry.aliasSlot), entry.nonceHex);
|
|
70
|
+
loaded++;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
skipped++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
skipped++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (skipped > 0) {
|
|
81
|
+
process.stderr.write(`[TokenAliasStore] loadIndex: loaded=${loaded} skipped=${skipped} (malformed lines)\n`);
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.orElse((e) => {
|
|
85
|
+
if (e.code === 'FS_NOT_FOUND')
|
|
86
|
+
return (0, neverthrow_1.okAsync)(undefined);
|
|
87
|
+
return (0, neverthrow_1.errAsync)({ code: 'ALIAS_IO_ERROR', message: e.message });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.LocalTokenAliasStoreV2 = LocalTokenAliasStoreV2;
|
|
92
|
+
function encodeJsonlLine(line) {
|
|
93
|
+
return new TextEncoder().encode(JSON.stringify(line) + '\n');
|
|
94
|
+
}
|
|
95
|
+
function parseAliasLine(parsed) {
|
|
96
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
97
|
+
return null;
|
|
98
|
+
const r = parsed;
|
|
99
|
+
if (r['v'] !== ALIAS_FILE_VERSION ||
|
|
100
|
+
typeof r['nonceHex'] !== 'string' ||
|
|
101
|
+
(r['tokenKind'] !== 'state' && r['tokenKind'] !== 'ack' && r['tokenKind'] !== 'checkpoint' && r['tokenKind'] !== 'continue') ||
|
|
102
|
+
typeof r['sessionId'] !== 'string' ||
|
|
103
|
+
typeof r['runId'] !== 'string' ||
|
|
104
|
+
typeof r['nodeId'] !== 'string') {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
nonceHex: r['nonceHex'],
|
|
109
|
+
tokenKind: r['tokenKind'],
|
|
110
|
+
sessionId: r['sessionId'],
|
|
111
|
+
runId: r['runId'],
|
|
112
|
+
nodeId: r['nodeId'],
|
|
113
|
+
...(typeof r['attemptId'] === 'string' ? { attemptId: r['attemptId'] } : {}),
|
|
114
|
+
...(r['aliasSlot'] === 'retry' ? { aliasSlot: 'retry' } : {}),
|
|
115
|
+
...(typeof r['workflowHashRef'] === 'string' ? { workflowHashRef: r['workflowHashRef'] } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ResultAsync } from 'neverthrow';
|
|
2
|
+
import type { ShortTokenKind } from '../durable-core/tokens/short-token.js';
|
|
3
|
+
export interface TokenAliasEntryV2 {
|
|
4
|
+
readonly nonceHex: string;
|
|
5
|
+
readonly tokenKind: ShortTokenKind;
|
|
6
|
+
readonly aliasSlot?: 'retry';
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
readonly runId: string;
|
|
9
|
+
readonly nodeId: string;
|
|
10
|
+
readonly attemptId?: string;
|
|
11
|
+
readonly workflowHashRef?: string;
|
|
12
|
+
}
|
|
13
|
+
export type TokenAliasRegistrationError = {
|
|
14
|
+
readonly code: 'ALIAS_IO_ERROR';
|
|
15
|
+
readonly message: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly code: 'ALIAS_DUPLICATE_NONCE';
|
|
18
|
+
readonly nonceHex: string;
|
|
19
|
+
};
|
|
20
|
+
export type TokenAliasLookupError = {
|
|
21
|
+
readonly code: 'ALIAS_IO_ERROR';
|
|
22
|
+
readonly message: string;
|
|
23
|
+
};
|
|
24
|
+
export type TokenAliasLoadError = {
|
|
25
|
+
readonly code: 'ALIAS_IO_ERROR';
|
|
26
|
+
readonly message: string;
|
|
27
|
+
};
|
|
28
|
+
export interface TokenAliasStorePortV2 {
|
|
29
|
+
register(entry: TokenAliasEntryV2): ResultAsync<void, TokenAliasRegistrationError>;
|
|
30
|
+
lookup(nonceHex: string): TokenAliasEntryV2 | null;
|
|
31
|
+
lookupByPosition(tokenKind: ShortTokenKind, sessionId: string, nodeId: string, attemptId?: string, aliasSlot?: 'retry'): TokenAliasEntryV2 | null;
|
|
32
|
+
loadIndex(): ResultAsync<void, TokenAliasLoadError>;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exaudeus/workrail",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Step-by-step workflow enforcement for AI agents via MCP",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
"bin": {
|
|
15
15
|
"workrail": "dist/mcp-server.js"
|
|
16
16
|
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/mcp-server.js",
|
|
19
|
+
"./engine": {
|
|
20
|
+
"import": "./dist/engine/index.js",
|
|
21
|
+
"types": "./dist/engine/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
17
24
|
"files": [
|
|
18
25
|
"dist",
|
|
19
26
|
"spec",
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "coding-task-workflow-agentic",
|
|
3
|
+
"name": "Agentic Task Dev Workflow (Lean • Notes-First • WorkRail Executor)",
|
|
4
|
+
"version": "2.1.0",
|
|
5
|
+
"description": "Lean variant of the agentic coding workflow. Merges triage, inputs gate, context gathering, and re-triage into a single Understand & Classify phase. Reduces context variable count and removes top-level clarificationPrompts. Same quality guarantees with fewer tokens.",
|
|
6
|
+
"recommendedPreferences": {
|
|
7
|
+
"recommendedAutonomy": "guided",
|
|
8
|
+
"recommendedRiskPolicy": "conservative"
|
|
9
|
+
},
|
|
10
|
+
"preconditions": [
|
|
11
|
+
"User provides a task description or equivalent objective.",
|
|
12
|
+
"Agent has codebase read access and can run the tools needed for analysis and validation.",
|
|
13
|
+
"A deterministic validation path exists (tests, build, or an explicit verification strategy).",
|
|
14
|
+
"If the task touches critical paths, rollback or containment strategy can be defined."
|
|
15
|
+
],
|
|
16
|
+
"metaGuidance": [
|
|
17
|
+
"DEFAULT BEHAVIOR: self-execute with tools. Only ask the user for business decisions, missing external artifacts, or permissions you cannot resolve.",
|
|
18
|
+
"V2 DURABILITY: use output.notesMarkdown as the primary durable record. Do NOT mirror execution state into CONTEXT.md or any markdown checkpoint file.",
|
|
19
|
+
"ARTIFACT STRATEGY: `implementation_plan.md` is the only default human-facing artifact for non-small tasks. `spec.md` or `design.md` are optional and should be created only when they materially improve handoff or reviewability.",
|
|
20
|
+
"OWNERSHIP & DELEGATION: the main agent owns strategy, decisions, synthesis, and implementation. Delegate only bounded cognitive routines via WorkRail Executor. Never hand off full task ownership or rely on named Builder/Researcher identities.",
|
|
21
|
+
"SUBAGENT SYNTHESIS: treat subagent output as evidence, not conclusions. State your hypothesis before delegating, then interrogate what came back: what was missed, wrong, or new? Say what changed your mind or what you still reject, and why.",
|
|
22
|
+
"PARALLELISM: when reads, audits, or delegations are independent, run them in parallel inside the phase. Parallelize cognition; serialize synthesis and canonical writes.",
|
|
23
|
+
"PHILOSOPHY LENS: apply the user's coding philosophy (from active session rules) as the evaluation lens. Flag violations by principle name, not as generic feedback. If principles conflict, surface the tension explicitly instead of silently choosing.",
|
|
24
|
+
"PHILOSOPHY CHECKS: watch for immutability, architectural fixes over patches, illegal states unrepresentable, explicit domain types, reduced path explosion, type safety, exhaustiveness, and errors as data.",
|
|
25
|
+
"PHILOSOPHY CHECKS (cont): validate at boundaries, fail fast on invariant violations, prefer determinism and small pure functions, use data-driven control flow, DI at boundaries, YAGNI with discipline, and atomicity.",
|
|
26
|
+
"PHILOSOPHY CHECKS (cont): treat graceful degradation, observability, fakes over mocks, and focused interfaces as first-class review concerns.",
|
|
27
|
+
"DRIFT HANDLING: when reality diverges from the plan, update the plan artifact and re-audit deliberately rather than accumulating undocumented drift.",
|
|
28
|
+
"NEVER COMMIT MARKDOWN FILES UNLESS USER EXPLICITLY ASKS."
|
|
29
|
+
],
|
|
30
|
+
"steps": [
|
|
31
|
+
{
|
|
32
|
+
"id": "phase-0-understand-and-classify",
|
|
33
|
+
"title": "Phase 0: Understand & Classify",
|
|
34
|
+
"prompt": "Build understanding and classify the task in one pass.\n\nStep 1 — Early exit check:\nBefore any exploration, verify that acceptance criteria or expected behavior exist. If they are completely absent and cannot be inferred, ask the user and stop. Do NOT ask questions you can resolve with tools.\n\nStep 2 — Explore:\nUse tools to build the minimum complete understanding needed to design correctly. Read independent files in parallel when possible.\n\nGather:\n- key entry points and call chain sketch\n- relevant files, modules, and functions\n- existing repo patterns with concrete file references\n- testing strategy already present in the repo\n- risks and unknowns\n- explicit invariants and non-goals\n\nStep 3 — Discover the dev's philosophy and preferences:\nDiscover what the dev cares about using this fallback chain (try each, use all that are available):\n1. Memory MCP (if available): call `mcp_memory_conventions`, `mcp_memory_prefer`, `mcp_memory_recall` to retrieve learned preferences and coding philosophy\n2. Active session rules / Firebender rules: read any rules, commands, or philosophy documents already in context\n3. Repo patterns: infer preferences from how the codebase already works — error handling style, mutability patterns, test approach, naming conventions, architecture patterns\n4. Ask the dev: only if the above sources are contradictory or clearly insufficient for this task\n\nDo NOT distill into a summary — record WHERE the philosophy lives (which rules, which Memory entries, which repo files exemplify it) so later phases can reference the source directly.\n\nIf stated rules conflict with actual repo patterns (e.g., rules say 'prefer immutability' but the module uses MutableStateFlow), note the conflict in `philosophyConflicts` — this is valuable signal for design decisions.\n\nStep 4 — Classify (informed by exploration):\nNow that you have real context, classify:\n- `taskComplexity`: Small / Medium / Large\n- `riskLevel`: Low / Medium / High\n- `rigorMode`: QUICK / STANDARD / THOROUGH\n- `automationLevel`: High / Medium / Low\n- `prStrategy`: SinglePR / MultiPR\n\nDecision guidance:\n- QUICK: small, low-risk, clear path, little ambiguity\n- STANDARD: medium scope or moderate risk\n- THOROUGH: large scope, architectural uncertainty, or high-risk change\n\nStep 5 — Optional deeper context (post-classification):\nIf `rigorMode` is STANDARD or THOROUGH and understanding still feels incomplete or the call chain is too fuzzy, and delegation is available, spawn TWO WorkRail Executors SIMULTANEOUSLY running `routine-context-gathering` with focus=COMPLETENESS and focus=DEPTH. Synthesize both outputs before finishing this step.\n\nSet context variables:\n- `taskComplexity`\n- `riskLevel`\n- `rigorMode`\n- `automationLevel`\n- `prStrategy`\n- `contextSummary`\n- `candidateFiles`\n- `invariants`\n- `nonGoals`\n- `openQuestions`\n- `philosophySources` — pointers to where the dev's philosophy lives (rules, Memory entries, repo files), not a summary\n- `philosophyConflicts` — conflicts between stated rules and actual repo patterns (if any)\n\nRules:\n- answer your own questions with tools whenever possible\n- only keep true human-decision questions in `openQuestions`\n- keep `openQuestions` bounded to the minimum necessary\n- classify AFTER exploring, not before",
|
|
35
|
+
"requireConfirmation": {
|
|
36
|
+
"or": [
|
|
37
|
+
{ "var": "taskComplexity", "equals": "Large" },
|
|
38
|
+
{ "var": "riskLevel", "equals": "High" }
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "phase-1-architecture-decision",
|
|
44
|
+
"title": "Phase 1: Architecture Decision (Generate, Compare, Challenge, Select)",
|
|
45
|
+
"runCondition": {
|
|
46
|
+
"var": "taskComplexity",
|
|
47
|
+
"not_equals": "Small"
|
|
48
|
+
},
|
|
49
|
+
"prompt": "Design the architecture through deep understanding, not surface-level generation.\n\nPart A — Understand the problem deeply:\n- What are the core tensions in this problem? (e.g., performance vs simplicity, flexibility vs type safety, backward compatibility vs clean design)\n- How does the codebase already solve similar problems? Study the most relevant existing patterns — don't just list files, analyze the architectural decisions and constraints they protect.\n- What's the simplest naive solution? Why is it insufficient? (If it IS sufficient, that's your leading candidate — the burden of proof is on complexity.)\n- What makes this problem hard? What would a junior developer miss?\n\nPart B — Identify tensions and constraints (including philosophy):\n- Extract 2-4 real tradeoffs from your understanding (not generic labels like 'simplicity' or 'maintainability')\n- These tensions drive candidate generation — each candidate resolves them differently\n- Filter `philosophySources` to the principles actually under pressure for THIS problem. Which of the dev's philosophy principles constrain the solution space? For example: does the simplest solution require mutable state when the dev prefers immutability? Does the existing pattern use exceptions when the dev prefers Result types? Would the cleanest approach violate their preference for small interfaces?\n- If `philosophyConflicts` exist for this area of the codebase, surface them as explicit tensions the design must resolve: follow the stated rule, follow the existing pattern, or reconcile them\n\nPart C — State your hypothesis before delegating:\nBefore spawning any subagents, write 2-3 sentences: what do you currently believe the best approach is, and what concerns you most about it? This is your reference point for interrogating subagent output later.\n\nPart D — Generate candidates from tensions:\n- QUICK: self-generate candidates from your tensions. Include mandatory candidates: (1) simplest possible change that satisfies acceptance criteria, (2) follow existing repo pattern.\n- STANDARD: spawn ONE WorkRail Executor running `routine-tension-driven-design` with your tensions, philosophy sources, and problem understanding as input. Simultaneously, spawn ONE WorkRail Executor running `routine-hypothesis-challenge`: 'What constraints or failure modes would make you choose a fundamentally different approach? Propose one, grounded in real reasons.'\n- THOROUGH: spawn ONE WorkRail Executor running `routine-tension-driven-design`, ONE running `routine-hypothesis-challenge` (adversarial divergence), and ONE running `routine-execution-simulation`: 'Trace through the leading approach's 3 most likely failure scenarios step by step.'\n- For STANDARD with riskLevel=High: also spawn the execution simulation subagent.\n\nThe main agent ALWAYS self-generates its own candidates too (at minimum the two mandatory ones: simplest change + existing pattern). Subagent candidates supplement, not replace, your own thinking.\n\nPart E — Interrogate subagent output (if subagents were used):\nDo NOT summarize subagent findings as your own. Instead, interrogate against your hypothesis:\n- Where do subagent findings challenge your hypothesis? Are they right or did they miss context?\n- What did they surface that you genuinely hadn't considered?\n- Where are they just restating the obvious or echoing each other?\n- What did they get wrong or overweight?\nState explicitly: what you changed your mind about and why, or what you held firm on despite their input and why.\n\nPart F — Compare via tradeoffs (not checklists):\nFor each surviving candidate, produce:\n- One-sentence summary of the approach\n- Which tensions it resolves and which it accepts\n- The specific failure mode you'd watch for\n- How it relates to existing repo patterns (follows / adapts / departs)\n- What you gain and what you give up\n- Which of the dev's philosophy principles it honors and which it conflicts with — be specific (principle name + how)\n\nPart G — Challenge the leading option:\n- STANDARD: optionally challenge with ONE WorkRail Executor running `routine-hypothesis-challenge`\n- THOROUGH: challenge top 1-2 candidates using ONE or TWO WorkRail Executors running `routine-hypothesis-challenge`\n\nPart H — Select:\nSet context variables:\n- `selectedApproach` — the chosen design with rationale tied back to tensions\n- `runnerUpApproach` — the next-best option and why it lost\n- `architectureRationale` — which tensions were resolved and which were accepted\n- `pivotTriggers` — specific conditions under which you'd switch to the runner-up\n- `keyRiskToMonitor` — the failure mode of the selected approach\n- `acceptedTradeoffs` — what the selected approach gives up (feeds directly into design review)\n- `identifiedFailureModes` — per-candidate failure modes (feeds directly into design review)\n\nRules:\n- the main agent owns the final decision; subagents contribute depth, not decisions\n- if the simplest solution satisfies acceptance criteria, prefer it — complexity must justify itself\n- if the challenged leading candidate no longer looks best, switch deliberately rather than defending sunk cost\n- subagents go deep on specific questions, not wide on generic plans",
|
|
50
|
+
"requireConfirmation": {
|
|
51
|
+
"or": [
|
|
52
|
+
{ "var": "automationLevel", "equals": "Low" },
|
|
53
|
+
{ "var": "taskComplexity", "equals": "Large" },
|
|
54
|
+
{ "var": "riskLevel", "equals": "High" }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "phase-2-design-review",
|
|
60
|
+
"type": "loop",
|
|
61
|
+
"title": "Phase 2: Design Review",
|
|
62
|
+
"runCondition": {
|
|
63
|
+
"var": "taskComplexity",
|
|
64
|
+
"not_equals": "Small"
|
|
65
|
+
},
|
|
66
|
+
"loop": {
|
|
67
|
+
"type": "while",
|
|
68
|
+
"conditionSource": {
|
|
69
|
+
"kind": "artifact_contract",
|
|
70
|
+
"contractRef": "wr.contracts.loop_control",
|
|
71
|
+
"loopId": "design_review_loop"
|
|
72
|
+
},
|
|
73
|
+
"maxIterations": 2
|
|
74
|
+
},
|
|
75
|
+
"body": [
|
|
76
|
+
{
|
|
77
|
+
"id": "phase-2a-review-design",
|
|
78
|
+
"title": "Review Design for Gaps, Issues, and Improvements",
|
|
79
|
+
"prompt": "Review the selected architecture using the explicit tradeoffs and failure modes from Phase 1 as your review criteria — not a generic gaps checklist.\n\nTargeted review (derived from Phase 1 outputs):\n1. Are the `acceptedTradeoffs` actually acceptable? For each accepted tradeoff, verify it won't violate acceptance criteria or invariants under realistic conditions.\n2. Are the `identifiedFailureModes` actually handled? For each failure mode, trace through the design and confirm there's a mitigation path. If not, flag it.\n3. Does the selected approach's relationship to existing repo patterns hold up? If it 'adapts' an existing pattern, verify the adaptation doesn't break the invariants the original pattern protects.\n4. Is there a simpler version of the selected approach that still satisfies acceptance criteria? (Complexity must continue to justify itself.)\n\nCompare against the runner-up:\n- Are there elements from the runner-up that would strengthen the selected approach without adding complexity?\n- Would a hybrid resolve an accepted tradeoff that's bothering you?\n\nPhilosophy alignment: does the architecture respect the user's active coding rules?\n\nBefore delegating, state your current assessment: what do you think the strongest and weakest parts of the design are right now?\n\nMode-adaptive delegation:\n- QUICK: self-review only\n- STANDARD: optionally spawn ONE WorkRail Executor running `routine-hypothesis-challenge` focused specifically on the accepted tradeoffs and failure modes\n- THOROUGH: spawn TWO WorkRail Executors — `routine-hypothesis-challenge` on tradeoffs + `routine-execution-simulation` on failure modes\n\nAfter receiving subagent output (if used), interrogate it against your pre-assessment. Do not adopt their framing wholesale. State what changed your thinking and what didn't.\n\nIf issues are found, fix the design (update `selectedApproach`, `architectureRationale`, `pivotTriggers`, `acceptedTradeoffs`, `identifiedFailureModes`) before continuing.\n\nSet context variables:\n- `designFindings`\n- `designRevised`",
|
|
80
|
+
"requireConfirmation": false
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "phase-2b-loop-decision",
|
|
84
|
+
"title": "Design Review Loop Decision",
|
|
85
|
+
"prompt": "Provide a loop control artifact.\n\nDecision rules:\n- if `designFindings` is non-empty and design was revised -> continue (verify the revision)\n- if `designFindings` is empty -> stop\n- if max iterations reached -> stop and document remaining concerns\n\nOutput exactly:\n```json\n{\n \"artifacts\": [{\n \"kind\": \"wr.loop_control\",\n \"decision\": \"continue\"\n }]\n}\n```",
|
|
86
|
+
"requireConfirmation": false,
|
|
87
|
+
"outputContract": {
|
|
88
|
+
"contractRef": "wr.contracts.loop_control"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "phase-3-plan-and-test-design",
|
|
95
|
+
"title": "Phase 3: Slice, Plan, and Test Design",
|
|
96
|
+
"runCondition": {
|
|
97
|
+
"var": "taskComplexity",
|
|
98
|
+
"not_equals": "Small"
|
|
99
|
+
},
|
|
100
|
+
"prompt": "Create or update the human-facing implementation artifact: `implementation_plan.md`.\n\nThis phase combines slicing, plan drafting, philosophy alignment, and test design.\n\nThe plan must include:\n1. Problem statement\n2. Acceptance criteria\n3. Non-goals\n4. Philosophy-driven constraints (from the user's active rules)\n5. Invariants\n6. Selected approach + rationale + runner-up\n7. Vertical slices\n8. Work packages only when they improve execution or enable safe parallelism\n9. Test design\n10. Risk register\n11. PR packaging strategy\n12. Philosophy alignment per slice:\n - [principle] -> [satisfied / tension / violated + 1-line why]\n\nSet context variables:\n- `implementationPlan`\n- `slices`\n- `testDesign`\n- `estimatedPRCount`\n- `followUpTickets` (initialize if needed)\n- `unresolvedUnknownCount`\n- `planConfidenceBand`\n\nRules:\n- keep `implementation_plan.md` concrete enough for another engineer to implement without guessing\n- use work packages only when they create real clarity; do not over-fragment work\n- use the user's coding philosophy as the primary planning lens, and name tensions explicitly\n- set `unresolvedUnknownCount` to the number of still-open issues that would materially affect implementation quality\n- set `planConfidenceBand` to Low / Medium / High based on how ready the plan actually is",
|
|
101
|
+
"requireConfirmation": false
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "phase-4-plan-audit",
|
|
105
|
+
"type": "loop",
|
|
106
|
+
"title": "Phase 4: Plan Audit (Review, Fix, Decide)",
|
|
107
|
+
"runCondition": {
|
|
108
|
+
"var": "taskComplexity",
|
|
109
|
+
"not_equals": "Small"
|
|
110
|
+
},
|
|
111
|
+
"loop": {
|
|
112
|
+
"type": "while",
|
|
113
|
+
"conditionSource": {
|
|
114
|
+
"kind": "artifact_contract",
|
|
115
|
+
"contractRef": "wr.contracts.loop_control",
|
|
116
|
+
"loopId": "plan_audit_loop"
|
|
117
|
+
},
|
|
118
|
+
"maxIterations": 2
|
|
119
|
+
},
|
|
120
|
+
"body": [
|
|
121
|
+
{
|
|
122
|
+
"id": "phase-4a-audit-and-refocus",
|
|
123
|
+
"title": "Audit Plan and Apply Fixes",
|
|
124
|
+
"prompt": "Audit the plan and fix what you find in one pass.\n\nPart A -- Audit:\n- completeness / missing work\n- weak assumptions and risks\n- invariant coverage\n- slice boundary quality\n- philosophy alignment against the user's active rules\n- regression check against `resolvedFindings` (if present): if a previously resolved issue reappeared, treat it as Critical\n\nPhilosophy rules:\n- flag findings by principle name\n- Red / Orange findings go into `planFindings`\n- Yellow tensions are informational only and do NOT block loop exit\n\nBefore delegating, state your hypothesis: what do you think the plan's biggest weakness is right now? What are you most and least confident about?\n\nMode-adaptive delegation:\n- QUICK: self-audit only\n- STANDARD: if delegation is available, spawn THREE WorkRail Executors SIMULTANEOUSLY running `routine-plan-analysis`, `routine-hypothesis-challenge`, and `routine-philosophy-alignment`; include `routine-execution-simulation` only when runtime or state-flow risk is material\n- THOROUGH: if delegation is available, spawn FOUR WorkRail Executors SIMULTANEOUSLY running `routine-plan-analysis`, `routine-hypothesis-challenge`, `routine-execution-simulation`, and `routine-philosophy-alignment`\n\nInterrogate subagent output (if used):\n- Do NOT treat auditor findings as your findings. They are raw input from junior analysts.\n- Where 2+ auditors flag the same issue -> likely real, but verify it yourself\n- Where one auditor flags a unique concern -> investigate; is it genuine or did they miss context?\n- Where auditors conflict -> reason through it yourself rather than splitting the difference\n- State what changed your assessment of the plan and what didn't\n\nPart B -- Refocus (apply fixes immediately):\n- update `implementation_plan.md` to incorporate amendments\n- update `slices` if the plan shape changed\n- extract out-of-scope work into `followUpTickets`\n- track resolved findings (cap at 10, drop oldest)\n\nSet context variables:\n- `planFindings`\n- `planConfidence`\n- `resolvedFindings`\n- `followUpTickets`\n\nRules:\n- the main agent is synthesizer and final decision-maker\n- do not delegate sequentially when audit routines are independent\n- do not silently accept plan drift; reflect changes in the plan artifact immediately",
|
|
125
|
+
"requireConfirmation": false
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "phase-4b-loop-decision",
|
|
129
|
+
"title": "Loop Exit Decision",
|
|
130
|
+
"prompt": "Provide a loop control artifact.\n\nDecision rules:\n- if `planFindings` is non-empty -> continue\n- if `planFindings` is empty -> stop, but enumerate what was checked to justify the clean pass\n- if max iterations reached -> stop and document remaining concerns\n\nOutput exactly:\n```json\n{\n \"artifacts\": [{\n \"kind\": \"wr.loop_control\",\n \"decision\": \"continue\"\n }]\n}\n```",
|
|
131
|
+
"requireConfirmation": true,
|
|
132
|
+
"outputContract": {
|
|
133
|
+
"contractRef": "wr.contracts.loop_control"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "phase-5-small-task-fast-path",
|
|
140
|
+
"title": "Phase 5: Small Task Fast Path",
|
|
141
|
+
"runCondition": {
|
|
142
|
+
"var": "taskComplexity",
|
|
143
|
+
"equals": "Small"
|
|
144
|
+
},
|
|
145
|
+
"prompt": "For Small tasks:\n- confirm target locations and relevant patterns with tools\n- implement the smallest correct change\n- verify with tests/build or a deterministic check\n- apply the user's coding philosophy as the active review lens before finalizing\n- provide a concise PR-ready summary\n\nDo not create heavyweight planning artifacts unless risk unexpectedly grows.",
|
|
146
|
+
"requireConfirmation": false
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"id": "phase-6-implement-slices",
|
|
150
|
+
"type": "loop",
|
|
151
|
+
"title": "Phase 6: Implement Slice-by-Slice",
|
|
152
|
+
"runCondition": {
|
|
153
|
+
"var": "taskComplexity",
|
|
154
|
+
"not_equals": "Small"
|
|
155
|
+
},
|
|
156
|
+
"loop": {
|
|
157
|
+
"type": "forEach",
|
|
158
|
+
"items": "slices",
|
|
159
|
+
"itemVar": "currentSlice",
|
|
160
|
+
"indexVar": "sliceIndex",
|
|
161
|
+
"maxIterations": 20
|
|
162
|
+
},
|
|
163
|
+
"body": [
|
|
164
|
+
{
|
|
165
|
+
"id": "phase-6a-implement-slice",
|
|
166
|
+
"title": "Implement Slice",
|
|
167
|
+
"prompt": "Implement slice `{{currentSlice.name}}`.\n\nBefore writing code, do a quick inline check:\n- if pivot triggers have fired or plan assumptions are clearly stale, stop and return to planning instead of coding through it\n- if target files or symbols no longer match the plan, stop and re-plan\n\nImplementation rules:\n- the main agent owns implementation\n- delegate only targeted cognitive routines via the WorkRail Executor (challenge, simulation, philosophy review), not the whole slice\n- read independent files in parallel when possible\n- implement incrementally and keep the slice within its intended boundary\n- apply the user's coding philosophy as the active implementation lens\n- run tests and build after implementation to confirm the slice works\n\nTrack whether this slice required:\n- a new special-case (`specialCaseIntroduced`)\n- an unplanned abstraction (`unplannedAbstractionIntroduced`)\n- unexpected file changes outside planned scope (`unexpectedScopeChange`)\n\nSet `verifyNeeded` to true if ANY of:\n- `sliceIndex` is odd (verify every 2 slices)\n- `specialCaseIntroduced = true`\n- `unplannedAbstractionIntroduced = true`\n- `unexpectedScopeChange = true`\n- tests or build failed\n\nIf `prStrategy = MultiPR`, stop with a concise PR package for user review.\n\nSet context variables:\n- `specialCaseIntroduced`\n- `unplannedAbstractionIntroduced`\n- `unexpectedScopeChange`\n- `verifyNeeded`",
|
|
168
|
+
"requireConfirmation": {
|
|
169
|
+
"var": "prStrategy",
|
|
170
|
+
"equals": "MultiPR"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "phase-6b-verify-slice",
|
|
175
|
+
"title": "Verify Slice",
|
|
176
|
+
"runCondition": {
|
|
177
|
+
"var": "verifyNeeded",
|
|
178
|
+
"equals": true
|
|
179
|
+
},
|
|
180
|
+
"prompt": "Evaluate what was just implemented with fresh eyes.\n\nReview:\n- does the implementation match the plan intent, not just the letter?\n- are there hidden assumptions or edge cases the implementation glossed over?\n- do invariants still hold?\n- are there philosophy-alignment regressions?\n- if multiple slices have passed since last verification, review all unverified slices together\n\nBefore delegating (if applicable), state: what is your honest assessment of the slice you just implemented? Where are you least confident?\n\nMode-adaptive delegation:\n- QUICK: self-verify only\n- STANDARD: if a fresh-eye trigger fired (`specialCaseIntroduced`, `unplannedAbstractionIntroduced`, or `unexpectedScopeChange`), optionally spawn ONE or TWO WorkRail Executors running `routine-hypothesis-challenge` and `routine-philosophy-alignment`\n- THOROUGH: if any fresh-eye trigger fired, spawn up to THREE WorkRail Executors running `routine-hypothesis-challenge`, `routine-execution-simulation`, and `routine-philosophy-alignment`\n\nAfter receiving subagent output (if used), interrogate: did they find something you genuinely missed, or are they flagging things you already considered and accepted? State what changed your assessment.\n\nSet context variables:\n- `verificationFindings`\n- `verificationFailed`\n\nRule:\n- if serious concerns are found, stop and return to planning or ask the user\n- do not rubber-stamp; this step exists specifically to catch what the implementation step missed",
|
|
181
|
+
"requireConfirmation": {
|
|
182
|
+
"var": "verificationFailed",
|
|
183
|
+
"equals": true
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"id": "phase-7-final-verification",
|
|
190
|
+
"type": "loop",
|
|
191
|
+
"title": "Phase 7: Final Verification & Handoff",
|
|
192
|
+
"runCondition": {
|
|
193
|
+
"var": "taskComplexity",
|
|
194
|
+
"not_equals": "Small"
|
|
195
|
+
},
|
|
196
|
+
"loop": {
|
|
197
|
+
"type": "while",
|
|
198
|
+
"conditionSource": {
|
|
199
|
+
"kind": "artifact_contract",
|
|
200
|
+
"contractRef": "wr.contracts.loop_control",
|
|
201
|
+
"loopId": "final_verification_loop"
|
|
202
|
+
},
|
|
203
|
+
"maxIterations": 2
|
|
204
|
+
},
|
|
205
|
+
"body": [
|
|
206
|
+
{
|
|
207
|
+
"id": "phase-7a-verify-and-fix",
|
|
208
|
+
"title": "Verify Integration and Fix Issues",
|
|
209
|
+
"prompt": "Perform integration verification across all implemented slices.\n\nRequired:\n- verify acceptance criteria\n- map invariants to concrete proof (tests, build results, explicit reasoning)\n- run whole-task validation commands\n- identify any invariant violations or regressions\n- confirm the implemented result aligns with the user's coding philosophy, naming any tensions explicitly\n- review cumulative drift across all slices\n- check whether repeated small compromises added up to a larger pattern problem\n\nIf issues are found, fix them immediately:\n- apply code fixes\n- re-run affected tests\n- update `implementation_plan.md` if the fix changed boundaries or approach\n\nSet context variables:\n- `integrationFindings`\n- `integrationPassed`\n- `regressionDetected`",
|
|
210
|
+
"requireConfirmation": false
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "phase-7b-loop-decision",
|
|
214
|
+
"title": "Final Verification Loop Decision",
|
|
215
|
+
"prompt": "Provide a loop control artifact.\n\nDecision rules:\n- if `integrationFindings` is non-empty and fixes were applied -> continue (re-verify the fixes)\n- if `integrationFindings` is empty or all issues resolved -> stop and produce handoff\n- if max iterations reached -> stop and document remaining concerns\n\nWhen stopping, include the handoff summary:\n- acceptance criteria status\n- invariant status\n- test/build summary\n- concise PR/MR description draft (why, test plan, rollout notes)\n- follow-up tickets\n- any philosophy tensions accepted intentionally and why\n\nKeep the handoff concise and executive-level. Do not auto-merge or push unless the user explicitly asks.\n\nOutput exactly:\n```json\n{\n \"artifacts\": [{\n \"kind\": \"wr.loop_control\",\n \"decision\": \"continue\"\n }]\n}\n```",
|
|
216
|
+
"requireConfirmation": true,
|
|
217
|
+
"outputContract": {
|
|
218
|
+
"contractRef": "wr.contracts.loop_control"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"description": "Independently evaluates a plan or implementation artifact against the user's coding philosophy. Produces findings by principle name and distinguishes blocking violations from acceptable tensions.",
|
|
6
6
|
"clarificationPrompts": [
|
|
7
7
|
"What artifact should I review? (plan, architecture summary, implementation diff, files)",
|
|
8
|
-
"What philosophy principles or user rules should I apply?",
|
|
9
8
|
"What mode is this review in? (plan, architecture, implementation)",
|
|
10
|
-
"What artifact name should I produce?"
|
|
9
|
+
"What artifact name should I produce?",
|
|
10
|
+
"Are `philosophySources` and `philosophyConflicts` available in context? (if not, I will discover from scratch)"
|
|
11
11
|
],
|
|
12
12
|
"preconditions": [
|
|
13
13
|
"A review artifact is available",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
],
|
|
25
25
|
"steps": [
|
|
26
26
|
{
|
|
27
|
-
"id": "step-
|
|
28
|
-
"title": "Step 1:
|
|
29
|
-
"prompt": "
|
|
30
|
-
"agentRole": "You are
|
|
27
|
+
"id": "step-discover-philosophy",
|
|
28
|
+
"title": "Step 1: Discover the Dev's Philosophy",
|
|
29
|
+
"prompt": "Discover the dev's coding philosophy and preferences. Check `philosophySources` context variable first — if it contains pointers to rules, Memory entries, or repo files, go read those sources directly.\n\nIf `philosophySources` is empty or unavailable, discover from scratch using this fallback chain:\n1. Memory MCP (if available): call `mcp_memory_conventions`, `mcp_memory_prefer`, `mcp_memory_recall` to retrieve learned preferences\n2. Active session rules / Firebender rules: read any rules or philosophy documents in context\n3. Repo patterns: infer preferences from how the codebase works — error handling, mutability, test style, naming, architecture\n\nAlso check `philosophyConflicts` — if stated rules conflict with repo patterns, note which apply to this review.\n\nWorking notes:\n- Philosophy sources consulted\n- Key principles discovered\n- Conflicts between stated and practiced philosophy",
|
|
30
|
+
"agentRole": "You are discovering what the dev actually cares about before judging their code against it.",
|
|
31
31
|
"requireConfirmation": false
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "step-
|
|
35
|
-
"title": "Step 2:
|
|
36
|
-
"prompt": "
|
|
34
|
+
"id": "step-understand-scope",
|
|
35
|
+
"title": "Step 2: Understand the Artifact and Select Principles",
|
|
36
|
+
"prompt": "Understand what you are reviewing and select the principles that matter.\n\nRead and summarize:\n- the artifact under review\n- the review mode (plan, architecture, implementation)\n- any supporting files or repo patterns needed for evidence\n\nSelect the subset of discovered principles that materially apply:\n- do not pretend every principle matters equally for every artifact\n- prioritize the principles actually implicated by the design or implementation\n- note any principles that are out of scope for this review\n\nIdentify:\n- which principles are actually touched by this artifact\n- where violations are most likely to appear\n- where principle tensions may naturally arise\n\nWorking notes:\n- Review scope\n- High-priority principles\n- Secondary principles\n- Likely risk areas\n- Possible tension zones",
|
|
37
37
|
"agentRole": "You are focusing the review on the principles that actually matter for this artifact.",
|
|
38
38
|
"requireConfirmation": false
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"id": "step-evaluate-artifact",
|
|
42
|
-
"title": "Step 3: Evaluate Principle-by-Principle",
|
|
42
|
+
"title": "Step 3: Evaluate Principle-by-Principle (from source, not summary)",
|
|
43
43
|
"prompt": "Evaluate the artifact against each relevant principle.\n\nFor each principle, determine:\n- what the artifact does well\n- what violates the principle, if anything\n- whether this is a Red violation, Orange issue, or Yellow tension\n- what change or justification would resolve it\n\nSeverity guide:\n- Red = blocking violation of a key philosophy principle\n- Orange = meaningful design quality issue that should be fixed or justified\n- Yellow = principle tension or trade-off that may be acceptable if explicit\n\nWorking notes:\n- Findings by principle\n- Evidence / citations\n- Severity\n- Recommended action or required justification",
|
|
44
44
|
"agentRole": "You are performing a principle-by-principle review with specific, evidence-based findings.",
|
|
45
45
|
"requireConfirmation": false
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"id": "step-identify-tensions",
|
|
49
|
-
"title": "Step 4: Identify Principle Tensions",
|
|
50
|
-
"prompt": "Identify where principles conflict.\n\nLook for cases like:\n- simplicity vs extensibility\n- YAGNI vs architecture cleanliness\n- explicitness vs verbosity\n- atomicity vs implementation complexity\n\nFor each tension:\n- name the principles involved\n- explain the trade-off\n- say what decision still needs to be made or documented\n\nWorking notes:\n- Principle tensions\n- Why they exist\n- What decision or explicit acceptance is needed",
|
|
49
|
+
"title": "Step 4: Identify Principle Tensions (including stated vs practiced)",
|
|
50
|
+
"prompt": "Identify where principles conflict.\n\nLook for cases like:\n- simplicity vs extensibility\n- YAGNI vs architecture cleanliness\n- explicitness vs verbosity\n- atomicity vs implementation complexity\n- stated philosophy vs actual repo patterns (e.g., rules say immutability but module uses mutable state)\n\nFor each tension:\n- name the principles involved\n- explain the trade-off\n- say what decision still needs to be made or documented\n\nWorking notes:\n- Principle tensions\n- Why they exist\n- What decision or explicit acceptance is needed",
|
|
51
51
|
"agentRole": "You are surfacing real trade-offs instead of flattening them into fake certainty.",
|
|
52
52
|
"requireConfirmation": false
|
|
53
53
|
},
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "routine-tension-driven-design",
|
|
3
|
+
"name": "Tension-Driven Design Generation",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Generates design candidates by deeply understanding a problem, identifying real tensions and constraints (including the dev's philosophy), and producing candidates that resolve those tensions differently. Each candidate includes explicit tradeoffs, failure modes, and philosophy alignment. Replaces perspective-based generation with constraint-driven generation for higher-quality, genuinely diverse candidates.",
|
|
6
|
+
"clarificationPrompts": [
|
|
7
|
+
"What problem should this design solve?",
|
|
8
|
+
"What acceptance criteria, invariants, and constraints must it respect?",
|
|
9
|
+
"Are `philosophySources` and `philosophyConflicts` available in context? (if not, I will discover from scratch)",
|
|
10
|
+
"What artifact name should I produce?"
|
|
11
|
+
],
|
|
12
|
+
"preconditions": [
|
|
13
|
+
"Problem statement is available",
|
|
14
|
+
"Acceptance criteria and non-goals are available",
|
|
15
|
+
"Relevant files, patterns, or codebase references are available",
|
|
16
|
+
"Agent has read access to the codebase"
|
|
17
|
+
],
|
|
18
|
+
"metaGuidance": [
|
|
19
|
+
"PURPOSE: generate genuinely different design candidates grounded in real problem tensions, not abstract perspectives.",
|
|
20
|
+
"ROLE: you are a designer, not an auditor or implementer. Think deeply about the problem before proposing solutions.",
|
|
21
|
+
"PHILOSOPHY: the dev's coding philosophy is a design constraint, not an afterthought review lens. Discover it and use it.",
|
|
22
|
+
"SIMPLICITY BIAS: always consider whether the problem even needs an architectural solution. The simplest change that works is a valid candidate.",
|
|
23
|
+
"REPO PATTERNS: study how the codebase already solves similar problems. The best design often adapts an existing pattern.",
|
|
24
|
+
"HONESTY: for each candidate, state what you gain, what you give up, and how it fails. Optimize for useful comparison, not persuasion."
|
|
25
|
+
],
|
|
26
|
+
"steps": [
|
|
27
|
+
{
|
|
28
|
+
"id": "step-discover-philosophy",
|
|
29
|
+
"title": "Step 1: Discover the Dev's Philosophy",
|
|
30
|
+
"prompt": "Discover the dev's coding philosophy and preferences before designing anything.\n\nCheck `philosophySources` context variable first — if it contains pointers to rules, Memory entries, or repo files, go read those sources directly.\n\nIf `philosophySources` is empty or unavailable, discover from scratch:\n1. Memory MCP (if available): call `mcp_memory_conventions`, `mcp_memory_prefer`, `mcp_memory_recall` to retrieve learned preferences\n2. Active session rules / Firebender rules: read any rules or philosophy documents in context\n3. Repo patterns: infer preferences from how the codebase works — error handling, mutability, test style, architecture\n\nNote any `philosophyConflicts` (stated rules vs actual repo patterns).\n\nWorking notes:\n- Philosophy sources consulted\n- Key principles discovered\n- Conflicts between stated and practiced philosophy\n- Which principles are likely to constrain this design",
|
|
31
|
+
"agentRole": "You are discovering what the dev actually cares about before designing solutions.",
|
|
32
|
+
"requireConfirmation": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "step-understand-deeply",
|
|
36
|
+
"title": "Step 2: Understand the Problem Deeply",
|
|
37
|
+
"prompt": "Understand the problem before proposing anything.\n\nReason through:\n- What are the core tensions in this problem? (e.g., performance vs simplicity, flexibility vs type safety, backward compatibility vs clean design)\n- How does the codebase already solve similar problems? Study the most relevant existing patterns — analyze the architectural decisions and constraints they protect, not just list files.\n- What's the simplest naive solution? Why is it insufficient? (If it IS sufficient, note that — it may be the best candidate.)\n- What makes this problem hard? What would a junior developer miss?\n- Which of the dev's philosophy principles are under pressure from this problem's constraints?\n\nWorking notes:\n- Core tensions (2-4 real tradeoffs, not generic labels)\n- Existing patterns analysis (decisions, invariants they protect)\n- Naive solution and why it's insufficient (or sufficient)\n- What makes this hard\n- Philosophy principles under pressure",
|
|
38
|
+
"agentRole": "You are reasoning deeply about the problem space before generating any solutions.",
|
|
39
|
+
"requireConfirmation": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "step-generate-candidates",
|
|
43
|
+
"title": "Step 3: Generate Candidates from Tensions",
|
|
44
|
+
"prompt": "Generate design candidates that resolve the identified tensions differently.\n\nMANDATORY candidates:\n1. The simplest possible change that satisfies acceptance criteria. If the problem doesn't need an architectural solution, say so.\n2. Follow the existing repo pattern — adapt what the codebase already does for similar problems. Don't invent when you can adapt.\n\nAdditional candidates (1-2 more):\n- Each must resolve the identified tensions DIFFERENTLY, not just vary surface details\n- Each must be grounded in a real constraint or tradeoff, not an abstract perspective label\n- Consider philosophy conflicts: if the stated philosophy disagrees with repo patterns, one candidate could follow the stated philosophy and another could follow the established pattern\n\nFor each candidate, produce:\n- One-sentence summary of the approach\n- Which tensions it resolves and which it accepts\n- The specific failure mode you'd watch for\n- How it relates to existing repo patterns (follows / adapts / departs)\n- What you gain and what you give up\n- Which philosophy principles it honors and which it conflicts with (by name)\n\nRules:\n- candidates must be genuinely different in shape, not just wording\n- if all candidates converge on the same approach, that's signal — note it honestly rather than manufacturing fake diversity\n- cite specific files or patterns when they materially shape a candidate",
|
|
45
|
+
"agentRole": "You are generating genuinely diverse design candidates grounded in real tensions.",
|
|
46
|
+
"requireConfirmation": false
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "step-compare-and-recommend",
|
|
50
|
+
"title": "Step 4: Compare via Tradeoffs and Recommend",
|
|
51
|
+
"prompt": "Compare candidates through tradeoff analysis, not checklists.\n\nFor the set of candidates, assess:\n- Which tensions does each resolve best?\n- Which has the most manageable failure mode?\n- Which best fits the dev's philosophy? Where are the philosophy conflicts?\n- Which is most consistent with existing repo patterns?\n- Which would be easiest to evolve or reverse if assumptions are wrong?\n\nProduce a clear recommendation with rationale tied back to tensions and philosophy. If two candidates are close, say so and explain what would tip the decision.\n\nSelf-critique your recommendation:\n- What's the strongest argument against your pick?\n- What would make you switch to a different candidate?\n- What assumption, if wrong, would invalidate this design?\n\nWorking notes:\n- Comparison matrix (tensions x candidates)\n- Recommendation and rationale\n- Strongest counter-argument\n- Pivot conditions",
|
|
52
|
+
"agentRole": "You are comparing candidates honestly and recommending based on tradeoffs, not advocacy.",
|
|
53
|
+
"requireConfirmation": false
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "step-deliver",
|
|
57
|
+
"title": "Step 5: Deliver the Design Candidates",
|
|
58
|
+
"prompt": "Create `{deliverableName}`.\n\nRequired structure:\n- Problem Understanding (tensions, what makes it hard)\n- Philosophy Constraints (which principles matter, any conflicts)\n- Candidates (each with: summary, tensions resolved/accepted, failure mode, repo-pattern relationship, gains/losses, philosophy fit)\n- Comparison and Recommendation\n- Self-Critique (strongest counter-argument, pivot conditions)\n- Open Questions for the Main Agent\n\nThe main agent will interrogate this output — it is raw investigative material, not a final decision. Optimize for honest, useful analysis over polished presentation.",
|
|
59
|
+
"agentRole": "You are delivering design analysis for the main agent to interrogate and build on.",
|
|
60
|
+
"requireConfirmation": false
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|