Skip to content

Count chains over the graph wherever only the count is wanted - #46

Merged
sajonaro merged 1 commit into
mainfrom
count-chains
Oct 7, 2026
Merged

sajonaro merged 1 commit into
mainfrom
count-chains

Conversation

@sajonaro

@sajonaro sajonaro commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

A follow-up to T2 (#44). Diagnosis stopped listing chains there, but three commands still listed every chain the model allows just to count them.

What changes

These sites used to list every chain:

Where Why it listed them
model validate --write-scenarios It listed them twice: once for the message, once for the file's scenario_count.
model validate staleness check It expanded the whole sidecar to read one hash.
model diff It needed the scenario counts of both revisions.

Now:

  • scenarios.CountChains counts with the DP that diagnosis uses. On a cycle it falls back to listing.
  • scenarios.SiblingHash reads only the sidecar's hash. It keeps the full reader's error for an unknown format.

The listings that really walk chains are unchanged: simulate --from-scenarios, the MCP scenario listings, and incident scenario matching.

Speed (BenchmarkScale, new count case)

Tiers Chains Listing Counting
6 273,511 3.2 s 18 ms
8 9,853,471 does not finish 38 ms
10 354,734,551 — 73 ms

Docs

  • how-it-works.md still said diagnosis expands every chain, and advised meta.scenarios: none past seven tiers. It now states the current cost.
  • The benchmark's comment table is re-measured. Its chain counts predated scenario IDs name their chain; no chain twice #43's duplicate removal (7,471 at four tiers, not 10,921).

Verified

  • Tests: the 400-graph property test now also checks CountChains against Expand. A cycle test pins the fallback, and a SiblingHash test covers both formats, an absent file, and an unknown format.
  • go test ./... and mkdocs build --strict pass.
  • Downstream harness: 18/18. The storefront still writes 14,429 scenarios, its committed scenario_count.

Diagnosis stopped listing chains in #44, but three commands still listed
every chain the model allows only to count it: model validate
--write-scenarios (twice: once to print, once for the file's
scenario_count), model diff, and the staleness check in model validate,
which expanded the whole sidecar to read its hash.

scenarios.CountChains counts by the DP diagnosis uses, falling back to
listing on a cycle, and scenarios.SiblingHash reads only the hash. Six
tiers count in 18 ms (listing took 3.2 s) and ten, 354 million chains, in
73 ms. The storefront still counts 14,429, its committed scenario_count.

The how-it-works page still said diagnosis expands every chain and
advised meta.scenarios: none past seven tiers; it now says what is true.
The benchmark's table is re-measured: its chain counts predated the
duplicate removal of #43.
@sajonaro
sajonaro merged commit 1bda0d0 into main Oct 7, 2026
4 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant