Skip to content

Turn the slice into a document, a diagram and two commands - #32

Merged
peopleworks merged 1 commit into
mainfrom
feat/walkthrough-document
Aug 23, 2026
Merged

Turn the slice into a document, a diagram and two commands#32
peopleworks merged 1 commit into
mainfrom
feat/walkthrough-document

Conversation

@peopleworks

Copy link
Copy Markdown
Owner

Phase 2 of #23 — where the feature becomes usable. xaflogic walkthrough --from <seed> and the xaf_walkthrough MCP tool. Offline, either language, no API key, no network.

What comes out

Run against the fixture whose process goes through a virtual method:

# Walkthrough — RecalculateTotals

Started from **RecalculateTotals** — action, `Controllers/TotalsControllers.cs:16`.

Nodes in this slice: 4. Depth limit: 3, not reached — the walk ran out of calls it
could resolve, and the ones it could not are listed below.

## Flow

```mermaid
flowchart TD
    n0(["RecalculateTotals"])
    n1[["TotalsControllerBase"]]
    n2["TotalsControllerBase.RecalculateAction_Execute"]
    n3["TotalsControllerBase.Recalculate"]

    n1 -->|declares| n0
    n0 -->|calls| n2
    n2 -->|calls| n3
```

## What takes part
- **TotalsControllerBase** — controller, `Controllers/TotalsControllers.cs:14`## Step by step
1. **TotalsControllerBase** declares **RecalculateTotals**`Controllers/TotalsControllers.cs:16`## What this walk could not follow
- **`Recalculate`**, called from **TotalsControllerBase.RecalculateAction_Execute** — the
  declaration is virtual; which override runs is decided by the run-time type, not by the source.
  - Could be: `TotalsControllerBase.Recalculate`, `InvoiceTotalsController.Recalculate`,
    `CreditNoteTotalsController.Recalculate`

## What this walk is, and is not
It was allowed a depth of 3 and did not need all of it.
- Relationships between entities are not followed…

The diagram is not drawn, it is emitted

Node for node, arrow for arrow, off the walk's own edge set. Nothing in the renderer decides what to draw.

That is the point rather than an implementation detail. Ask a language model for a Mermaid diagram of a process and it will produce one — including edges that do not exist, drawn with a confidence indistinguishable from the true ones, in a format whose entire value is that a reader believes it at a glance.

So the test counts:

Assert.Equal(slice.Edges.Count, arrows);
Assert.Equal(slice.Nodes.Count, boxes);

Counted, not sampled — an invented arrow is exactly what a spot check of a diagram that looks right would miss.

Shapes carry meaning rather than decoration: ([action]), [[controller]], [(entity)], {{rule}}. A reader tells a stored thing from a command without a legend.

xaf_walkthrough — the first tool about a process

The other ten MCP tools return atoms. An agent asked "how does approval work" has to guess which atoms to fetch, and then guess whether it has them all — and the guess that stops one atom early produces a confident answer with a step missing from it.

This one hands back the traced path and what it could not follow. An agent told "this call is virtual, here are the three overrides" can go read all three; an agent given silence cannot know to.

Four things reading the output caught

Written before the assertions, as usual.

  1. The opening sentence contradicted the section below it. A walk halted by a virtual call reported that it "ran out of code to follow" — three lines above a heading listing the code it could not follow. A walk ends three ways, not two: the process ended, the depth limit ended it, or the source stopped being decidable. It now says which.
  2. Citations used backslashes. Every one of them would diff the day somebody regenerated the document on another machine.
  3. A node that is only ever the source of a step was never cited. A step cites its target, so the controller appeared in the document with nowhere to go and read it. Hence What takes part — every node gets its place, exactly once.
  4. Caught by running the command: writing the document through AnsiConsole wrapped it to the terminal width and broke the Mermaid block across lines. It goes to stdout raw now, so walkthrough … > process.md gives the same file --out does.

Translated, like everything else here

Twenty-nine new labels in both languages, including the diagram's edge verbs. A test asserts the Spanish page contains no English heading — a page half in one language is worse than either.

What is left

Phases 3 and 4: --narrate (opt-in prose over a structure that is already fixed) and --since <ref> (what changed in this process). Both additive. Per the design, if the project stopped here it would already have gained the ability to explain a process, without a single new runtime dependency.

373 tests, zero warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W45tzJFX3NoSrk7svtQeKT

Phase 2 of #23, which is where the feature becomes usable: `xaflogic
walkthrough --from <seed>` and the `xaf_walkthrough` MCP tool. Both work
offline, in either language, with no API key and no network.

The diagram is emitted from the walk's own edge set -- node for node, arrow for
arrow -- and nothing in the renderer decides what to draw. That is the point
rather than an implementation detail: ask a model for a Mermaid diagram of a
process and it will produce one, including edges that do not exist, drawn with
a confidence indistinguishable from the true ones, in a format whose whole
value is that a reader believes it at a glance. A test counts arrows against
edges and boxes against nodes, because an invented arrow is precisely what a
spot check of a diagram that looks right would miss.

xaf_walkthrough is the first MCP tool that answers a question about a process.
The other ten return atoms, so an agent asked how something works has to guess
which atoms to fetch and then guess whether it has them all -- and the guess
that stops one atom early produces a confident answer with a step missing.

Three things reading the output caught that the tests would only have
enshrined:

- The opening sentence contradicted the section below it. A walk halted by a
  virtual call reported that it "ran out of code to follow", three lines above
  a heading listing the code it could not follow. A walk ends three ways, not
  two, and now says which.
- Citations were written with backslashes, so every one of them would diff the
  day somebody regenerated the document on another machine.
- A node that is only ever the source of a step was never cited at all -- the
  controller was named with nowhere to go and read it. Hence "What takes part",
  where every node gets its place exactly once.

And one caught by running the command: writing the document through
AnsiConsole wrapped it to the terminal width and broke the Mermaid block. It
goes to stdout raw, so `walkthrough ... > process.md` gives the same file
`--out` does.

373 tests, zero warnings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W45tzJFX3NoSrk7svtQeKT
Comment on lines +42 to +48
foreach (var edge in slice.Edges)
{
// An edge can only be drawn between two nodes that are in the slice. The walk never
// records one that is not, and drawing a dangling arrow would invent a node.
if (ids.TryGetValue(edge.From, out var from) && ids.TryGetValue(edge.To, out var to))
sb.AppendLine($" {from} -->|{Verb(edge.Kind, labels)}| {to}");
}
Comment on lines +118 to +125
foreach (var edge in slice.Edges)
{
if (!byId.TryGetValue(edge.From, out var from) || !byId.TryGetValue(edge.To, out var to))
continue;

// The citation is the target's, because the target is what the step introduces.
sb.AppendLine($"{++step}. **{from.Name}** {Verb(edge.Kind)} **{to.Name}** — {At(project, to)}");
}
@peopleworks
peopleworks merged commit f816bf5 into main Aug 23, 2026
6 checks passed
@peopleworks
peopleworks deleted the feat/walkthrough-document branch August 23, 2026 05:09
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