Topic: Do implementations match their plans? Where do they diverge and why?

Date: 2026-06-05

Time: 13:34

Do Implementations Match Their Plans?

The short answer: yes, closely — but with deliberate simplifications that favor testability over production realism. The plans in this repo are unusually prescriptive (they specify data models, method signatures, and even assertion examples), which leaves little room for divergence. Where divergence exists, it falls into three categories: structural compression, pragmatic shortcuts in time-handling, and silent omissions of features the plan specified but the implementation quietly dropped.

High Fidelity: Rate Limiter

The rate limiter plan (rate-limiter/plan.md) specifies four algorithms, a middleware, a factory, and metrics tracking. The implementation (rate-limiter/rate_limiter.py, 259 lines) delivers all of these within the plan's 200–400 line target.

What matches exactly:

Where it diverges:

The plan's record method (line 28–31) tracks totalallowed and total_denied as defaultdict(int) on the base class. This is a minor structural divergence — the plan lists metrics as a separate requirement (requirement 10), but the implementation folds it into the base class constructor rather than a separate metrics object. This is a simplification, not a gap.

High Fidelity with Known Gaps: Payment System

The payment system plan (payment-system/plan.md) and implementation (payment-system/paymentsystem.py, 238 lines) are well-aligned, but the plan review (payment-system/planreview.md) documents five known divergences between the design and what a production system would need:

What matches exactly:

Deliberate divergences documented in plan_review.md:

1. time.sleep in retry logic (line 154 area in callprocessorwithretry): blocks the calling thread. The plan says "exponential backoff" — the implementation does this literally with time.sleep(self.basedelay * (2 ** attempt)), which is correct for a single-process simulation but wouldn't work in production.

2. TOCTOU on balance checks: balance is checked before the processor call (line ~100), but ledger entries are created after (lines ~129–138). No locking, which the plan doesn't require but a real system would need.

3. Failed idempotency keys are permanent: once a payment fails and gets mapped to an idempotency key, retrying with the same key returns the FAILED payment. The plan doesn't address this edge case.

Structural Divergence: Chat System

The chat system shows the most interesting divergence pattern. The plan (chat-system/plan.md, 318 lines) is the most ambitious — it specifies 12 distinct feature areas. The implementation (chat-system/chat_system.py, 434 lines) delivers on all of them but makes structural choices the plan didn't prescribe:

What matches:

Where it diverges structurally:

Cross-Cutting Pattern

Across all three implementations, the same divergence pattern repeats:

1. Plans are prescriptive enough that the core algorithm matches exactly. When the plan says "weighted count = prevcount * weight + currentcount," that's exactly what appears in SlidingWindowCounterLimiter.weightedcount (lines 173–179).

2. Production concerns are acknowledged but deliberately skipped. Thread safety, async I/O, persistent storage — all absent by design. The plans state "single-process" and "in-memory," and the implementations honor that constraint.

3. Memory management is implemented but minimal. The rate limiter prunes deques and clears old window keys. The payment system doesn't prune its ledger list. The chat system observations don't show pruning.

4. No divergence markers in the code. The grep for TODO/FIXME/HACK across these three systems found zero hits — all 16 matches came from web-crawler and other systems. The implementer either hit the plan exactly or didn't annotate deviations.

What's Missing From These Observations