Skip to content

Commit 6db579a

Browse files
authored
Merge pull request #401 from raifdmueller/feat/business-rules
feat: add Business Rules (BR-IDs) to Use Case structure
2 parents 35416fa + eb9ba96 commit 6db579a

7 files changed

Lines changed: 67 additions & 10 deletions

File tree

docs/brownfield-workflow.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Ralf D. Müller
66

77
== Introduction
88

9-
You have mastered the link:spec-driven-workflow.adoc[greenfield workflow].
9+
You have mastered the link:#/workflow[greenfield workflow].
1010
Now you want to apply it to an existing codebase.
1111

1212
The core principles remain the same: small steps, high autonomy, error correction loops.
@@ -64,7 +64,7 @@ The output is a set of use cases that describe the *existing* behavior -- not wh
6464
.Prompt
6565
----
6666
Read the code in [bounded context path]. Extract the existing behavior as Use Cases.
67-
For each Use Case: ID, Trigger, Actors, Preconditions, Main Flow, Alternative Flows, Postconditions.
67+
For each Use Case: ID, Trigger, Actors, Preconditions, Main Flow, Alternative Flows, Postconditions, Business Rules.
6868
Save as docs/specs/use-cases-[context-name].adoc.
6969
----
7070

@@ -152,7 +152,7 @@ Stable code that nobody touches does not need specs.
152152
|link:#/anchor/tdd-london-school[TDD London] / link:#/anchor/tdd-chicago-school[Chicago]
153153

154154
|Continue
155-
|Follow link:spec-driven-workflow.adoc[the standard workflow] from Step 3 (PRD) or Step 8 (Implementation), depending on whether you are adding new features or fixing bugs.
155+
|Follow link:#/workflow[the standard workflow] from Step 3 (PRD) or Step 8 (Implementation), depending on whether you are adding new features or fixing bugs.
156156
|{empty}--
157157
|===
158158

docs/spec-driven-workflow.adoc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Click on any anchor to see its full definition on the Semantic Anchors website.
3131
[IMPORTANT]
3232
====
3333
This workflow is designed for greenfield projects built from scratch with AI assistance.
34-
For existing codebases, see link:brownfield-workflow.adoc[Adapting the Workflow to Brownfield Projects].
34+
For existing codebases, see link:#/brownfield[Adapting the Workflow to Brownfield Projects].
3535
====
3636

3737
== The Key Principle: Small Steps, High Autonomy
@@ -210,7 +210,7 @@ From the PRD, generate a full specification:
210210
[source]
211211
----
212212
Create a detailed specification from the PRD. Include:
213-
- Use Cases (Trigger, Main Flow, Alternative Flows, Postconditions)
213+
- Use Cases (Trigger, Main Flow, Alternative Flows, Postconditions, Business Rules)
214214
- Activity Diagrams for all flows (not just the happy path)
215215
- Acceptance criteria in Gherkin format
216216
Save as .adoc files in src/docs/specs/.
@@ -224,6 +224,9 @@ Without a trigger, neither the AI nor a tester knows when the use case begins.
224224
* *Alternative Flows*: Named branches (A1, A2, ...) for error handling, validation failures, and edge cases.
225225
* *Postconditions*: The guaranteed system state after successful completion.
226226
Postconditions are what your tests assert.
227+
* *Business Rules*: Numbered rules (BR-001, BR-002, ...) that capture validation constraints, calculation logic, or domain invariants.
228+
Business rules make implicit knowledge explicit.
229+
Without them, the AI invents its own validation logic -- or skips it entirely.
227230

228231
This structure follows Alistair Cockburn's Use Case format, which LLMs recognize reliably.
229232
The more precise the use case, the less the AI has to guess during implementation.
@@ -431,7 +434,7 @@ Consider assigning different AI models to different review roles.
431434
Run ATAM reviews after each major architectural change, not just once.
432435
Groom the backlog more frequently as the project grows.
433436
*Legacy codebases*:: This workflow assumes you start from scratch.
434-
See link:brownfield-workflow.adoc[Adapting the Workflow to Brownfield Projects] for a dedicated guide covering reverse engineering, baseline test coverage, and incremental migration using bounded contexts.
437+
See link:#/brownfield[Adapting the Workflow to Brownfield Projects] for a dedicated guide covering reverse engineering, baseline test coverage, and incremental migration using bounded contexts.
435438
*Frontend / HTML applications*:: This workflow works well for backend code, CLIs, and libraries where the compiler and TDD provide strong error correction.
436439
Frontend applications can be built with the same approach, but consistent UI is harder to verify automatically.
437440
The error correction layers that make backend development reliable (compiler errors, test failures) have no direct equivalent for visual consistency.
@@ -457,7 +460,7 @@ The essential one-liners for each phase, with the Semantic Anchors they activate
457460
|link:#/anchor/plain-english-strunk-white[Strunk & White]
458461

459462
|Specification
460-
|`Create a detailed spec with Use Cases (Trigger, Main Flow, Alternative Flows, Postconditions), Activity Diagrams (all paths), and Gherkin acceptance criteria.`
463+
|`Create a detailed spec with Use Cases (Trigger, Main Flow, Alternative Flows, Postconditions, Business Rules), Activity Diagrams (all paths), and Gherkin acceptance criteria.`
461464
|link:#/anchor/gherkin[Gherkin]
462465

463466
|Architecture
@@ -529,7 +532,7 @@ Start with the Socratic Method for requirements and see where it leads.
529532
If you discover anchors that work well in your workflow, https://github.com/LLM-Coding/Semantic-Anchors/blob/main/CONTRIBUTING.md[contribute them to the collection].
530533

531534
Once you are comfortable with this greenfield workflow, you can adapt it to existing codebases.
532-
See link:brownfield-workflow.adoc[Adapting the Workflow to Brownfield Projects] for a step-by-step guide.
535+
See link:#/brownfield[Adapting the Workflow to Brownfield Projects] for a step-by-step guide.
533536

534537
=== Further Reading
535538

docs/specs/01_use_cases.adoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ stop
4747
* URL enthält Filter-Parameter (für Deep-Linking)
4848
* Filter-Auswahl wird in localStorage persistiert
4949

50+
=== Geschäftsregeln
51+
* **BR-01-001**: Ein Anker kann mehreren Rollen zugeordnet sein. Filterung zeigt alle Anker, die mindestens eine der ausgewählten Rollen enthalten.
52+
* **BR-01-002**: Bei Auswahl von "All Roles" oder leerem Filter werden alle Anker ohne Einschränkung angezeigt.
53+
5054
=== Fehlerszenarien
5155
* **F1**: Keine Anker für ausgewählte Rolle → System zeigt "Keine Anker gefunden für diese Rolle"
5256
* **F2**: Browser-localStorage nicht verfügbar → Filter wird nicht persistiert, aber funktioniert während Session
@@ -100,6 +104,10 @@ stop
100104
* Treemap ist interaktiv und responsive
101105
* Kategorien sind proportional zur Anzahl ihrer Anker dargestellt
102106

107+
=== Geschäftsregeln
108+
* **BR-02-001**: Kategorie-Größe in der Treemap entspricht der Anzahl der enthaltenen Anker.
109+
* **BR-02-002**: Kategorien ohne Anker (nach Filterung) werden nicht dargestellt.
110+
103111
=== Fehlerszenarien
104112
* **F1**: Metadata-Datei nicht gefunden → System zeigt Fehlermeldung "Kategorien können nicht geladen werden"
105113
* **F2**: Sehr kleine Bildschirmgröße → Treemap wird zu vereinfachter Liste
@@ -151,6 +159,11 @@ stop
151159
* Suchergebnisse sind nach Relevanz sortiert
152160
* URL enthält Suchquery (für Deep-Linking)
153161

162+
=== Geschäftsregeln
163+
* **BR-03-001**: Suche durchsucht Anker-Namen, Proponenten, Core Concepts und Tags. Andere Felder werden nicht durchsucht.
164+
* **BR-03-002**: Suche wird debounced (min. 150ms Verzögerung) um übermäßige Anfragen zu vermeiden.
165+
* **BR-03-003**: Suchbegriffe werden auf maximal 100 Zeichen begrenzt.
166+
154167
=== Fehlerszenarien
155168
* **F1**: Suchindex nicht geladen → System zeigt "Suche vorübergehend nicht verfügbar"
156169
* **F2**: Sehr lange Suchbegriffe → System limitiert auf 100 Zeichen
@@ -249,6 +262,11 @@ stop
249262
* Sprachpräferenz wird bei nächstem Besuch beibehalten
250263
* `<html lang="...">` ist korrekt gesetzt
251264

265+
=== Geschäftsregeln
266+
* **BR-05-001**: Unterstützte Sprachen: Englisch (EN) und Deutsch (DE). Englisch ist die Standardsprache.
267+
* **BR-05-002**: Nur UI-Texte (Navigation, Labels, Buttons, Tooltips) werden übersetzt. Anker-Inhalte bleiben in der Originalsprache.
268+
* **BR-05-003**: Fehlende Übersetzungen fallen auf Englisch zurück, niemals auf leere Strings.
269+
252270
=== Fehlerszenarien
253271
* **F1**: Übersetzung fehlt → System zeigt Fallback auf Englisch
254272
* **F2**: localStorage nicht verfügbar → Sprache nur für aktuelle Session
@@ -295,6 +313,10 @@ stop
295313
* Theme-Präferenz wird persistiert
296314
* Alle Komponenten (inkl. Treemap) respektieren Theme
297315

316+
=== Geschäftsregeln
317+
* **BR-06-001**: Theme-Ermittlung folgt der Priorität: 1. localStorage, 2. `prefers-color-scheme`, 3. Light als Default.
318+
* **BR-06-002**: Theme-Wechsel erfolgt ohne Seiten-Reload und ohne visuelles Flackern.
319+
298320
=== Fehlerszenarien
299321
* **F1**: localStorage nicht verfügbar → Theme nur für Session, reagiert auf prefers-color-scheme
300322
* **F2**: Theme-CSS nicht geladen → Fallback auf System-Theme
@@ -362,6 +384,11 @@ stop
362384
* Automatisches Feedback ist gepostet (bei Validation)
363385
* Bei Approval: PR ist erstellt mit generiertem Content
364386

387+
=== Geschäftsregeln
388+
* **BR-07-001**: Jeder vorgeschlagene Anker muss die vier Qualitätskriterien erfüllen: Precise, Rich, Consistent, Attributable.
389+
* **BR-07-002**: Vorschläge, die reine Instruktionen ohne konzeptuelle Tiefe sind (z.B. "TLDR", "ELI5"), werden abgelehnt.
390+
* **BR-07-003**: Duplikate bestehender Anker werden abgelehnt mit Verweis auf den existierenden Eintrag.
391+
365392
=== Fehlerszenarien
366393
* **F1**: GitHub Actions Workflow schlägt fehl → Issue bleibt ohne Auto-Comment, manueller Review nötig
367394
* **F2**: Copilot API nicht verfügbar → Maintainer erstellt Entry manuell
@@ -420,6 +447,10 @@ stop
420447
* Issue hat passendes Label
421448
* Contributor hat klares Feedback
422449

450+
=== Geschäftsregeln
451+
* **BR-08-001**: Validierungs-Score basiert auf einer 10-Punkt-Skala. Score > 7 gilt als "validated".
452+
* **BR-08-002**: Die vier Bewertungskriterien sind: Precise, Rich, Consistent, Attributable — gleichgewichtet.
453+
423454
=== Fehlerszenarien
424455
* **F1**: Copilot API Timeout → Workflow posted "Validation failed, manual review required"
425456
* **F2**: Issue-Body unlesbar → Workflow posted "Cannot parse issue, please use template"
@@ -519,6 +550,11 @@ stop
519550
* URL ist share-bar (kopierbar)
520551
* State (Filter, Language) ist in URL kodiert
521552

553+
=== Geschäftsregeln
554+
* **BR-10-001**: Gültige Deep-Link-Formate: `#/anchor/<anchor-id>` (Hash-basiert).
555+
* **BR-10-002**: Anker-IDs sind case-sensitive und müssen exakt mit der ID in der Anchor-Datei übereinstimmen.
556+
* **BR-10-003**: Filter- und Sprachparameter aus der URL werden beim Laden angewendet.
557+
522558
=== Fehlerszenarien
523559
* **F1**: Anker-ID ungültig → 404 Seite mit Suchfunktion
524560
* **F2**: Alter Link (nach Rename) → System zeigt Redirect-Hinweis oder 301 Redirect

scripts/render-docs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ renderFile(
8484
path.join(WEB_DOCS, 'spec-driven-workflow.html')
8585
)
8686

87+
renderFile(
88+
path.join(ROOT, 'docs/brownfield-workflow.adoc'),
89+
path.join(WEB_DOCS, 'brownfield-workflow.html')
90+
)
91+
8792
renderFile(
8893
path.join(ROOT, 'docs/anchor-evaluations.adoc'),
8994
path.join(WEB_DOCS, 'anchor-evaluations.html')

website/public/data/contracts.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"description": "What we mean when we say 'spec'",
77
"descriptionDe": "Was wir meinen, wenn wir 'Spec' sagen",
88
"anchors": ["gherkin", "bdd-given-when-then"],
9-
"template": "When we talk about a \"specification\" or \"spec\", we mean:\n- Use Cases with Trigger, Main Flow, Alternative Flows, and Postconditions\n- Activity Diagrams for all flows (not just the happy path)\n- Acceptance criteria in Gherkin format (Given/When/Then)",
10-
"templateDe": "Wenn wir von einer \"Spezifikation\" oder \"Spec\" sprechen, meinen wir:\n- Use Cases mit Trigger, Hauptablauf, Alternativabläufe und Nachbedingungen\n- Activity Diagrams für alle Abläufe (nicht nur der Happy Path)\n- Akzeptanzkriterien im Gherkin-Format (Given/When/Then)",
9+
"template": "When we talk about a \"specification\" or \"spec\", we mean:\n- Use Cases with Trigger, Main Flow, Alternative Flows, Postconditions, and Business Rules (BR-IDs)\n- Activity Diagrams for all flows (not just the happy path)\n- Acceptance criteria in Gherkin format (Given/When/Then)",
10+
"templateDe": "Wenn wir von einer \"Spezifikation\" oder \"Spec\" sprechen, meinen wir:\n- Use Cases mit Trigger, Hauptablauf, Alternativabläufe, Nachbedingungen und Geschäftsregeln (BR-IDs)\n- Activity Diagrams für alle Abläufe (nicht nur der Happy Path)\n- Akzeptanzkriterien im Gherkin-Format (Given/When/Then)",
1111
"category": "requirements"
1212
},
1313
{

website/src/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function initApp() {
110110
addRoute('/rejected-proposals', renderRejectedProposalsPage)
111111
addRoute('/all-anchors', renderAllAnchorsPage)
112112
addRoute('/workflow', renderWorkflowPage)
113+
addRoute('/brownfield', renderBrownfieldPage)
113114
addRoute('/contracts', renderContractsPageHandler)
114115
addRoute('/evaluations', renderEvaluationsPage)
115116

@@ -233,6 +234,15 @@ function renderWorkflowPage() {
233234
loadDocContent('docs/spec-driven-workflow.adoc')
234235
}
235236

237+
function renderBrownfieldPage() {
238+
const pageContent = document.getElementById('page-content')
239+
if (!pageContent) return
240+
241+
pageContent.innerHTML = renderDocPage()
242+
updateActiveNavLink()
243+
loadDocContent('docs/brownfield-workflow.adoc')
244+
}
245+
236246
function renderContractsPageHandler() {
237247
const pageContent = document.getElementById('page-content')
238248
if (!pageContent) return
@@ -458,6 +468,8 @@ function handleLanguageChange() {
458468
loadDocContent('docs/all-anchors.adoc')
459469
} else if (currentRoute === '/workflow') {
460470
loadDocContent('docs/spec-driven-workflow.adoc')
471+
} else if (currentRoute === '/brownfield') {
472+
loadDocContent('docs/brownfield-workflow.adoc')
461473
} else if (currentRoute === '/') {
462474
initCardGridVisualization()
463475
}

website/src/utils/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const ROUTE_TITLES = {
1717
'/about': 'About — Semantic Anchors',
1818
'/contracts': 'Semantic Contracts — Semantic Anchors',
1919
'/workflow': 'Development Workflow — Semantic Anchors',
20+
'/brownfield': 'Brownfield Workflow — Semantic Anchors',
2021
'/evaluations': 'Evaluations — Semantic Anchors',
2122
'/contributing': 'Contributing — Semantic Anchors',
2223
'/changelog': 'Changelog — Semantic Anchors',

0 commit comments

Comments
 (0)