Skip to content

Harden compiler validation and reconcile schemas with the compile contract#12

Merged
ksimback merged 1 commit into
mainfrom
fix/compiler-hardening
Jul 5, 2026
Merged

Harden compiler validation and reconcile schemas with the compile contract#12
ksimback merged 1 commit into
mainfrom
fix/compiler-hardening

Conversation

@ksimback

@ksimback ksimback commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Remediation batch 2 of 3 from the 2026-07-04 audit.

Compile-time invariants now actually enforced

  • Timeouts everywhere: programmatic checks (default 300s) and cmd context sources (default 60s) now compile with validated timeouts — previously only host/council members had them, leaving the most-executed calls uncapped.
  • Empty argv rejected (invoke: [] used to compile, then crash the runner).
  • context_sources entries need exactly one of file/cmd; entries that had neither were silently dropped from RUN_IN_SESSION.md.
  • Null-tolerant parsing: bare context_sources: / criteria: / members: keys no longer produce raw TypeError tracebacks.
  • Path containment at compile time: workspace.dir and context file paths must be relative, no .. (defense-in-depth with the runner-side check from Fix runner loop-control, consent, and redaction defects #11).
  • Budget sanity: usd/tokens/wall_clock_min must be positive numbers (wall_clock_min: -5 used to compile).
  • Council integrity: duplicate member ids rejected (used to silently collapse); verdict_source must be listed in its gate's members; cli required on host and members.

Registry safety + usability

  • register-model refuses secret-shaped tokens in --invoke/--notes (sk-/ghp_/xox/AKIA/key=value patterns) — ~/.looper/models.json must never store credentials.
  • --invoke "claude -p" (single quoted string, shell-split) now works; argparse previously made flag-bearing invocations impossible to register.

Cross-platform

  • JSON/YAML reads tolerate UTF-8 BOMs from Windows editors; all generated artifacts (resolved JSON, LOOP.md, RUN_IN_SESSION.md, registry) are written with LF newlines on every platform, ending CRLF git churn.

Schemas reconciled

The bundled JSON schemas drifted from what the compiler accepts (schema required workspace/verification/five gate fields; code defaulted them). Schemas now describe the real contract, including the new typed budget, context_sources one-of, and criterion timeout_sec. Example artifacts recompiled with the new defaults.

Tests

16/16 locally (4 new: invalid-spec rejection matrix via subtests, defaults/null-tolerance, BOM tolerance, registry secret guard + quoted invoke).

🤖 Generated with Claude Code

Validation now enforces the invariants the docs promise:
- Every external invocation gets a timeout: programmatic checks default
  to timeout_sec 300 and cmd context sources to 60, both validated as
  positive integers (previously only host/council had timeouts).
- Empty argv arrays are rejected at compile time instead of crashing a
  runner at execution time.
- context_sources entries must have exactly one of file or cmd; null
  context_sources / gate criteria / gate members no longer raise bare
  TypeError tracebacks.
- workspace.dir and context file paths must be relative and must not
  traverse out of the loop directory.
- Budget values (usd, tokens, wall_clock_min) must be positive numbers.
- Duplicate council member ids are rejected instead of silently
  collapsing; a gate's verdict_source judge must also be listed in that
  gate's members; host.cli and council cli are required.
- register-model refuses invoke/notes values that look like credentials
  (the registry must never store secrets) and accepts a single quoted
  string for flag-bearing invocations (--invoke "claude -p"), which
  argparse could not express before.
- JSON/YAML reads tolerate a UTF-8 BOM; all generated artifacts are
  written with LF newlines on every platform.

Schemas reconciled with the real compile contract (workspace and
verification optional, gate requires only verdict_policy, typed budget
and context_sources, timeout_sec on programmatic criteria) so
schema-aware editors agree with the compiler. Example artifacts
recompiled with the new defaults.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ksimback ksimback merged commit 940a9ff into main Jul 5, 2026
9 checks passed
@ksimback ksimback deleted the fix/compiler-hardening branch July 5, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant