The Ise Principle

Rebuild by routine,
not by necessity.

A practice for testing specs in agentic software engineering.

How old is the Grand Shrine of Ise in Japan: over 1,300 years, or under 20?

Naikū at Ise Jingū in 2013 showing the newly built wooden shrine on the left next to its weathered predecessor on the right.
Naikū Shrine at Ise Jingū - Photo: isejingu.or.jp/en.

Both. Since the 7th century, the shrine has been dismantled every 20 years and rebuilt from scratch on the adjacent plot (Shikinen Sengū). Once the sacred symbol is moved to the new building, the old one is taken down. Even the weathered building on the right is only 20 years old. What lasts are the plans and the skills to build from them.

Why every 20 years? A plan on paper stays untested unless someone builds from it. Rebuilding before the wood decays or the senior carpenters retire verifies the plan in practice and trains the next generation.

In software, the code often outlives the plan. Specifications fall behind when developers fix edge cases in code without writing down the rules. When the original developers leave, those rules can be hard to recover.

The Ise Principle reverses those roles: the specification is the source of truth, and the source code is replaceable. Rebuild regularly without the old implementation to find gaps in the spec.

1 · The spec must be enough to build from scratch

Start with a component: a part of the system you can replace without rewriting its callers. A pricing module is one example. Its contract tells callers what they can rely on, such as how prices are rounded. If you need the old code to recover a required rule, add that rule to the spec.

2 · Anything not in the spec is free to change

Undocumented behavior is not guaranteed. That leaves room for a better implementation, so anything the next build needs to preserve belongs in the spec. If required behavior is missing there, the spec is incomplete.

3 · Rebuild by routine

Set a regular schedule for rebuilding a component or the whole system. The goal is to find gaps before you need a replacement.

Rebuild the chosen part without access to its previous implementation. Keep the requirements, contracts, and behavior checks. Keep whatever the surrounding system needs to call and test the replacement.

Passing the checks is evidence that the spec was enough for the behavior they cover. If the previous implementation is still available, passing tests show that the replacement meets the behavior those tests check. They don’t establish that the spec was enough on its own.

What belongs to the spec
  • Behavior and invariants: Domain rules, valid states, and edge cases.
  • Contracts and schemas: Public APIs, events, wire formats, database schemas, and externally visible UI states.
  • Technical limits: Target stack, allowed dependencies, security and compliance rules, and latency and resource budgets under expected load.
  • Automated tests: Black-box tests that verify behavior from the outside.
What to keep for the rebuild
  • Old implementation and its internal tests: Leave out the old source and tests tied to its private structure.
  • Component behavior tests: Keep the scenarios and expected results. Rewrite test setup that depends on the old implementation.
  • End-to-end (E2E) tests (Kept unchanged): Test the system through its real interfaces (HTTP, CLI, UI, queues) and must pass against the rebuild without changes.

Fix the spec first

If a bug exposes a missing or unclear requirement, write down the intended behavior and add a test. If the spec already says what should happen, fix the code to match it.

Data, state, and contracts outlive the code

In Ise, the wood is replaced while the sacred symbol is carried over to the new shrine. In software, production data, schemas, and public contracts stay in place. Callers must not depend on undocumented internals. Changing the tech stack then becomes a rebuild under new technical limits instead of a full rewrite.

Check the spec by rebuilding

When you review a spec, it’s easy to fill in missing details from memory. A rebuild makes those gaps easier to spot. Passing tests still won’t tell you about cases the tests don’t cover.

AI lowers the cost of rebuilding

AI coding agents can lower the cost of a rebuild. The principle is the same whether a person or an agent writes the replacement.

Start with one component. Rebuild the whole system only when that’s what you want to test.

One component

Single-component rebuild

Keep the rest of the project in place. Replace only the chosen component’s implementation and preserve its contract.

Whole system

Whole-system rebuild

Replace the system’s implementation. Preserve the data and the contracts that callers depend on.

After the rebuild: Either discard the exercise code or adopt the replacement through your normal release process.

How to run the rebuild
  • Hold the spec fixed during each attempt: If you’re adding a feature, update the spec before rebuilding. If the rebuild reveals a missing or unclear rule, revise the spec before trying again.
  • Choose where to rebuild: Use a separate environment without the previous implementation to test the spec on its own. For a practical single-component replacement, stay in the existing project and remove only the chosen component’s old implementation. Don’t consult it in version history.
  • Keep behavior checks fixed: Run the tests without changing the cases or expected results. Replace only test setup tied to the old implementation.

1. Over-specifying internals

Problem: Describing loops, private classes, or internal algorithms makes the spec as rigid and bloated as source code.

Solution: Specify what callers can rely on: inputs, outputs, invariants, and performance limits. Leave internal structure up to the implementation.

2. Existing systems have no spec

Problem: In older systems, domain rules exist only inside tightly coupled code. You cannot delete the whole system and start over.

Solution: Choose one part of the system and define its contract. Test and document the behavior you want to keep. Build a replacement and compare its behavior with the old version before adopting it.

3. Tests get weakened or hard-coded

Problem: Developers or AI agents may weaken assertions or hard-code expected outputs just to make the test suite pass.

Solution: Keep implementation and test authorship separate, make test files read-only during the build, and check behavior against real traffic.

Patterns for applying the Ise Principle, followed by drafts in progress.

Core Patterns
Drafts · Work in Progress

Every rebuild, whether shipped or discarded after a dry run, moves undocumented assumptions out of old code and into a specification you can test at any time.