You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/brownfield-workflow.adoc
+68-16Lines changed: 68 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,33 +53,85 @@ Present as a table.
53
53
Pick one bounded context to start with.
54
54
Choose one that is small, well-isolated, and has a change request pending.
55
55
56
-
== Phase 0.5: Socratic CodeTheory Recovery
56
+
== Phase 0.5: Socratic Code-Theory Recovery
57
57
58
58
Before changing anything, you need to recover the "theory" of the bounded context -- what https://pages.cs.wisc.edu/~remzi/Naur.pdf[Peter Naur] called the mental model that lives in the heads of the original developers. In a brownfield project, this model is not documented. The code is the only source.
59
59
60
-
This phase uses *Socratic CodeTheory Recovery*: a two-phase workflow that builds understanding through recursive question refinement before producing documentation.
60
+
This phase uses *Socratic Code-Theory Recovery*: a two-phase workflow that builds understanding through recursive question refinement before producing documentation.
61
61
62
62
=== Phase 1: Build the Question Tree
63
63
64
64
Start with five high-level questions about the bounded context and decompose them recursively. Use Semantic Anchors as decomposition guides: *arc42* for architecture, *Cockburn Use Cases* for specification, *ISO 25010* for quality, *Nygard ADRs* for decisions.
65
65
66
-
.Starting Questions (adapt to your bounded context)
66
+
Each leaf in the tree is either `[ANSWERED]` (with code evidence: file, function, line) or `[OPEN]` (with Category and Ask role). The output is two AsciiDoc files: `QUESTION_TREE.adoc` (full reasoning trace) and `OPEN_QUESTIONS.adoc` (handoff document, grouped by role).
67
+
68
+
Copy the prompt below into a session that has read access to the bounded context. Adapt `[bounded context path]` and the example questions if your domain warrants it; do not change the leaf classification, Q-ID scheme, or output files.
69
+
70
+
.Prompt: Phase 1 — Build the Question Tree
67
71
[source,txt]
68
72
----
69
-
1. What problem does this bounded context solve and for whom?
70
-
2. What is the specification of this bounded context?
71
-
3. What is the architecture of this bounded context?
72
-
4. What quality goals drive the design?
73
-
5. What risks and technical debt exist?
73
+
You are performing Socratic Code-Theory Recovery on a brownfield bounded
74
+
context located at [bounded context path]. Phase 1 of two.
75
+
76
+
Goal: recover the program's theory (Naur, 1985) from source code through
77
+
recursive question refinement, before any documentation is written.
78
+
79
+
Process:
80
+
81
+
1. Start with five high-level questions about the bounded context:
82
+
Q1 What problem does this bounded context solve, and for whom?
83
+
Q2 What is the specification of this bounded context?
84
+
Q3 What is the architecture of this bounded context?
85
+
Q4 What quality goals drive the design?
86
+
Q5 What risks and technical debt exist?
87
+
88
+
2. Decompose each question recursively. Use these Semantic Anchors as
89
+
decomposition guides:
90
+
- arc42 — 12 sub-questions for architecture (Q3 branch)
91
+
- Cockburn Use Cases — Primary Actor, Trigger, Main Success Scenario,
92
+
Extensions, Postconditions for specification (Q2 branch)
- State precisely what cannot be answered, and why.
116
+
117
+
5. Output two files in AsciiDoc:
118
+
119
+
QUESTION_TREE.adoc
120
+
- Full hierarchical tree with all nodes and Q-IDs
121
+
- Each leaf marked [ANSWERED] (with evidence) or [OPEN] (with Category
122
+
and Ask role)
123
+
- Includes all reasoning, not only the leaves
124
+
125
+
OPEN_QUESTIONS.adoc
126
+
- Only the [OPEN] leaves, copied verbatim from QUESTION_TREE.adoc
127
+
- Grouped by Ask role (one section per role)
128
+
- Each question short enough to be answered in 1-3 sentences
129
+
130
+
Do not write any other documentation in this phase. Phase 2 will synthesize
131
+
the answered tree into PRD, specification, arc42, and ADRs — only after the
132
+
team has filled in the [OPEN] leaves.
74
133
----
75
134
76
-
Each leaf in the tree is either `[ANSWERED]` (with code evidence: file, function, line) or `[OPEN]` (with Category and Ask role).
77
-
78
-
The output is two files:
79
-
80
-
* `QUESTION_TREE.adoc` -- the full reasoning trace
81
-
* `OPEN_QUESTIONS.adoc` -- the handoff document, grouped by role (Product Owner, Architect, Developer, Domain Expert, Operations)
82
-
83
135
=== Between Phases: Team Answers the Open Questions
84
136
85
137
Route the Open Questions to the people who can answer them. In a controlled experiment with a 13,000-line Go codebase, *11 targeted questions* were sufficient to close the gap between reverse-engineered documentation and the original. The questions are precise because the recursive decomposition ensures they are specific, not vague.
@@ -233,6 +285,6 @@ If the system cannot be built or started, you have a different problem -- fix th
233
285
* Simon Martinelli, https://unifiedprocess.ai/[AI Unified Process] -- the bounded-context approach to spec-driven development in existing systems.
234
286
* Eric Evans, https://www.domainlanguage.com/ddd/[Domain-Driven Design] -- the foundational work on bounded contexts and strategic design.
235
287
* Michael Feathers, _Working Effectively with Legacy Code_ -- techniques for establishing test coverage in systems without tests.
236
-
* Peter Naur, "Programming as Theory Building" (1985) -- argues that programming is about building a mental model ("theory") that cannot be fully captured in documentation. Socratic CodeTheory Recovery tests this claim in the context of LLM-generated code.
288
+
* Peter Naur, "Programming as Theory Building" (1985) -- argues that programming is about building a mental model ("theory") that cannot be fully captured in documentation. Socratic Code-Theory Recovery tests this claim in the context of LLM-generated code.
237
289
* link:#/brownfield-experiment-report[Brownfield Experiment Report] -- controlled experiment: delete documentation from a greenfield project, regenerate from code, compare. Full methodology and findings.
238
290
* link:#/brownfield-fair-comparison[Fair Comparison Report] -- three approaches (Direct, Socratic, Two-Phase) with identical team answers. Measures the structural value of the Question Tree.
0 commit comments