Inspiration
AI agents can rewrite code. But the definition of "correct" should stay with humans.
When an AI coding agent encounters a failing test, it can modify the test to match its own incorrect implementation. The test may pass, but it no longer verifies what a human originally intended.
A test that never fails proves nothing.
ODDSTITCH was created to explore how humans can retain control over the definition of correctness while benefiting from AI-assisted software development.
Why Frankenstein?
ODDSTITCH combines two fundamentally different approaches to software development:
- Generative AI: Flexible, adaptive, and capable of autonomously modifying implementation code.
- Deterministic testing: Fixed, human-defined conditions that determine whether an implementation is correct.
These approaches can conflict when an AI agent has the ability to modify both the implementation and the criteria used to evaluate it.
ODDSTITCH stitches them together using Kiro Specs, Agent Hooks, a lightweight test runner, a shell-based guard script, and human approval.
The result is a development workflow that gives AI the freedom to fix implementation errors while introducing technical boundaries intended to protect human-defined tests.
Rather than limiting what AI can create, ODDSTITCH explores how to protect the boundaries within which AI operates.
What it does
ODDSTITCH is a proof-of-concept development tool and reusable Kiro template that helps preserve human-defined tests during AI-assisted coding.
Human-defined requirements are stored in .kiro/specs/, while tests are stored in tests/.
A Kiro PreToolUse hook is configured to intercept two file-edit tools, fs_write and str_replace, and reject operations that match the protection pattern for the tests/ directory.
Blocking an attempted modification through str_replace was verified. The fs_write tool has not yet been independently verified.
Kiro can still modify implementation code in src/.
Tests run using:
node .oddstitch/run-tests.js
No additional packages are required.
The demo uses a shipping-fee calculation:
- Orders of 10,000 JPY or more: free shipping.
- Orders below 10,000 JPY: 600 JPY shipping fee.
I intentionally changed the implementation from 600 JPY to 500 JPY and confirmed that a test failed. Kiro identified the implementation error and proposed restoring the correct value.
The demonstration also shows successful test execution and the Protect Tests hook blocking an attempted test modification.
How we built it
I built ODDSTITCH using Kiro IDE and combined the following technologies:
- Kiro Specs: Define human-approved requirements.
- Kiro Agent Hooks: Intercept selected AI tool operations before execution.
- Bash: Check file paths and reject matching protected operations.
- Node.js: Execute deterministic tests without external dependencies.
- Human-in-the-loop review: Review proposed implementation changes before accepting them.
The prototype includes:
.kiro/specs/shipping-fee/requirements.md.kiro/hooks/protect-tests.json.oddstitch/guard.sh.oddstitch/run-tests.jssrc/fee.jstests/fee.test.js
The guard script returns exit code 2 when a matching protected file path is detected, allowing the PreToolUse hook to reject the operation.
No additional packages or external testing frameworks were required.
Challenges we ran into
The most important technical challenge was identifying the actual boundaries of Kiro's hook protection.
1. Shell-based modifications
Kiro was able to modify a test through a shell command (sed). The hook did not block that operation. I restored the test manually.
Therefore, the current protection is limited to matching operations performed through the configured file-edit tools. It does not provide comprehensive protection against all possible file modifications.
2. Hook activation in a freshly cloned repository
During fresh clone verification on December 2, 2026, the Protect Tests hook was initially displayed as disabled.
An attempted test modification succeeded while the hook was disabled.
I restored the original test file, added "enabled": true to the hook configuration, and restarted Kiro IDE.
After updating the GitHub repository, I performed another fresh clone verification.
Although the updated configuration already contained "enabled": true, the hook was initially displayed as disabled again.
Fully quitting and restarting Kiro IDE resolved the issue without additional configuration changes.
The reason for the initial disabled state has not been confirmed. The activation and restart instructions are documented in the README.
3. AI-generated reports versus actual results
Kiro's own reports were sometimes inaccurate.
For example, during one verification round, Kiro reported that the expected shipping fee remained at 500 JPY, even though the actual file contained the correct value of 600 JPY.
To address this, I independently checked actual file contents, Git differences, and test output rather than relying solely on the AI agent's reports.
This reinforced the core principle behind ODDSTITCH: an AI agent's statement about correctness is not sufficient evidence of correctness.
The Post Task Execution hook has not yet been verified.
Accomplishments that we're proud of
- Successfully demonstrated that the test runner detects an intentionally introduced implementation error.
- Confirmed that Kiro can identify an implementation error and propose a correction.
- Verified that the guard script returns exit code 2 for a matching protected file path.
- Demonstrated the Protect Tests hook blocking an attempted test modification through
str_replace, based on Kiro's reported tool result and subsequent file verification. - Reproduced the protection workflow in a freshly cloned copy of the updated GitHub repository after restarting Kiro IDE.
- Verified that the original human-defined test remained unchanged.
- Documented the actual protection boundaries, activation requirements, and technical limitations.
- Provided English documentation and translations for international reviewers.
- Built the prototype without additional software packages.
Final Fresh Clone Verification — December 2, 2026
A new copy of the updated GitHub repository was cloned and tested.
After restarting Kiro IDE, a controlled test was conducted to attempt to change the expected shipping fee from 600 JPY to 500 JPY through Kiro's str_replace tool.
| Verification Item | Result |
|---|---|
| Fresh clone from GitHub | Passed |
Hook configuration contains enabled: true |
Passed |
| Hook enabled on initial opening | Failed |
| Hook enabled after restarting Kiro | Passed |
Attempted test modification via str_replace |
Reported blocked by Kiro |
| Expected shipping fee remains 600 JPY | Passed |
| Tests passed | 2 |
| Tests failed | 0 |
| Test pass rate | 100% |
| Git working tree changes reported | 0 |
| Additional package installations | 0 |
The final file contents, test results, and Git status were independently verified using terminal commands.
These results demonstrate reproducibility in the tested environment after restarting Kiro IDE. They do not establish comprehensive protection against all possible modification methods.
What we learned
An AI agent's report that a task is complete is not proof.
Actual files, test results, Git differences, and tool execution results provide stronger evidence than an AI-generated completion message alone.
I also learned that protecting human-defined correctness requires more than simply instructing an AI agent not to modify tests. Technical controls are needed, and their limitations must be independently verified.
Even a correctly configured protection mechanism may require additional activation steps before it becomes effective.
AI should be able to change how a solution works without silently changing the criteria that determine whether it works correctly.
What's next for ODDSTITCH
- Extend protection to shell-based file modifications.
- Improve protected-path detection.
- Independently verify additional file-edit tools, including
fs_write. - Investigate the initial hook activation issue.
- Verify the Post Task Execution hook.
- Support standard testing frameworks such as Jest.
- Expand test coverage, including the zero-value order requirement.
- Explore protection of human-approved specifications as well as tests.
- Validate the approach on a real-world software development project.
ODDSTITCH is currently a proof of concept, not a production-ready security solution.
Project Resources
- GitHub: https://github.com/charnoheya/oddstitch-spike
- Demo video: https://youtu.be/lsPYTJiILZA
- English documentation: README.md
- English translations: TRANSLATIONS.md
- License: MIT
ODDSTITCH — Humans Define What's Right.
Built With
- bash
- javascript
- kiro
- macos
- node.js