Cross-project strategy · revised after review

Preserving the Why

How to keep AI coding sessions coherent across time — minimizing tokens, errors, and silent regressions.

Claude Code · solo-developer strategy · April 2026 · v2 (post review board)

The problem

Between sessions, the AI forgets why the code is there.

A future enhancement looks reasonable. The change compiles. Tests pass. A silent constraint — a workaround, a rate limit, a legal requirement — has just been erased.

Tokens

Re-exploring the repo every session.

Errors

Lost invariants, broken assumptions, regressions.

Reliability

Critical rules depend on memory — and memory decays.

What we're optimizing for

↓

Minimize tokens

Targeted loading. Don't re-read the whole repo to answer a narrow question.

✓

Minimize errors

Preserve the why across sessions so enhancements don't silently regress.

★

Maximize reliability

Critical rules enforced, not remembered.

Part 1

Today's stack

Three layers of context capture, already in use. Each has a job. Each has limits.

The three layers you have today

Layer 1

In-code comments

Localized why at the constraint site. Seen whenever the file is read. Travels with refactors.

Layer 2

docs/context/ (8 files)

Snapshots of current state: architecture, interfaces, conventions, security, ops, testing, gotchas, requirements.

Layer 3

CLAUDE.md directives

Scoped triggers: "before modifying X, read Y." Tells the AI what to load for sensitive areas.

Maintained by the context-save skill, invoked via Stop / PreCompact / SessionEnd hooks.

What the AI sees on any edit

Seen for free

  • Every comment in the file being edited
  • Module-level docstring at the top
  • What you type in this conversation
  • CLAUDE.md directives (auto-loaded)

Only on explicit trigger

  • Comments in other files (must Read)
  • git blame / commit history
  • docs/context/ files (must match the task)
  • Cross-file invariants with no single owner

The right-hand column is where most gaps live.

Where today's stack leaks 6 gaps

Five were identified up front. The sixth surfaced during the review board pass — and it's the most common.

1

Staleness

Comments/docs lag reality.

2

Never captured

Reason was in someone's head. Never written.

3

Wrong-trigger scope

Directive names one area; change lands elsewhere.

4

Cross-cutting behavior

Invariant lives in the interaction between files.

5

Judgment failures

AI reads the rule, "improves" past it.

6

Attention / retrieval failure new

Context loaded. Trigger fired. AI still drops it — from saturation or from conflicting sources.

Gap 6 — the quiet killer

Two flavors, same root

  • Authority conflict — comment says one thing, test implies another, ADR is stale, requirement vague. AI picks the wrong source.
  • Attention decay — constraint is in the prompt, but under long-context saturation the model under-weights it during generation.

Why it matters

Having the context isn't the same as obeying it. Gap 6 is why doc-only strategies plateau. The fix isn't more documents — it's stronger signal: an explicit authority order, plus executable guardrails that fail loud.

Codex named it authority conflict; Gemini named it attention/retrieval failure. Same gap.

Part 2

The revised design

Original proposal had 5 layers. Review board pushed back. The revised shape is 4 layers, 1 manifest, 1 authority order — fewer documents, stronger enforcement.

Four primitives, not five

PrimitiveHoldsJob
1. Comments / docstrings Localized why + test docstrings as spec Seen on every Read. Failing test output prints the constraint.
2. Slim docs/context/ 4 files architecture.md, invariants.md, interfaces.md, operations.md Current-state snapshot. No more 8-file sprawl.
3. ADRs rare Catastrophic-trap decisions only 3–5 lifetime per project. With frontmatter. Everything else stays in docstrings.
4. Executable guardrails Unit + Semgrep + selective Hypothesis + golden tests The only layer that actually forces respect. Fails loud.

Supporting: criticality.yml (path → invariants/ADRs/tests manifest) drives a PreToolUse hook that auto-injects relevant context. No manual grep ritual.

The authority order v3 revision

Linear stack for canonical truth. Separate parallel axis for agent memory — because memory is a recall aid, not an authority.

Canonical truth — linear precedence

Tests
>
Spec / requirements
>
ADRs
>
Code comments
>
Context notes

Parallel axis — behavioral recall

Agent memory — recall aid, never final authority

Rule: if a test enforces it, the test is right. Memory can remind; artifacts decide. Memory never wins conflicts with any written artifact — if forced to linearize, it sits below context notes.

Linear stack: Codex (v2). Parallel memory axis: both reviewers (v3). Without this separation, people over-trust memory.

ADRs — rare, structured, searchable

  • 3–5 per project lifetime. Reserve for catastrophic-trap decisions only.
  • If the why fits in a docstring, put it in the docstring.
  • Every ADR gets frontmatter: status, scope, supersedes, last_verified, tags.
  • last_verified is the staleness killer. Re-verify quarterly.
  • Referenced from code: # See ADR-0007. Indexed in criticality.yml.

Gemini wanted ADRs killed. Codex wanted them structured. The revision keeps them — but at a drastically lower volume, so they can't rot into a graveyard.

Failure mode

Context Bankruptcy. Unverified ADRs multiply faster than they decay. AI hallucinates from stale sources. Worse than no ADRs at all.

Countermeasure

Ruthless scope. Write a new ADR or delete an old one — no other options on save.

ADR with frontmatter


---
id: ADR-0007
status: Accepted
scope: price-services
supersedes: null
last_verified: 2026-04-19
tags: [ib, yahoo, data-routing, catastrophic-trap]
---

# IB for realtime, Yahoo for historical

## Context
IB HTTP API times out on 5Y weekly bars. Yahoo has a 15-minute delay.

## Decision
IB for live/delayed. Yahoo for historical.

## Alternatives rejected
- All IB: fails on 5Y weekly requests
- All Yahoo: 15m delay unacceptable for live

## Consequences
Two code paths in price services. Fallback order: IB → Yahoo → DB cache.

## Invariant test
tests/test_price_routing.py::test_historical_uses_yahoo
  

Frontmatter makes it searchable, staleable, and supersedable. last_verified is the single most important field.

Executable guardrails — the enforcement layer

Both reviewers agreed: docs don't prevent judgment failures. Only tests do. And not every rule needs the same tool.

Unit + integration tests

Default. Example-based. Known inputs, known outputs. Fast feedback.

Semgrep / static checks revived

3–10 cheap rules per project. Forbid dangerous patterns, require wrappers. Zero-token enforcement.

Golden / approval tests

For high-risk outputs. Catches "looks cleaner, behaves differently" — the classic AI refactor failure.

Hypothesis (property-based) selective

Only for parsers, transforms, schedulers, state machines, pricing/math, serialization. Not the default.

Dropped from the default stack: quarterly mutation testing. Defer until the test suite is fast and stable; it's triage-heavy and easy to abandon.

Test-driven context Gemini

Put the why in the test docstring. When the AI breaks the rule, the failing test output literally prints the architectural constraint.


def test_historical_uses_yahoo():
    """Historical price requests must route to Yahoo, never IB.

    WHY: IB HTTP API times out on 5Y weekly bars (see ADR-0007).
         The fallback chain is IB-live -> Yahoo-historical -> DB-cache.
         If this test fails, you've broken the data-routing invariant.
    """
    client = PriceClient()
    result = client.get_history("AAPL", period="5Y", interval="weekly")
    assert client.last_source == "yahoo", (
        "Historical request reached IB - violates ADR-0007 data routing"
    )
  

The failing assertion becomes a self-describing error. AI can't "improve past" what a test explicitly names.

criticality.yml + PreToolUse hook replaces manual ritual

Both reviewers flagged the 4-step manual grep workflow as fragile. Replace it with deterministic path-based routing.


# criticality.yml  - maps code paths to required context
- path: "src/services/ib_client.py"
  invariants: [docs/context/invariants.md#data-routing]
  adrs: [ADR-0007]
  must_run: [tests/test_price_routing.py]

- path: "src/trading/**"
  invariants: [docs/context/invariants.md#trading-rules]
  adrs: [ADR-0002, ADR-0005]
  must_run: [tests/test_trading_invariants.py]
  change_impact_prompt: true   # force AI to answer: what could this break?
  

A Claude Code PreToolUse hook reads this before any Edit/Write, auto-injects the listed context, and (when flagged) prompts the change-impact question. No scattered CLAUDE.md triggers.

Coverage — honest accounting revised

Reviewers were right: "closed" was rhetoric. The honest claim is reduced probability, unevenly.

Gap Today Revised design Dominant closer
Staleness low high Tests + last_verified
Never-captured rules low medium ADRs + docstrings
Wrong-trigger scope medium high criticality.yml hook
Cross-cutting behavior low high Semgrep + property tests
Judgment failures low medium Executable guardrails only
Attention / retrieval (Gap 6) low medium Authority order + test docstrings

No gap reaches "closed." Judgment failures and Gap 6 are the hardest — they plateau at "medium" because models can always over-ride context; only failing tests are non-negotiable.

Costs — honest numbers revised

ChangeSetup (one-time)OngoingTokens
Slim docs/context/ ~1 day (absorb gotchas → invariants.md; delete stubs) ~10 min per material change Lower (4 files vs 8)
ADRs (rare) 2–4 hours (template + 3–5 backfills per project) 20–45 min per ADR including review + linking Neutral
Semgrep checks 1–2 hours per project (3–10 rules) ~15 min per new rule Zero in conversation
Hypothesis (selective) 1–3 hours per applicable surface Only when contracts change Zero in conversation
criticality.yml + hook 3–4 hours (hook script + initial paths) Grows with project Variable — measure per triggered edit

Original deck said "ADRs: 10–15 min" — both reviewers said that's unrealistic. Revised: 20–45 min including the context switch to draft + link properly.

What you get back revised

5 / 6

Gaps materially reduced
"Closed" was overstated.
Judgment + Gap 6 plateau at medium.

0

Silent invariant violations
For encoded invariants.
Unencoded rules still at risk.

?

Token savings
Claimed -40% was speculation.
Measure before claiming.

The original deck claimed measurable token savings and "5/5 gaps closed." Review board pushed back on both. Revised: honest reductions, not marketing numbers.

The meta-risk — Context Bankruptcy two subclasses

v2 identified one subclass (doc bankruptcy). v3 adds a second once memory enters the picture — shadow context, hidden accumulation outside reviewable artifacts.

Doc bankruptcy (v2)

  • ADRs multiply faster than verified
  • Hypothesis tests bit-rot
  • Triggers miss real impact path
  • AI hallucinates from stale writing

Shadow context (v3)

  • Durable decisions accumulate only in memory
  • Stale memories survive code changes
  • Cross-project contamination
  • "Agent remembers" excuses skipping ADRs
  • Hard to debug: behavior from memory, not artifacts

Countermeasures

  • 3–5 ADRs lifetime; delete, don't accumulate
  • last_verified — quarterly re-verify or retire
  • Write-back: memory that changes behavior → artifact
  • Promotion Protocol at milestone end
  • Per-project memory wings, not shared global vault
  • Expiry / recency bias on entries

One-line policy (Codex): Memory can remind; artifacts decide.

Rollout — revised timing shorter

Phase 0 · 1 day

Clean up

  • Collapse docs/context to 4 files
  • Fix deck overclaims
  • Write review findings in
Phase 1 · 3–4 days

Foundation

  • Update context-save skill: authority order (linear + parallel memory axis)
  • criticality.yml format + PreToolUse hook
  • Change-impact prompt skill
  • Narrow /qatests WHY-docstring rule (triggered, not blanket)
  • Adopt Superpowers subset (repo scan, change impact, test selection, spec-to-checklist, diff audit)
  • Write one ADR as template
Phase 2 · 1 week/project

Per-project v3: + memory pilot

  • 1–3 catastrophic-trap ADRs
  • 3–10 Semgrep rules
  • 1–3 property-based tests (where domain fits)
  • Test docstrings carry architectural why
  • Wire criticality.yml
  • MemPalace pilot — one project only, opt-in writes, expiry/recency bias, per-project wing, Promotion Protocol exercised at least once
Phase 3 · deferred

Skip for now

  • Mutation testing — defer until test suite mature
  • Knowledge graphs — solo-dev overkill
  • Enterprise ADR governance — no team
  • Memory expansion beyond pilot — needs evidence pilot works

v2 was 2 weeks to working state. v3 keeps the same timeline; MemPalace fits inside Phase 2 at no infra cost.

What we're not doing — and why

✕

Knowledge graphs (Graphify, Codebase-Memory)

Designed for 450K+ file monorepos. Overkill for single-developer apps.

✕

MCP-based ADR servers

Valuable when multiple agents/humans query shared ADRs. Solo-dev can grep the folder directly via the criticality manifest.

✕

Enterprise ADR governance

No review boards. No approval workflow. ADRs are five-minute files. Keep ceremony low or no one uses them.

↑

Semgrep: moved IN v2 change

Originally dismissed as "too narrow." Review board independently recommended bringing it back. Cheapest enforcement layer for structural invariants.

≈

Superpowers plugin: partial adoption v3 change

Not the full 14 skills (too much ceremony). Phase 1 adopts a narrow subset: repo/context scan, change-impact analysis, test selection, spec-to-checklist, regression diff audit. Avoid anything that adds autonomous behavior or new memory surfaces.

Agent memory systems v3: Phase 2 pilot

v2 said “defer to Phase 3+.” Both reviewers pushed back — MemPalace is OSS/MIT/local/zero-cost/MCP-native, so the integration tax is trivial. v3 pulls it into Phase 2 as a narrow pilot with explicit write-back rules.

Our strategy

Project knowledge — rules, decisions, invariants. Repo-bound. Travels with the code.

Agent memory

Episodic memory — user prefs, prior-session context, cross-repo patterns. Vector store. Travels with the user.

The policy — one line

Memory can remind; artifacts decide.

If a memory changes future behavior across sessions, it must be written back to an artifact (spec, ADR, guardrail, context note). Memory is “remember to look here,” never “this is now policy.”

April 2026 open-source landscape

ProjectReleasedNotable
MemPalace Apr 6, 2026 new MIT. 96.6% on LongMemEval (100% hybrid — best free option). Verbatim storage + vector search, local-first, zero API cost. MCP-compatible with Claude Code.
Hermes Agent v0.7.0 Apr 3, 2026 new OSS agent stack. Pluggable memory providers. 32k+ stars.
Mem0 Established Universal memory layer. AI-driven extraction (summaries), not verbatim.
Letta (ex-MemGPT) Established OS-inspired virtual context. Moves info between immediate & long-term stores.
Zep, Cognee, LangMem Established Frameworks with varying retrieval strategies (graph, temporal, hierarchical).
Cloudflare Agent Memory Apr 13–17, 2026 Managed service (not OSS). Profile-based API. Public beta Apr 30.

Covered on The AI Daily Brief: Harness Engineering 101 (memory as harness layer) · Operator's Bonus Apr 18 (“memory gap holding the whole field back”).

Memory handoff rule v3 new

The mechanism that keeps shadow context from accumulating. Gemini: Promotion Protocol. Codex: write-back rule. Same thing.

Memory may store

  • User preferences (indent, naming, tone)
  • WIP context across sessions
  • Pointers to artifacts
  • Tentative hypotheses
  • Workflow habits / dead-ends

Memory must not own

  • Decisions (→ ADR)
  • Invariants (→ invariants.md)
  • Interfaces / contracts
  • Operational runbooks
  • Risk boundaries

Promotion Protocol + stale-memory reconciliation

At milestone end, explicitly tell Claude:

“Promote structural learnings into ADRs/invariants. Forget the episodic memory.”
  • Claude flags memories it overrode this session (test/ADR won)
  • context-save at Stop/SessionEnd prompts: forget / update / keep
  • Never auto-delete — always ask

Without this, memory becomes shadow context — durable decisions or stale assumptions living outside reviewable artifacts. Worse than no memory at all.

How novel is this? (post review)

Revised deck is even more mainstream than v1. The review board's pushback converged us toward established patterns (Semgrep, authority order, selective property testing, path manifests).

ComponentIndustry statusNote
CLAUDE.md + scoped rules + skillsconsensus baselineStandard Claude Code pattern.
Slim docs/context/ (4 files)consensusGemini + Codex both pushed for collapse. 8 files was sprawl.
Rare structured ADRsde facto standardICSE 2026 confirms. Frontmatter + scarcity is the pragmatic form.
Authority orderstandard (under-taught)Codex's contribution. Well-known in ML systems engineering.
Semgrep / cheap static checksmainstreamUsed across many solo and team projects. We were wrong to exclude.
Selective property testsemerging mainstreamAnthropic-endorsed. Both reviewers said: selective, not blanket.
criticality.yml manifestsynthesisDistinctive of this plan. Codex's framing, solo-dev tuning.
Low-ceremony solo framingour synthesisIndustry targets teams. We deliberately stay small.

Net: mainstream toolkit, selectively assembled. The novelty is in the scarcity discipline, not the primitives.

Recommendation · v3

Fewer documents. Stronger authority. Selective tests.
Memory can remind; artifacts decide.

Phase 0 + Phase 1 ship in <1 week. Phase 2 adds per-project ADRs, Semgrep rules, property tests, and a narrow MemPalace pilot (opt-in writes, per-project wing, Promotion Protocol exercised). Phase 3 — mutation testing, knowledge graphs, enterprise governance — deferred indefinitely. Honest on what's closed: reductions, not closures. Shadow context is the new meta-risk; the write-back rule is the countermeasure.

Scarcity over completeness
Enforcement over documentation
Manifest over prose
Authority explicit — linear + parallel
Write-back mandatory

End-to-end flow — working with Claude in the new framework

One edit cycle, start to finish. ■ you · ■ framework (automated) · ■ Claude

1

You ask for a change

"Add retry to scraper fetch."

↓
mem

Claude queries MemPalace MCP (parallel axis)

recalls: user prefs, prior-session context, cross-repo patterns — lead generator only, never overrides an artifact

↓
2

PreToolUse hook fires on Edit

reads: criticality.yml (path → required context)

↓
3

Hook auto-injects relevant context

injects: matching invariants, ADRs, must-run test names

↓
4

Change-impact prompt (if flagged)

asks Claude: what invariant could this break? adjacent modules? doc/test consulted?

↓
5

Claude writes the change

applies authority order: tests > spec > ADRs > comments > context

6

Executable guardrails run

Semgrep · unit · golden · Hypothesis (where applicable)

↓
?

Pass?

fail → Claude reads failing test docstring (carries the why) → fixes → back to step 6

↓ (pass)
7

Claude commits + responds

Commit message references touched ADRs / invariants where relevant.

↓
8

Stop / SessionEnd → context-save + Promotion Protocol

decides: update invariants.md? new ADR? update last_verified? reconcile stale memories? write non-durable prefs to memory with expiry?

↓
mem

Memory write-back (parallel axis)

writes: durable → ADR/invariant/context; ephemeral → MemPalace w/ expiry; stale-detected → forget or flag

↓
9

You review the diff

Normal code review. Invariants already enforced by tests — you're checking intent, not policing rules.

Key property: steps 2–4 and 6 are framework-enforced, not Claude-remembered. The ritual disappears; the enforcement doesn't.

Memory axis (dashed circles): recall after you ask, write-back at session end. Never authoritative. Memory can remind; artifacts decide.

Where it all lives — context locations by flow step

Every asset referenced in the prior flow, mapped to its filesystem home and the step(s) it serves. NEW = added in v2. REVIVED = originally excluded, brought back after review.

Project repository

CLAUDE.md                       directives, authority order    step 5
criticality.yml                 path → context manifest       steps 2–4 NEW
.semgrep.yml                    structural guardrails            step 6 REVIVED
src/**/*.py                    code + # See ADR-NNNN comments   steps 1,5,9
tests/
  test_*.py                    unit + integration (default)    step 6
  test_invariants.py           Hypothesis (selective)           step 6 NEW
  test_golden_*.py             golden / approval                step 6 NEW
  — docstrings carry the WHY —  failing tests print constraint   steps 6→7 NEW
docs/
  context/                      slim snapshot (4 files, not 8)
    architecture.md            system overview                  step 3
    invariants.md              cross-cutting rules (absorbs gotchas) step 3 NEW
    interfaces.md              contracts & schemas              step 3
    operations.md              deploy/run/config                step 3
  decisions/                    rare ADRs with frontmatter
    ADR-0001-*.md              catastrophic-trap decision       steps 3,7 NEW
    ADR-0007-*.md              ”                                  steps 3,7 NEW

Claude Code runtime

~/.claude/skills/
  context-save/
    SKILL.md                step 8
    decides what to record
    on Stop / SessionEnd

.claude/settings.json        steps 2,8
  PreToolUse + Stop hooks

.claude/hooks/
  pre_tool_use.py          steps 2–4 NEW
  reads criticality.yml
  injects relevant context
  fires change-impact prompt

External

git commit log            step 7
  diff & trace of change
  ADR / invariant refs in commit message

~/.mempalace/             turn start, step 8 v3
  ChromaDB + SQLite + filesystem
  queried at turn start (recall aid)
  written at step 8 via Promotion Protocol
  per-project wing, expiry bias

Assets outside the project (~/.claude/skills/, .claude/hooks/) are cross-project — write once, every repo benefits. Assets inside the project (criticality.yml, docs/, tests/) are per-repo and evolve with the code.

criticality.yml — what it contains

Lives at the project root. Read by the PreToolUse hook on every Edit/Write. One entry per sensitive path or pattern.

Schema — each field explained

FieldMeaning
path File pattern (glob). Matches files whose path fits; this entry activates when Claude edits one. ** = any depth.
invariants Anchors into invariants.md. Rules that must always hold for this code (e.g. "orders ≤ 5% of account").
adrs ADR IDs. Hook loads the full decision record so Claude sees the why and the alternatives that were rejected.
must_run Test files that must run (and pass) when this code is touched. Failing tests loop back to Claude with the docstring as explanation.
change_impact_prompt If true, hook forces Claude to answer "what invariant could this break? which modules participate?" before writing code.
owner Person or team responsible for this surface. Vestigial for solo devs; useful when project has mixed contributors or AI agents.

Order matters: first matching path wins. Put specific paths before wildcard ones.

Example — stocktrader


- path: "src/services/ib_client.py"
  invariants: [docs/context/invariants.md#data-routing]
  adrs: [ADR-0007]
  must_run: [tests/test_price_routing.py]
  change_impact_prompt: false

- path: "src/trading/**"
  invariants:
    - docs/context/invariants.md#trading-rules
    - docs/context/invariants.md#position-sizing
  adrs: [ADR-0002, ADR-0005]
  must_run:
    - tests/test_trading_invariants.py
    - tests/test_golden_quick_trade.py
  change_impact_prompt: true      # always ask; trading is high-risk
  owner: websurfinmurf

- path: "sql/migrations/*.sql"
  invariants: []
  adrs: []
  must_run: [tests/test_migration_idempotency.py]
  change_impact_prompt: true      # one-way change; flag every time

- path: "src/scraper/**"
  invariants: [docs/context/invariants.md#scraper-rate-limits]
  adrs: [ADR-0003]
  must_run: [tests/test_scraper_fallback.py]

Terms used on this slide

invariant
A rule that must always hold — not an occasional check, an unbreakable contract. Lives in invariants.md.
glob
Wildcard file pattern. * = any filename chars. ** = any directory depth. Used to match groups of files.
ADR
Architecture Decision Record. Short markdown file: context, decision, alternatives rejected, consequences.
must_run test
Test the framework requires to pass before accepting the edit. Failures loop back to Claude with the docstring's why.
owner
Reviewer / responsible party for this surface. Optional. Anchors accountability when more than one human or AI touches the code.

tests/* — QA coverage + architectural enforcement

Not a separate test framework — this is QA. The /qatests skill handles coverage; this strategy adds the intent layer via test docstrings. v3 narrowing The WHY-docstring rule is triggered, not blanket — routine unit tests keep their default docstring style.

Test types & their roles

TypeRoleTool
Unit / integrationStandard QA coverage — happy path, edges, errors, securitypytest via /qatests
Golden / approvalCatch "looks cleaner, behaves differently" after AI refactorpytest-approvaltests
Property-based selectiveFormal invariants over input spaceHypothesis
Contract / schemaAPI/event boundariesPydantic / JSON schema
E2ECross-component flowspytest + docker-compose

/qatests covers six QA categories (happy, edge, error, integration, regression, security). This strategy adds one thing: docstring carries the why — but only when the test fires on a narrow trigger.

WHY-docstring fires when: test is in a criticality.yml must_run list, OR filename matches test_invariants* / test_golden*, OR asserts catastrophic-trap regression. Routine unit tests: default style.

Example — invariant + property test


# tests/test_trading_invariants.py

from hypothesis import given, strategies as st
from src.trading import sizing

def test_quick_trade_rejects_oversized_position():
    """Quick Trade orders must not exceed 5% of account value.

    WHY: Risk management (see ADR-0005).
         Oversized positions are a catastrophic-trap scenario.
         Violating bypasses sizing.accept_order().
    """
    assert not sizing.accept_order(size=10_000, account=100_000)

@given(account=st.floats(min_value=1000, max_value=1e9),
       size=st.floats(min_value=0))
def test_position_sizing_property(account, size):
    """Property: accepted orders <= 5% of account value.

    WHY: ADR-0005 invariant must hold for arbitrary inputs.
         If this test fails, you've broken the sizing guard.
    """
    if sizing.accept_order(size, account):
        assert size <= 0.05 * account

docs/decisions/* — what goes here

Reserved for catastrophic-trap decisions — changes a future enhancement could silently undo, causing a one-way mistake. Target: 3–5 lifetime per project. Everything else goes in docstrings.

Qualifies ✓

  • External constraint with non-obvious alternative rejected (IB realtime / Yahoo historical)
  • Risk boundary with legal / financial / safety consequence (position sizing limit)
  • One-way architectural choice (schema migration strategy)
  • Workaround for external bug or quirk (Cloudflare Turnstile scraper flow)

Doesn't qualify ✕

  • Library choice with easy swap (pytest vs unittest)
  • Code style / naming convention (goes in CLAUDE.md)
  • One-off bug fix (git history is enough)
  • Refactor that changes structure but not behavior
  • Any "why" that fits in a single module docstring

Example — catastrophic-trap ADR (abridged)


---
id: ADR-0005
status: Accepted
scope: trading
last_verified: 2026-04-19
tags: [risk, position-sizing]
---

# Position size capped at 5% of account

## Decision
Order paths MUST pass `sizing.accept_order()`.
Rejects any size > 0.05 * account_value.

## Alternatives rejected
- Trust UI: single point of failure
- Backend soft warning: easy to click through
- Per-symbol caps: wrong risk model

## Consequences
- No direct order creation in handlers
- Property test enforces the bound
- Bypass requires ADR-0005 supersede

If you can't articulate "the alternative was considered and rejected because …", it's not an ADR — it's a docstring.

Decide. Then we build.

If approved, Phase 0 + Phase 1 ship in <1 week: slim docs/context, fix overclaims, update context-save skill with authority order (linear + parallel memory axis) + criticality.yml + change-impact prompt, narrow the /qatests WHY rule, adopt the Superpowers subset, scaffold an ADR template. Phase 2 runs per-project and includes the MemPalace pilot under the write-back rule.

📄 Full review synthesis (v2 + v3): context-strategy.final.md — two reviewer rounds, consensus, disagreements, action items, risks.

Sources & external references: adr.github.io · AgDR · Hypothesis · Anthropic PBT · Semgrep · ICSE 2026 ADR context · Context rot

Review board: Gemini 3.1 Pro + Codex (GPT-5.x). Two rounds — v2 (baseline strategy) and v3 (memory-layer delta). Full synthesis at docs/reviews/context-strategy.final.md.