Skip to content

fix: P8 — CLI JSON regression, dead code SQL, chunker loop, vector persist, path corruption, thread cap - #985

Merged
ajianaz merged 1 commit into
developfrom
fix/p8-regression-deadcode-chunker
Aug 10, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/p8-regression-deadcode-chunker

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

What

Post-fix cora re-scan (163 findings) triage — 7 actionable fixes from the remaining findings.

Why

After merging PR #983 and #984 (P0–P7), a re-scan found 163 remaining findings. Subagent analysis categorized them — 7 were validated as real issues worth fixing now, 2 were false positives (embed/engine.rs, aging.rs), and the rest are long-term backlog (N+1 queries, consolidate locking, etc.).

Changes

# File Fix
R1 cli/commands/mod.rs Regression — remaining manual JSON format! converted to serde_json::json!()
R2 core/memory/schema.rs SQL injection defense-in-depth: table name allowlist in column_exists_in
R3 docker-entrypoint.sh Explicit checksum validation — fail fast on mismatch, no silent skip
C1 core/chunker.rs Guard zero-length chunks — floor_char_boundary + force advance prevents infinite loop
C3 core/operations.rs soft_forget now persists vector index removal to disk (survives restart)
C5 core/memory/documents.rs REPLACE() → substr() prefix swap — avoids multi-occurrence path corruption
C6 server/main.rs Atomic counter backpressure — caps concurrent request threads at available_parallelism * 2

False positives skipped:

  • embed/engine.rs:116 — Cora flagged ORT init not reset on failure, but load_model()? propagates error without caching — correct behavior
  • memory/aging.rs:152 — Cora flagged tier_counts warm/cold inversion, but query logic is correct (hot = recent, warm = between cutoffs, cold = older)

Testing

  • cargo fmt ✅
  • cargo clippy --workspace --all-targets — 0 warnings ✅
  • cargo test --workspace — 476 pass, 0 fail ✅
  • Cora pre-commit: passed (3 MAJOR findings reviewed as acceptable trade-offs)

Comment thread crates/uteke-core/src/chunker.rs Fixed
Comment thread crates/uteke-server/src/main.rs Fixed
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-server/src/main.rs:484 — The backpressure mechanism uses std::thread::yield_now() inside a while loop. yield_now() only hints to the OS scheduler; it does not put the thread to sleep. Under high load, the main thread will continuously spin, consuming 100% of a CPU core while waiting for active threads to finish. This degrades throughput for the very workers it's trying to protect. Using std::thread::sleep with a small duration (e.g., 1ms) or using a synchronization primitive like Semaphore would be much more efficient.
  • crates/uteke-server/src/main.rs:505 — The spawned thread increments active before spawning and decrements it at the end of the closure. However, if handlers::route or req.respond panics, the fetch_sub is skipped, and the atomic counter is never decremented. Over time, or during a systematic panic-inducing request, active will reach max_threads and the server will deadlock completely, refusing all new connections. Consider using a Drop guard to ensure the counter is decremented even on panic, or wrap the closure logic in std::panic::catch_unwind.

Review powered by cora-code · BYOK · MIT

…rsist, path corruption, thread cap

- mod.rs: convert remaining manual JSON string to serde_json::json!()
- schema.rs: add table name allowlist in column_exists_in (defense-in-depth)
- docker-entrypoint.sh: explicit checksum validation with error exit
- chunker.rs: guard against zero-length chunks causing infinite loop
- operations.rs: persist vector index to disk after soft_forget
- documents.rs: replace REPLACE() with substr() prefix swap to avoid
  multi-occurrence path corruption when moving subtrees
- main.rs: cap concurrent request threads via atomic counter backpressure
@ajianaz
ajianaz force-pushed the fix/p8-regression-deadcode-chunker branch from ecdf3e4 to 15ada6e Compare August 10, 2026 03:27

// Backpressure: wait until a thread slot is available.
while active.load(Ordering::Acquire) >= max_threads {
if SHUTDOWN.load(Ordering::SeqCst) {
@ajianaz
ajianaz merged commit 82c2b6d into develop Aug 10, 2026
13 of 14 checks passed
@ajianaz
ajianaz deleted the fix/p8-regression-deadcode-chunker branch August 10, 2026 03:33
ajianaz added a commit that referenced this pull request Aug 13, 2026
…rsist, path corruption, thread cap (#985)

- mod.rs: convert remaining manual JSON string to serde_json::json!()
- schema.rs: add table name allowlist in column_exists_in (defense-in-depth)
- docker-entrypoint.sh: explicit checksum validation with error exit
- chunker.rs: guard against zero-length chunks causing infinite loop
- operations.rs: persist vector index to disk after soft_forget
- documents.rs: replace REPLACE() with substr() prefix swap to avoid
  multi-occurrence path corruption when moving subtrees
- main.rs: cap concurrent request threads via atomic counter backpressure

Co-authored-by: ajianaz <[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