Skip to content

fix: harden replay safety, guard resume, jail validation, torn-line recovery - #68

Merged
ajianaz merged 5 commits into
developfrom
fix/pretag-scan-hardening
Sep 12, 2026
Merged

ajianaz merged 5 commits into
developfrom
fix/pretag-scan-hardening

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Four hardening fixes from the pre-tag full-scan triage (1 CRITICAL + 3 MAJOR, all verified real):

  • ReplaySafety derives from tool risk (ReadOnly → Idempotent, else Guarded) instead of a blanket Idempotent for every intent.
  • Guarded resume consults the wired approver: Allow replays the effect; deny or no approver settles the intent as failed (no more permanent pending livelock).
  • All file-tool jails (WriteFileTool, core read_file/edit_file/delete_file) validate by path components: every component must be Normal; Prefix/RootDir/ParentDir rejected.
  • JSONL open(): good_bytes counts a physical line only after it parses, so a newline-terminated corrupt final line is actually truncated instead of surviving and bricking the session on the next append.

Why (the problem you're solving)

Full cora scan before tagging v0.3.0 surfaced findings the incremental PR reviews never caught: a crash mid-sandwich could double-fire a human-approved Write/Destructive tool with no fresh consent (the exact hazard Guarded exists for); the Guarded resume path acknowledged the hazard in comments but never consulted the approver, livelocking the session; Windows-relative paths escape the jail despite the unix-only thinking; a single torn+invalid final line permanently bricks the session file, violating the stated invariant.

Testing (how you verified this works)

  • New/updated tests: guarded_intent_replay_requires_fresh_approval (deny → intent SETTLED, pending cleared, bomb never fired), guarded_intent_replays_when_approver_allows (allow → effect fires EXACTLY once across crash+resume), plus the full existing crash-resume golden/SIGKILL suites stay green.
  • Full workspace tests green, fmt + clippy -D warnings clean, CodeCora diff review clean.

ajianaz and others added 5 commits August 28, 2026 09:48
chore(release): v0.2.0 — chat-first harness, mobile-ready core
Version bump 0.2.0 -> 0.3.0 (minor: real features per house versioning),
CHANGELOG entries for #57-#66, publish workflow extended to ship
tole-cli (version-pinned core dependency, published after core),
cli manifest pins tole-core 0.3.0.
The main ruleset REQUIRES 'Cargo Audit' and 'Trivy FS Scan', but
security.yml only produced them for PRs targeting develop - release PRs
to main were permanently blocked (the documented impossible-required-
check trap: admin cannot bypass required checks). Align the trigger set
with ci.yml (develop, main).
chore(release): v0.3.0 — reliability & long-running work
…ecovery

CodeCora full-scan findings triaged pre-tag (1 CRITICAL + 3 MAJOR real):
- turn: derive ReplaySafety from tool risk (CRITICAL #33) - a crash after
  a Write/Destructive effect ran must not blindly re-execute on resume;
  Guarded now forces re-consultation of the approver.
- turn: Guarded resume actually consults the approver and settles the
  intent either way (MAJOR #34) - Allow replays once; deny/absent settles
  the sandwich as failed instead of livelocking every future resume.
- jails: component-based path validation everywhere (MAJOR #6, INFO #12)
  - Windows drive-prefixed/rooted relatives escape via join despite not
  being is_absolute(); substring '..' both misses them and rejects benign
  names. Uniform across WriteFileTool, core file_tools, read_file.
- storage: torn-line accounting (MAJOR #47) - good_bytes counted before
  parse made a newline-terminated invalid final line look consumed; the
  truncation never fired and the next append bricked the session. Now
  counted only after a successful parse; empty lines still counted.
Tests: guarded deny (settles, no livelock), guarded allow (fires exactly
once), full workspace green; fmt/clippy clean; CodeCora diff review clean.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 59ba224 into develop Sep 12, 2026
13 checks passed
@ajianaz
ajianaz deleted the fix/pretag-scan-hardening branch September 12, 2026 07:27
ajianaz added a commit that referenced this pull request Sep 12, 2026
… pipeline (#70)

Found while re-reading the #68 tests: AllowlistApprover::new's two
arguments read as 'allow these, deny the rest', but the pipeline is
pattern-match -> Allow with default applying to NON-matches, so
new(vec!["bomb"], Decision::Deny) actually ALLOWS bomb.

- Document the pipeline on new() with the concrete trap example
  (behavior unchanged: 0.2.0 is published on crates.io and interactive
  UX relies on it), now codified by a regression test.
- allow_only(patterns): allow exactly these, deny the rest.
- deny_only(patterns): deny exactly these, allow the rest (Destructive
  stays always-denied). Implemented with an explicit deny_mode flag so
  deny_only cannot be expressed as the misleading shape that started
  this.

Co-authored-by: ajianaz <[email protected]>
ajianaz added a commit that referenced this pull request Oct 1, 2026
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