Skip to content

Add Socratic Code Theory Recovery to Brownfield workflow#455

Merged
rdmueller merged 1 commit into
LLM-Coding:mainfrom
raifdmueller:feat/socratic-code-theory-recovery
May 2, 2026
Merged

Add Socratic Code Theory Recovery to Brownfield workflow#455
rdmueller merged 1 commit into
LLM-Coding:mainfrom
raifdmueller:feat/socratic-code-theory-recovery

Conversation

@raifdmueller
Copy link
Copy Markdown
Contributor

@raifdmueller raifdmueller commented May 2, 2026

Summary

  • Extends Phase 0.5 of the Brownfield workflow with Socratic Code Theory Recovery: a two-phase approach to recovering a program's "theory" (Naur 1985) from source code
  • Phase 1 builds a Question Tree by recursively decomposing 5 high-level questions using Semantic Anchors as decomposition guides (arc42, Cockburn, ISO 25010, Nygard)
  • Team answers Open Questions (typically 10-15, routed by Ask role)
  • Phase 2 synthesizes documentation with dual traceability (Q-ID + team answer markers)

Based on controlled experiments with Bausteinsicht (Go, 13k lines):

  • LLM recovers FRs (21 vs 7 original), ACs (69 vs 40), complete glossary, security docs
  • Cannot recover: business context, design rationale, quality goal priorities, aspirational features
  • 11 targeted questions were sufficient to close the gap
  • Semantic Anchors validated as both prompt compression and decomposition heuristics

Also adds: spec drift detection, reconciliation workflow, updated prompt cheat sheet, Naur 1985 and experiment reports in Further Reading.

Test plan

  • Verify brownfield-workflow page renders correctly at /brownfield
  • Check all internal links (spec-driven-development, anchor references)
  • Verify Further Reading links are accessible

🤖 Generated with Claude Code

Summary by CodeRabbit

Dokumentation

  • Neue Anleitung für Brownfield-Projekte hinzugefügt: Beschreibt die Anpassung des Spec-driven-Workflows für bestehende Systeme, einschließlich strukturiertes Code-Recovery, Baseline-Test-Etablierung, Spec-Drift-Reconciliation und Best Practices für iteratives Onboarding sowie inkrementelle Expansion.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Warning

Rate limit exceeded

@raifdmueller has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 40 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 076b3b7a-77ca-4f1e-8a35-23ce13b67011

📥 Commits

Reviewing files that changed from the base of the PR and between d95ed38 and 8ab7663.

📒 Files selected for processing (1)
  • docs/brownfield-workflow.adoc

Walkthrough

Eine neue Dokumentationsdatei docs/brownfield-workflow.adoc wird hinzugefügt, die beschreibt, wie man den spec-gesteuerten Workflow auf Legacy-Projekte anwendet. Sie behandelt Bounded-Context-Onboarding, die Socratic Code Theory Recovery mit zwei Phasen und Spec-Drift-Reconciliation.

Changes

Brownfield-Workflow-Dokumentation

Layer / File(s) Zusammenfassung
Einführung & Kernkonzepte
docs/brownfield-workflow.adoc (Zeilen 1–33)
Titel, Metadaten und Einführung in das Brownfield Paradox; Begründung, warum nur die geänderten Bounded Contexts spezifiziert werden sollten.
Onboarding-Phasen
docs/brownfield-workflow.adoc (Zeilen 34–80)
Phase 0 zur Bounded-Context-Auswahl mit DDD-Richtlinien und Phase 0.5: Socratic Code Theory Recovery als rekursiver Frageverfeinerungsprozess vor der Dokumentationserstellung.
Theorie-Recovery & Baseline-Tests
docs/brownfield-workflow.adoc (Zeilen 61–128)
Detaillierte Beschreibung der Question-Tree-Konstruktion, Synthesephase mit Antworten und Code-Evidence sowie die Etablierung von Baseline-Tests aus Use Cases.
Grenzen & Spec-Drift-Management
docs/brownfield-workflow.adoc (Zeilen 129–159)
Erklärung nicht-rekonstruierbarer Themen (z. B. geschäftliche Logik), semantische Anker als Kompressions- und Dekompositionsheuristiken, sowie Periodic Reverse-Engineering mit Diff-Ergebnissen.
Standard-Workflow & Erweiterung
docs/brownfield-workflow.adoc (Zeilen 160–184)
Definition der Phase 1–12 nach Onboarding: New Features, Bug Fixes via TDD-Loop bei verletzten Use Cases, Refactoring mit Baseline-Tests; Regeln für inkrementelle Expansion über Contexts hinweg.
Prompt-Referenzen & Limitierungen
docs/brownfield-workflow.adoc (Zeilen 185–235)
Prompt Cheat Sheet Tabelle mit Phasen, Prompts und Anchor Links; Abschnitte zu Anwendungsgrenzen und kuratierte Further-Reading-Liste.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 Minuten

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel ist präzise und beschreibt akkurat die Hauptänderung: Hinzufügen der 'Socratic Code Theory Recovery' zur Brownfield-Workflow-Dokumentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 48 minutes and 40 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/brownfield-workflow.adoc (1)

45-50: ⚡ Quick win

Prompt-“Codeblöcke” in [source,language] kapseln (Guideline-Konformität).

Die Prompt-Blöcke werden derzeit als Literalblöcke mit ---- dargestellt (z.B. Zeilen 45-50 und 113-118). Die Guidelines verlangen für “code blocks” den Einsatz von [source,language]-Delimitern. Das würde Konsistenz/Formatierung (und ggf. Syntax-Handling) verbessern.

Bitte jeweils z.B. in einen [source,txt]-Block umformen (oder eine passende Sprache wählen) statt reinem -----Literalblock.

Also applies to: 113-118

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/brownfield-workflow.adoc` around lines 45 - 50, Replace the literal
`----` prompt blocks with AsciiDoc source blocks using `[source,txt]` (or
another appropriate language) so the two prompt/example blocks are wrapped as
`[source,txt]`...`----` → `[source,txt]`...`----`; locate the blocks introduced
by the `.Prompt` directive containing the "Analyze the codebase in src/.
Identify bounded contexts..." text and the later similar prompt (the other block
noted in the review) and convert each to the `[source,txt]` block style,
preserving the inner content and surrounding directives.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/brownfield-workflow.adoc`:
- Around line 9-16: Replace all nonstandard AsciiDoc links of the form
link:`#/`...[] with AsciiDoc anchor syntax <<anchor-id,Link Text>> and fix the
specific incorrect reference link:`#/spec-driven-development` to use the correct
anchor/file name (spec-driven-workflow) and appropriate link text; update every
occurrence mentioned (e.g., the spec-driven link in the header and other
link:`#/`...[] instances). Convert all .Prompt blocks into standard source blocks
using [source,language] +---- ... ---- (replace each .Prompt block at the
occurrences around lines 45–50 and 113–118 with [source,Prompt] style or the
correct language tag). Inspect and normalize the table cells that currently use
|{empty}-- and replace them with a standard empty cell representation (e.g.,
just | or |-) so table rendering is consistent. Ensure all replacements preserve
original link texts/anchor IDs and update any anchor IDs if you rename
spec-driven-development → spec-driven-workflow.

---

Nitpick comments:
In `@docs/brownfield-workflow.adoc`:
- Around line 45-50: Replace the literal `----` prompt blocks with AsciiDoc
source blocks using `[source,txt]` (or another appropriate language) so the two
prompt/example blocks are wrapped as `[source,txt]`...`----` →
`[source,txt]`...`----`; locate the blocks introduced by the `.Prompt` directive
containing the "Analyze the codebase in src/. Identify bounded contexts..." text
and the later similar prompt (the other block noted in the review) and convert
each to the `[source,txt]` block style, preserving the inner content and
surrounding directives.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 87f29b02-842b-4a7f-8fc7-e2bf5fda064c

📥 Commits

Reviewing files that changed from the base of the PR and between c706cdf and d95ed38.

📒 Files selected for processing (1)
  • docs/brownfield-workflow.adoc

Comment on lines +9 to +16
You have mastered the link:#/spec-driven-development[greenfield workflow].
Now you want to apply it to an existing codebase.

The core principles remain the same: small steps, high autonomy, error correction loops.
But brownfield projects add a challenge that greenfield projects do not have: *the system already exists*.
You cannot start with a blank slate.
You must understand what is there before you change it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

head -n 250 docs/brownfield-workflow.adoc | cat -n

Repository: LLM-Coding/Semantic-Anchors

Length of output: 13732


🏁 Script executed:

# Suche nach Ankerdefinitionen im Dokument
grep -n "\[\[" docs/brownfield-workflow.adoc

# Suche nach alle link:`#/` Referenzen
grep -n "link:`#/`" docs/brownfield-workflow.adoc

# Prüfe auf weitere .adoc Dateien, die Anker definieren könnten
find docs -name "*.adoc" -type f | head -20

Repository: LLM-Coding/Semantic-Anchors

Length of output: 1343


🏁 Script executed:

# Prüfe die Struktur einer Anker-Datei
head -50 docs/anchors/arc42.adoc | cat -n

# Suche nach Ankerdefinitionen in den Anker-Dateien
grep -n "\[\[" docs/anchors/arc42.adoc

# Prüfe, ob es ein Build-Skript oder Konfiguration für Links gibt
find . -name "*.yml" -o -name "*.yaml" -o -name "Makefile" -o -name "*.gradle" -o -name "*.xml" | grep -E "(build|config|doc)" | head -10

Repository: LLM-Coding/Semantic-Anchors

Length of output: 1612


🏁 Script executed:

# Prüfe die Asciidoc-Linter-Konfiguration
cat .asciidoc-linter.yml

# Suche nach Link-Verarbeitung oder Build-Skripten
grep -r "link:#" . --include="*.js" --include="*.ts" --include="*.py" --include="*.sh" 2>/dev/null | head -20

# Prüfe, ob es eine Dokumentations-Build-Datei gibt
ls -la docs/ | grep -E "(build|publish|render)" 
git ls-files | grep -E "^\." | grep -E "(yml|yaml|json)$" | head -20

Repository: LLM-Coding/Semantic-Anchors

Length of output: 833


🏁 Script executed:

# Suche nach xref: oder anderen AsciiDoc-Link-Formaten in der Datei
grep -n "xref:" docs/brownfield-workflow.adoc

# Suche nach ähnlichen link:`#/` Patterns in anderen Dateien
grep -r "link:`#/`" docs/*.adoc | head -10

# Prüfe deploy.yml für Hinweise auf Link-Verarbeitung
cat .github/workflows/deploy.yml | head -100

Repository: LLM-Coding/Semantic-Anchors

Length of output: 2899


🏁 Script executed:

# Prüfe render-docs.js für Link-Verarbeitung
cat scripts/render-docs.js 2>/dev/null | head -100

# Oder suche nach Scripts im website Verzeichnis
find website -name "*.js" | head -10

# Prüfe Codeblock-Formatierung in anderen adoc Dateien
grep -A 2 "^\." docs/*.adoc | grep -E "(Prompt|source)" | head -20

Repository: LLM-Coding/Semantic-Anchors

Length of output: 4183


🏁 Script executed:

# Prüfe spec-driven-workflow.adoc um Muster zu vergleichen
grep -B 2 -A 3 "\[source," docs/spec-driven-workflow.adoc | head -30

# Prüfe ALL .adoc Dateien nach Prompt-Blöcken
grep -n "\.Prompt" docs/*.adoc

# Prüfe, wie andere Dateien Links formatieren
grep -n "<<" docs/*.adoc | head -10

Repository: LLM-Coding/Semantic-Anchors

Length of output: 672


🏁 Script executed:

# Prüfe, wie viele Dateien link:`#/` verwenden
grep -r "link:`#/`" docs/ --include="*.adoc" | wc -l

# Prüfe, ob es irgendwelche <<anchor>> Links gibt
grep -r "<<" docs/ --include="*.adoc" | grep -v "<<<" | head -10

# Vergleiche Prompt-Block mit source-Block Beispiel
echo "=== Brownfield Prompt-Block ===" 
sed -n '45,50p' docs/brownfield-workflow.adoc
echo ""
echo "=== Spec-Driven source-bash Block ===" 
grep -A 5 "\[source,bash\]" docs/spec-driven-workflow.adoc | head -8

Repository: LLM-Coding/Semantic-Anchors

Length of output: 1427


🏁 Script executed:

# Prüfe, wie viele .Prompt Blöcke es insgesamt gibt
grep -r "\.Prompt" docs/ --include="*.adoc" | wc -l

# Prüfe, wie andere .adoc Dateien Literalblöcke verwenden
grep -B 1 "^----" docs/spec-driven-workflow.adoc | grep -E "^\." | head -10

# Prüfe die Tabellen-Formatierung genauer
sed -n '195,218p' docs/brownfield-workflow.adoc

Repository: LLM-Coding/Semantic-Anchors

Length of output: 1500


🏁 Script executed:

# Prüfe, ob spec-driven-development.adoc existiert
find docs -name "*spec-driven-development*" -o -name "*spec-driven-workflow*"

# Prüfe all-anchors.adoc für Include-Struktur
head -30 docs/all-anchors.adoc

Repository: LLM-Coding/Semantic-Anchors

Length of output: 857


Verwenden Sie AsciiDoc-Standard-Linkformat <<anchor-id,Link Text>> statt link:#/...[]

Die Datei nutzt durchgehend die nicht-standard Syntax link:#/anchor/...[] (z. B. Zeilen 9, 42, 63, 193, 197, 205, 209, 212). Laut Coding Guidelines müssen interne AsciiDoc-Links das Format <<anchor-id,Link Text>> verwenden. Zusätzlich ist die Referenz auf link:#/spec-driven-development`` fehlerhaft – die Datei heißt spec-driven-workflow.adoc, nicht `spec-driven-development.adoc`.

Ersetzen Sie alle link:#/...[] durch korrekte AsciiDoc-Anker und korrigieren Sie den Dateinamen-Fehler.

Ebenso sollten die .Prompt-Blöcke (Zeilen 45–50, 113–118) in [source,language]-Format umgewandelt werden, um den Guidelines zu entsprechen. Die Tabellenzellen |{empty}-- (Zeilen 201, 213, 217) sollten überprüft und standardisiert werden.

Betroffene Zeilen: 9–16, 42–44, 63–64, 45–50, 113–118, 191–218

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/brownfield-workflow.adoc` around lines 9 - 16, Replace all nonstandard
AsciiDoc links of the form link:`#/`...[] with AsciiDoc anchor syntax
<<anchor-id,Link Text>> and fix the specific incorrect reference
link:`#/spec-driven-development` to use the correct anchor/file name
(spec-driven-workflow) and appropriate link text; update every occurrence
mentioned (e.g., the spec-driven link in the header and other link:`#/`...[]
instances). Convert all .Prompt blocks into standard source blocks using
[source,language] +---- ... ---- (replace each .Prompt block at the occurrences
around lines 45–50 and 113–118 with [source,Prompt] style or the correct
language tag). Inspect and normalize the table cells that currently use
|{empty}-- and replace them with a standard empty cell representation (e.g.,
just | or |-) so table rendering is consistent. Ensure all replacements preserve
original link texts/anchor IDs and update any anchor IDs if you rename
spec-driven-development → spec-driven-workflow.

Phase 0.5 now uses two-phase Socratic Code Theory Recovery:
- Phase 1: Build Question Tree (5 starting questions, recursive
  decomposition using arc42/Cockburn/ISO 25010/Nygard as guides)
- Team answers Open Questions (typically 10-15, routed by role)
- Phase 2: Synthesize documentation with Q-ID traceability

Based on controlled experiments (Bausteinsicht, 13k lines Go):
- LLM recovers FRs, ACs, building blocks, glossary, security docs
- Cannot recover: business context, design rationale, quality goal
  priorities, aspirational features, performance budgets
- 11 targeted questions sufficient to close the gap

Added: spec drift detection, reconciliation workflow, Naur 1985
reference, experiment report links, updated prompt cheat sheet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@raifdmueller raifdmueller force-pushed the feat/socratic-code-theory-recovery branch from d95ed38 to 8ab7663 Compare May 2, 2026 12:04
@rdmueller rdmueller merged commit b4c911d into LLM-Coding:main May 2, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants