DEV Community

Dariusz Newecki
Dariusz Newecki

Posted on

How one missing line broke months of autonomous self-improvement — and what fixing it revealed about constitutional software governance

CORE is a system I've been building for over a year. Its purpose is to govern and autonomously improve software codebases using constitutional rules—not loose AI reasoning, but deterministic policies enforced by auditors and workers in a layered architecture (Mind/Body/Will).

The self-improvement loop is straightforward:

AuditViolationSensor detects violation
   posts finding to blackboard
     ViolationRemediatorWorker creates proposal
       ProposalConsumerWorker executes fix
         AuditViolationSensor confirms resolved
Enter fullscreen mode Exit fullscreen mode

For months, every proposal failed silently with the message: Actions failed: fix.logging. The autonomous pipeline—the core feature—was completely broken, and the failure left almost no useful trace.

The Investigation

The first red flag was that execution_results on every failed proposal was an empty dict {}. This meant the failure occurred before ActionExecutor even ran. Proposals were created correctly, approved correctly, and then died in the execution path.

Working backwards:

  1. ProposalConsumerWorker picked up approved proposals.
  2. It called ProposalExecutor.execute().
  3. ActionExecutor.execute("fix.logging") crashed with: AttributeError: 'NoneType' object has no attribute 'write_runtime_text'

write_runtime_text belongs to FileHandler, which meant file_handler was None.

I checked the daemon startup code in src/will/commands/daemon.py. It wired up git_service, knowledge_service, cognitive_service, and qdrant_service—but file_handler was never set. CoreContext defaults it to None.

The CLI path worked fine because the @core_command decorator wires the full CoreContext (including FileHandler). The daemon startup simply forgot it.

Root cause: one missing line. Months of silent failure.

The Fix That Got Rejected

The obvious patch looked like this:

# In src/will/commands/daemon.py
from shared.infrastructure.storage.file_handler import FileHandler
ctx.file_handler = FileHandler(str(BootstrapRegistry.get_repo_path()))
Enter fullscreen mode Exit fullscreen mode

CORE's own audit immediately rejected it:

ERROR | architecture.boundary.file_handler_access
src/will/commands/daemon.py:199 — Forbidden import:
'from shared.infrastructure.storage.file_handler import FileHandler'
Enter fullscreen mode Exit fullscreen mode

daemon.py lives in the Will layer. FileHandler lives in shared.infrastructure.storageBody layer territory. The Will layer is not allowed to import Body infrastructure directly.

The system enforced its own architectural boundaries against its author.

The Correct Fix

Add get_file_handler() to ServiceRegistry (in the Body layer, where it belongs), then call it from the daemon:

# Proper approach
ctx.file_handler = service_registry.get_file_handler()
Enter fullscreen mode Exit fullscreen mode

The import now lives where the constitution says it should.

What Happened Next

Once the pipeline started running, two more bugs surfaced:

  1. Double write argumentProposalExecutor passed write=True explicitly and unpacked {"write": True} from proposal parameters → TypeError: got multiple values for keyword argument 'write'.

    Fixed by stripping write from parameters before unpacking.

  2. Layer detection in LoggingFixer — The autonomous fixer converted console.print() to logger.info() in CLI-layer files because its path detection only checked for body/cli, missing src/cli/. It was breaking its own rendering.

    Fixed by updating the path detection logic.

First Autonomous Completion

After the fixes:

status: completed
fixes_applied: 28
files_modified: 4
dry_run: False
Enter fullscreen mode Exit fullscreen mode

No human approval. No human review. The governance pipeline ran end-to-end for the first time.

What This Revealed About Constitutional Governance

Three lessons stood out:

  1. Silent failures are a design smell.

    The fix.logging action returned ActionResult(ok=True) unconditionally, regardless of outcome. The pipeline reported success even when it wasn't. Observability isn't optional—it's a constitutional requirement.

  2. Layer boundaries matter at runtime, not just during review.

    The daemon missed file_handler because the bootstrap path (used by CLI) was never wired into the daemon path. Two code paths, one constitutional contract, and one path that didn't honour it.

  3. The governance system catching your own mistake is the point.

    The audit rejection of the wrong-layer import wasn't an obstacle. It was the system working as designed. The constitution exists precisely for moments when you're moving fast and tempted to "just make it work." The system slowed that impulse and enforced the right fix.

Where CORE Stands Now

We're not at full A3 autonomy yet. There's still an honest checklist of 8 remaining gaps—including rollback safety on partial execution failures, DB-level concurrency constraints, and the Logic Conservation Gate from an earlier test.

But Tier 1 autonomous actions now work. The loop has closed.

The system that was broken used its own constitutional rules to enforce the fix that unblocked it.


GitHub: https://github.com/DariuszNewecki/CORE

Previous posts in the series:


This version should slot right into your series. It's around 4–5 min read, maintains your voice, and emphasizes the self-referential governance aspect that readers seem to engage with. The code blocks are focused and helpful without overwhelming the narrative.

If you want any tweaks (e.g., more/less detail on a specific bug, different emphasis on a lesson, or adjusting the previous posts links), just say the word.

Top comments (0)