Skip to content

refactor: sweep technical debt#81

Merged
hakula139 merged 16 commits into
mainfrom
refactor/repo-sweep
May 12, 2026
Merged

refactor: sweep technical debt#81
hakula139 merged 16 commits into
mainfrom
refactor/repo-sweep

Conversation

@hakula139
Copy link
Copy Markdown
Owner

@hakula139 hakula139 commented May 12, 2026

Summary

Sweeps the repo after the broad review pass, removing stale compatibility debt and tightening several correctness boundaries in sessions, slash commands, config loading, file mutation, and tool output capture.

This PR also refreshes the Markdown docs against the current implementation and external reference notes so repository guidance matches the code that now ships.

Design decisions

  • Treat the session schema as early-stage owned data. The loader now rejects unknown entry variants instead of carrying compatibility shims for legacy JSONL shapes that are safe to discard.
  • Keep credential-bearing config user-scoped. Project config can no longer redirect API credentials through api_key or base_url, and invalid token-budget env input fails loudly instead of silently changing behavior.
  • Make the file tracker the content gate. Read, Edit, Write, and resume now share one content-hash validation path, including regular-file and size checks before reading or mutating tracked files.
  • Scope compact replay sidecars to accepted tail messages. Resume loading filters tool metadata and file snapshots with the same compact-tail boundary as messages, preventing stale sidecars from leaking across compaction.
  • Bound process output and pipe lifetime together. Bash tool execution drains stdout / stderr concurrently under the command deadline while retaining only capped buffers.
  • Keep command surfaces bounded. /resume now shares the CLI session-list cap, and /diff truncation hints match whether the repository has a HEAD commit.

Changes

File Description
session/entry.rs, session/store.rs, session/sanitize.rs, agent/compaction.rs, tui/components/chat.rs Remove schema compatibility shims, make compact replay sidecar filtering boundary-aware, and preserve real prompts when stripping synthetic compact prefixes from resumed chat history.
config.rs, config/file.rs, docs/guide/configuration.md Reject project-level credential redirects, validate Anthropic max-token env input, and document the user-config-only client settings.
file_tracker.rs, tool/read.rs, tool/edit.rs, tool/write.rs, session/handle.rs, docs/design/session/file-tracking.md Centralize tracked-file validation, verify current bytes before mutations and snapshot restore, drop oversized or non-regular tracked files before reading, and document the stronger invariant.
tool/bash.rs, docs/design/tools/truncation.md Enforce the command timeout across child wait and pipe collection while keeping stdout / stderr capture bounded.
slash/diff.rs, slash/resume.rs, slash/confirm.rs, tui/app.rs, slash/model.rs, slash/effort.rs Fix no-HEAD diff coverage, cap /resume list loading, gate config-changing pickers while busy, ignore modified confirm-delete keys, and roll back theme previews when forced modals close.
tui/components/chat/blocks/tool/glob.rs, tui/components/chat/blocks/error.rs Share truncation-footer parsing for glob titles and keep error-marker helpers test-only.
README.md, CLAUDE.md, docs/**/* Sync command docs, CI guidance, research notes, and design descriptions with current behavior and verified external reference state.

Test plan

  • cargo fmt --all --check
  • cargo build
  • cargo clippy --all-targets -- -D warnings: zero warnings
  • cargo test: 1954 tests pass
  • cargo llvm-cov --ignore-filename-regex 'main\.rs': 98.94% line coverage
  • pnpm lint
  • pnpm spellcheck

hakula139 added 8 commits May 12, 2026 11:24
This is an early single-user project, so the session schema should fail clearly on unknown entry shapes instead of carrying silent forward-compat branches. Dropping the Unknown variant and defaulted schema fields keeps persistence explicit and makes malformed JSONL easier to notice.

Also fixes adjacent documentation drift found during the sweep: /compact is counted in the slash-command design doc, /diff welcome copy matches its actual git diff HEAD + untracked behavior, and stale compatibility wording is removed from the design notes.
Project ox.toml is loaded from the checkout, so it must not be able to supply API credentials or redirect the Anthropic endpoint. Keep model, effort, and UI project overrides, but require api_key and base_url to come from user config or env.

Also make ANTHROPIC_MAX_TOKENS parse failures fatal and validate base_url schemes, allowing plain HTTP only for localhost proxies.
Compaction creates a fresh transcript chain, but replay previously filtered messages separately from their sidecar records. A stale old-chain append after a compact boundary could be skipped while its tool metadata or file snapshots still restored into the resumed session.

Gate sidecars on the compact-tail message acceptance state, and expose the compaction-owned synthetic-prefix stripper so the TUI can hide only the internal summary while preserving a real prompt merged by resume sanitization.
Bare /model and /effort open modals, but those modals submit SwapConfig actions that mutate the in-flight agent configuration. Treat both forms as mutating so they are refused while a turn is running.

Also require unmodified confirmation keys for session deletion and route forced modal-stack clears through the same theme-preview rollback helper used by modal cancellation.
Before the first commit, git diff HEAD is unavailable. The fallback only read the cached diff, which hid unstaged edits to already-staged files. Combine cached and unstaged diff sections in that state.

Also reuse glob output parsing for result titles so truncation footers do not inflate file counts, and move the test-only error marker out of production builds.
Refresh user guides, design notes, and research notes against the current source and the pulled sibling repositories. Codex was checked at 79c65f81 and opencode at 1a28924e; the Claude Code remote is disabled, so the notes record the local 4b9d30f checkout limitation.

This also fixes the broken configuration research link and removes stale claims about slash busy-gating, session deletion, effort capability fields, opencode command discovery, and CI coverage.
The Read-before-Edit gate used to allow matching mtime and size to pass without rehashing. That can miss same-size external edits or timestamp-preserving writes, which is exactly the case the tracker is meant to prevent.

Require mutating tools to verify the current bytes against the stored xxh64 hash, and rehash persisted snapshots on resume before restoring them into the live tracker.
wait_with_output buffered stdout and stderr fully before the registry-level cap could run. A noisy command could therefore allocate far beyond the tool output limit.

Read stdout and stderr concurrently, drain both pipes to avoid blocking the child, retain only a bounded prefix per stream, and annotate omitted bytes before final rendering.
@hakula139 hakula139 added bug Something isn't working documentation Improvements or additions to documentation labels May 12, 2026
@hakula139 hakula139 self-assigned this May 12, 2026
@hakula139 hakula139 changed the title refactor(repo): sweep technical debt refactor: sweep technical debt May 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 98.20359% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/oxide-code/src/tool/bash.rs 93.93% 10 Missing ⚠️
crates/oxide-code/src/file_tracker.rs 96.78% 7 Missing ⚠️
crates/oxide-code/src/config/file.rs 98.38% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

hakula139 added 6 commits May 12, 2026 13:45
The timeout previously covered child.wait() but could hang while collecting stdout or stderr if a background descendant kept the pipe open. Share the same deadline across wait and pipe collection, and abort both readers on timeout.
Move the Read-before-Edit freshness decision into FileTracker so Read, Edit, Write, and resume share one content-hash gate. Validate regular-file and size constraints before reading snapshots or mutating existing files, and keep docs aligned with the content-based model.
Share the session-list default between CLI and /resume so the picker cannot load an unbounded page. Make /diff truncation hints match the repository state, and refresh related slash docs and modal comments.
Add focused coverage for tracked-file validation and the edit/write rejection branches that surface it. Leave bash pipe failure plumbing alone because forcing those paths would require artificial seams rather than behavior coverage.
@hakula139 hakula139 merged commit 704ad7a into main May 12, 2026
4 checks passed
@hakula139 hakula139 deleted the refactor/repo-sweep branch May 12, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant