Skip to content

feat(insights): keep words out of the chain - #49

Merged
jgrodziski merged 2 commits into
mainfrom
feat/insights-words-fold
Nov 18, 2026
Merged

jgrodziski merged 2 commits into
mainfrom
feat/insights-words-fold

Conversation

@jgrodziski

Copy link
Copy Markdown
Contributor

Two commits. Refs #6.

1. docs(plan): close M19 on PetClinic

Issue #6's acceptance criteria are all met on main (M19a/b/c, #26–#46), so PLAN now says so:

  • §20.4: the live-run box and the docs box are ticked.
  • The Definition of Done is restated for what was actually tested: M19a/b on Broadleaf, and M19c on Spring PetClinic in Broadleaf's place (the side-car under prompt "2", 139 records, imported and exported cmp-equal, plus the v1 migration). A "Met" paragraph is added.
  • The §22 rows for M19a/b/c give the real merge dates.

2. feat(insights): keep words out of the chain

The problem. Each unit's fingerprint folded in its dependencies' whole fingerprints, including the words the prompt asks the model to define. But no caller's prompt ever shows a callee's words (DependencySummary is a summary and a concept). So a correction to the word lists re-explained everything above the units it touched. On PetClinic, #42 made 9 units stale through their own words and 44 more through this cascade alone.

The rule.

  • Each unit now has two hashes:
    • the fingerprint, stored on its records as before;
    • the chain (chainOf), which is every input except the words, folded over the dependencies' chains. It is never stored.
  • A dependent folds in a dependency's chain. The one exception is a module: it reconciles its types' word entries into its glossary, so it folds in their whole fingerprints (readsWordsOf).
  • Source, comments, signatures, facts, model, depth, prompt version and missing dependencies are all in the chain, so changes to any of them still cascade.

No store is re-explained for the switch. A record whose stamp matches the formula from before the split (stampedBeforeSplit) is reused. That stamp is only ever compared, never written. A match means every transitive input is unchanged, words included, so the new rule would reuse the record too.

Measured on a copy of the paid PetClinic store:

calls tokens in / out cost
the old fold, before the function words 0 (all 106 stamps reproduced) — —
today's words, store as stamped 53 121 067 / 55 665 ~$0.08
today's words, store stamped under the split 10 26 758 / 12 925 ~$0.02

A store stamped before this change still pays its 53 calls once. An old stamp mixes words and source into one hash, so it can't tell which of the two changed. Records get the new stamp as they are re-explained; nothing is rewritten on reuse.

Tests. 9 new tests:

  • a callee's words leave its callers and its type reused;
  • a type's words re-explain its module, even when the module's own word list didn't change;
  • source changes still cascade;
  • old stamps are reused while nothing changed, refused after a source change, and still pay the cascade on a words change (the known limit, pinned by a test).

Six mutants of the rule are each killed: no module exception, the old formula, old stamps refused, words in the chain, whole fingerprints in the chain, and the run stamping the chain.

Docs. docs/insights.md IN-5, docs/vocabulary.md (the open question is closed), the website's Explaining bottom-up and Explain cost pages, a PLAN §20.3 "As built" paragraph and a §23 decision row.

Verification

  • pnpm -r --filter '!@codegraph/website' typecheck
  • pnpm -r --no-bail test: 3 335 tests
  • ./test.sh --ts --skip-install: all checks passed

🤖 Generated with Claude Code

https://claude.ai/code/session_01PKCVgyytH9LKzUTsUaKxeH

jgrodziski and others added 2 commits November 18, 2026 10:24
Issue #6's criteria are met on main (M19a/b/c, PRs #26-#46), so PLAN
says so. §20.4 ticks the live run (M20: 68 calls, 79 records, 70 with
words, 3 glossaries) and the docs box (docs/vocabulary.md, #45). The
Definition of Done is restated for what was tested: M19a/b on
Broadleaf, M19c on Spring PetClinic in Broadleaf's place, with the
side-car (prompt "2", 139 records) importing and exporting cmp-equal,
and the v1 migration. The §22 rows for M19a/b/c give the
merge dates of #26-#30 and #46.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyytH9LKzUTsUaKxeH
A dependent hashed its dependencies' whole fingerprints, words
included, though no caller's prompt shows a callee's words. A
correction to the word lists therefore re-explained everything
above the units it touched: 53 calls on Spring PetClinic for 9
units whose words moved.

Each unit now has two hashes. The fingerprint is stored on its
records as before. The chain (chainOf) is every input but the words,
over the dependencies' chains, and is never stored. A dependent
hashes a dependency's chain, except a module, which reconciles its
types' word entries into its glossary and so hashes their whole
fingerprints (readsWordsOf). Source, comments, signatures, facts,
model, depth and missing dependencies are all in the chain and still
cascade.

No store is re-explained for the switch: a record whose stamp matches
the fold from before (stampedBeforeSplit) is reused. That stamp is
compared, never written. A match means every transitive input is
unchanged, words included.

Measured on a copy of the PetClinic store: the old fold reproduces
all 106 stamps (0 calls); today's words cost 53 calls as stamped and
10 on a store stamped under the split (~$0.08 against ~$0.02). An
existing store still pays the 53 once. 9 new tests; six mutants of
the rule are each killed. docs/insights.md IN-5, docs/vocabulary.md,
the website's explanation and cost pages and PLAN §20.3/§23 follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PKCVgyytH9LKzUTsUaKxeH
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
codegraph 5263bf9 Commit Preview URL

Branch Preview URL
Nov 18 2026, 10:24 AM

@jgrodziski
jgrodziski merged commit 18e872a into main Nov 18, 2026
100 of 102 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.

1 participant