Skip to content

fix: hardening batch from adversarial code review (v3.7.6) - #124

Merged
CryptoJones merged 1 commit into
mainfrom
fix/review-hardening-batch
Jul 1, 2026
Merged

fix: hardening batch from adversarial code review (v3.7.6)#124
CryptoJones merged 1 commit into
mainfrom
fix/review-hardening-batch

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

Summary

A hardening batch addressing findings from a full adversarial code review of the vault store, mesh replication, guard/enforcement layer, provisioning, and CLI/cron paths. All fixes — no API breaks. NoteFields gains backward-compatible frontmatter/lead fields. Version bumped 3.7.5 → 3.7.6 (patch, per SemVer discipline) with a CHANGELOG entry.

Highlights

  • Data integrity: parse/render (and the mesh merge) preserve YAML frontmatter + lead prose and are code-fence-aware; equal-rev merge conflicts converge symmetrically; case-insensitive reserved-name check; dot-prefixed/over-long titles raise clean errors; create_note concurrent-create race closed; atomic writes fsync the directory.
  • One bad byte no longer downs the vault: all note/index/log reads decode with errors="replace" (+ BOM strip); search/backlinks skip a note deleted mid-scan.
  • Guard false-positives: freshness accepts git -C <repo> fetch and compound read forms; forge/destructive rules are command-anchored; a bare > (pytest 2>&1) is no longer a "side effect"; global-config paths resolve against $HOME so a project-local .claude/ isn't gated; negation-aware auth detection.
  • Guard crash-hardening: a learned rule that fails to compile or matches the empty string is rejected at load and skipped at match, so one bad rule can't brick every tool call; command-position anchor covers shell wrappers + sudoedit.
  • Enforcement fail-open holes: adapter fails closed on unparseable events and reads array args; contentless list-notes/graph-* no longer clears the gate; secret-output guard no longer leaks pass show X 2>/dev/null | head nor false-blocks pass inside a word; turn-reset clears pending/freshness.
  • Availability: atomic config/hook/backup writes; checkpoint never raises into the timer + absolute ExecStart; mesh gitignores .obsidian/workspace.json, doctor surfaces per-peer sync errors, a push timeout no longer aborts the whole pass; OMIND_NO_UPDATE_CHECK no longer breaks explicit self-update; lint --strict passes on a healthy vault; the migrate hook migrates before deleting (no fuzzy/slug-less data loss).

Test plan

  • pytest714 passed, 1 skipped (the skip is the platform-gated bash+jq secret-guard suite).
  • ruff check . — clean.
  • mypy src — clean.
  • Version lockstep verified: pyproject.toml = __init__.py = uv.lock = 3.7.6; uv lock --check resolves.
  • ~350 lines of new regression tests across 12 test files covering each fix class (frontmatter/fence round-trip, merge convergence, guard anchoring/freshness/crash-hardening, adapter fail-closed, secret-guard leak, lint false-positives, compliance torn-line, etc.).

🤖 Generated with Claude Code

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

Address findings from a full adversarial review of the vault store, mesh,
guard/enforcement layer, provisioning, and CLI/cron paths. All fixes; no API
breaks. NoteFields gains backward-compatible frontmatter/lead fields.

Data integrity:
- Preserve YAML frontmatter + lead prose through parse/render and the mesh
  merge; fence-aware section splitting; symmetric equal-rev merge convergence.
- errors="replace" (+ BOM strip) on every note/index/log read so one bad byte
  can't down listing/search/writes; search/backlinks skip a mid-scan delete.
- Case-insensitive reserved-name check; reject dot-prefixed/over-long titles;
  close the create_note concurrent-create race; atomic dir-fsynced writes.

Guard false-positives + crash-hardening:
- Freshness accepts `git -C <repo> fetch` and `git fetch && git status`.
- Command-anchor the forge/destructive seed rules; a bare `>` (pytest 2>&1)
  is no longer a side effect; resolve global-config paths against $HOME so a
  project-local .claude/ isn't gated; negation-aware auth detection.
- Reject uncompilable/empty-match learned rules at load and skip them at
  match time so one bad rule can't brick every tool call; wrapper/sudoedit
  command-position coverage.

Enforcement fail-open holes:
- Adapter fails CLOSED on unparseable events and reads array-shaped args;
  contentless list-notes/graph-* no longer clears the gate; secret-output
  guard no longer leaks `pass show X 2>/dev/null | head` nor false-blocks
  `pass` inside a word; turn-reset clears pending/freshness (per-turn again).

Availability:
- Atomic config/hook/backup writes (a torn write can't brick a harness or the
  guard hook). Checkpoint never raises into the timer + absolute ExecStart.
- Mesh: gitignore .obsidian/workspace.json, doctor surfaces per-peer sync
  errors, push timeout no longer aborts the pass, BatchMode git.
- Self-update: OMIND_NO_UPDATE_CHECK no longer disables an explicit update;
  install/check timeouts. lint --strict passes on a healthy vault. Migrate
  hook migrates before deleting (no fuzzy/slug-less data loss).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/omind/adapters.py
try:
if src.isatty(): # a by-hand invocation with no piped event: nothing to guard
return 0
except (AttributeError, ValueError, OSError):
@CryptoJones
CryptoJones merged commit 49549f0 into main Jul 1, 2026
11 checks passed
@CryptoJones
CryptoJones deleted the fix/review-hardening-batch branch July 1, 2026 22:31
CryptoJones added a commit that referenced this pull request Jul 1, 2026
#133)

Mirror the GitHub Issues tab: seven Open items for the deferred review
findings (#125-#131) and the shipped v3.7.6 hardening batch under Done
(#132 / PR #124).

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants