Skip to content

fix: 10 validated bug fixes across serve, skills, render, and perf tools - #147

Merged
jkyberneees merged 2 commits into
mainfrom
fix/events-ring-frontmatter-scalars
Aug 28, 2026
Merged

fix: 10 validated bug fixes across serve, skills, render, and perf tools#147
jkyberneees merged 2 commits into
mainfrom
fix/events-ring-frontmatter-scalars

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Summary

Ten bugs found, each validated with a failing (RED) test on main before its fix, all GREEN after. Every fix pairs with a regression test pinning the corrected behavior; per-bug rationale lives in the test comments.

# Area Bug Fix
1 serve eventsRing.snapshot served the oldest N matching events once the ring exceeded the limit — /api/events stale exactly under load Most-recent window, oldest-first as documented; result no longer aliases the ring slice
2 skills Numeric/bool frontmatter scalars (version: 1.2, author: 7, trigger.topic: 2) silently dropped by bare .(string) assertions Canonical scalar coercion for string-typed fields
3 perf head_tail description promised a streaming early-stop the implementation never does (exact totals are test-pinned) Description aligned to real behavior
4 perf math_eval 1 % 0.5 → integer divide-by-zero panic; 0.5 % 2 → silently wrong 0 % requires integer operands, clean error
5 perf sort order:"desc" + reverse:true ignored reverse reverse flips the effective direction
6 perf sort order:"DESC" silently sorted ascending (schema enum violated) Case-insensitive enum + reject unknown values with a clean error
7 render ToolPreview lost previews on compact JSON ({"path":"main.go"}"file") extractJSONField rewritten: key-boundary aware, JSON-decodes values
8 render ToolPreview byte-truncation split multi-byte runes → invalid UTF-8 Rune-safe truncateRunes
9 perf head_tail/word_count on directories: raw scanner errors; word_count reported the dir stat size beside the error Same clear is-a-directory guard as count_lines
10 perf tree on a symlinked directory root → non-directory "file" sized by the target-path string, nothing walked Root resolved via Stat; descendants keep Lstat semantics (symlinks shown, never followed)

Investigation notes

  • One candidate was retired during validation: the ParseRefs @@ behavior looked like a broken escape, but TestParseRefs_DoubleAt pins it as intended. Reverted rather than weakening the pinned contract; replaced with bug feat(memory): path-aware episode/skill provenance + human-gated promote #10.
  • Known environmental exclusion during verification: TestBatchPatch_TrustedClasses blocks on an interactive TTY approval prompt in headless runs (pre-existing; batch_patch code untouched by this branch).

Test plan

  • All 10 new regression tests RED on main → GREEN on this branch
  • go build ./..., go vet ./...
  • golangci-lint run — 0 issues
  • Full ./internal/... suite; -race on changed internal packages
  • cmd/odek stateless subset for every touched tool family

Each fix is paired with a regression test that failed (RED) on main
before the fix and passes (GREEN) after; full per-bug rationale in the
test comments.

1. serve: eventsRing.snapshot served the OLDEST limit-matching events
   once the ring held more than the limit; /api/events now returns the
   most-recent window, oldest-first as documented.
2. skills: frontmatter scalars with numeric/bool forms (version: 1.2,
   author: 7, trigger topic: 2) were silently dropped by bare string
   assertions after parseYAMLValue type inference; string-typed fields
   now coerce scalar forms canonically.
3. perf: head_tail description claimed a streaming early-stop the
   implementation does not do (exact totals are pinned by test and kept);
   description now matches behavior.
4. perf: math_eval % with fractional operands panicked (1 % 0.5 →
   integer divide by zero) or silently truncated (0.5 % 2 → 0);
   non-integer operands now get a clean error.
5. perf: sort order is now a validated case-insensitive enum ("DESC"
   previously sorted ascending silently) and reverse flips the effective
   direction (desc+reverse = ascending, per the schema contract).
6. render: extractJSONField required a space after the colon, so compact
   JSON args ({"path":"main.go"}) silently lost their tool previews;
   rewritten to locate keys properly and json-decode values (escapes
   resolved).
7. render: tool-preview truncation sliced bytes, splitting multi-byte
   runes into invalid UTF-8; truncation is now rune-safe.
8. perf: head_tail and word_count on directories surfaced raw scanner
   errors (word_count also reported the dir stat size next to the error);
   both now give count_lines' clear is-a-directory message.
9. perf: tree on a symlinked directory root reported a non-directory
   "file" sized by the link-target string and walked nothing; the
   explicitly-requested root is now resolved, descendants keep Lstat
   semantics (symlinks shown, never followed).
10. serve: eventsRing.snapshot no longer aliases the ring's backing
    slice in its result (copy before return).

Verified: go build, go vet ./..., golangci-lint (0 issues), full
internal/... suite, -race on changed internal packages, and the
cmd/odek stateless subset for every touched tool family. Known
environmental exclusion: TestBatchPatch_TrustedClasses blocks on an
interactive TTY approval prompt in headless runs (pre-existing, code
untouched by this branch).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
odek 75fc1fd Commit Preview URL

Branch Preview URL
Aug 28 2026, 05:56 AM

CI caught a data race in TestAudit_WriteWSJSONStalledClientBounded: the
test retunes the package-global wsWriteTimeout while live WS write paths
(including in-flight goroutines surviving earlier tests) read it inside
writeWSJSON's select — an unsynchronized read/write of a plain time.Duration.

Convert wsWriteTimeout to atomic.Int64 (Store at init, Load in the write
watchdog) and update the test to Load/Store. Behavior unchanged; the
memory-model violation is gone regardless of detector scheduling.
@jkyberneees
jkyberneees merged commit e591c60 into main Aug 28, 2026
10 checks passed
@jkyberneees
jkyberneees deleted the fix/events-ring-frontmatter-scalars branch August 28, 2026 06:00
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