Skip to content

fix(tracing): page trace chunks by retained byte offsets - #119

Merged
Xuepoo merged 2 commits into
mainfrom
ctx-0054/fix-trace-pagination
Sep 17, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
ctx-0054/fix-trace-pagination

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #99. Task: CTX0054.

Scope

  • src/tracing.ts: fetchTraceChunk now pages by actual accumulated encoded byte offsets instead of dividing by a fixed chunk ceiling.
  • tests/tracing.test.ts: variable-size pagination tests against a reference concatenated stream (raw and structured), UTF-8 boundary offset tests, normalized fragment tests, multilingual multi-chunk reconstruction, and explicit empty/end/appended-tail continuation tests.

Behavior

  • Fetch returns the suffix of the containing retained chunk at an integral UTF-8 byte offset; the caller advances by the encoded page byte length.
  • Offsets must be nonnegative safe integers at UTF-8 boundaries; invalid offsets fail explicitly instead of corrupting text.
  • At end-of-trace, offset equals byte count and returns an empty page with continuation: false.
  • No new wire schema, capability, or protocol version; preview/redaction and retained-byte accounting from CTX0051/CTX0053 are unchanged.

Evidence

  • Independent reviewer APPROVE (PX0307/PX0308) at head b5616ca: parents 862b44f (pagination checkpoint) and 7676f87 (origin/main), source blob 06eb011a, test blob 4e4a0ef5.
  • Full local gates: bun test 360/360 (2884 expectations, 17 files), scoped 22/22, tsc --noEmit, prettier, oxlint, markdownlint, bun run check:types, bun run build, cargo fmt/check/clippy/test (76/76) with offline env.
  • gitleaks detect --source . clean before push.

Complexity

O(retained bytes) time per fetch, O(largest stored chunk) transient space.

@Xuepoo Xuepoo added this to the v0.1.0 milestone Sep 17, 2026
@Xuepoo Xuepoo added area:devtools devtools area fix Bug fix P2 Priority: medium labels Sep 17, 2026
@Xuepoo
Xuepoo merged commit 07ebe8d into main Sep 17, 2026
4 checks passed
Xuepoo added a commit that referenced this pull request Sep 18, 2026
…nc trace accounting semantics (#131)

* [CTX-0075] chore(devtools): record bitty-core jurisdiction and sync trace docs

Docs-only governance sync under bitty-core jurisdiction; no code behavior
changes.

- repo.toml: owner TBD -> bitty-core (matches workspace.toml).
- AGENTS.md: record bitty-core commander jurisdiction; keep the core-vs-docs
  boundary sentences; unify the scratch wording (ephemeral under /tmp/bitty/,
  durable under recording/); replace the blanket pre-implementation claim only
  where stale against merged code (tracing phases 1/2, inspect-only watch mode,
  live-socket fixtures) with Implemented-only wording.
- README.md: document the trace accounting semantics implemented by
  CTX-0053/#117 and CTX-0054/#119 and clarified in bitty-terminal-docs
  specifications/devtools-rfc.md (CTX-0026): retained redacted logical UTF-8
  export-byte accounting, independent per-record normalization with leading
  U+FEFF preserved, effective min(trace maxBytes, retention maxBytes)
  rejection with one counted drop and unchanged retained state, raw append vs
  typed stream coalescing, and fetchTraceChunk pagination on retained UTF-8
  byte offsets. Each claim verified read-only against src/tracing.ts and
  crates/devtools-client/src/tracing.rs.
- CHANGELOG.md: docs-only entry recording the same semantics sync.

Gates: just check green (prettier, markdownlint, tsc, bun test 444,
cargo fmt/check/clippy/test); actionlint clean; act -n CI dry-run clean
(offline action mode).

Refs #130
Task: CTX-0075

* [CTX-0075] fix(docs): repoint DevTools RFC links to bitty-terminal-docs

NEEDS-FIX PX-0389: README.md pointed the accepted DevTools RFC at
bitty-docs/docs/specifications/devtools-rfc.md (404); the canonical copy
lives in bitty-terminal-docs specifications/devtools-rfc.md (HTTP 200).
Sweep all four occurrences in README.md (45, 169, 201, 454; the review
cited 45/169/424) and correct the CTX-0026 attribution to
bitty-terminal-docs.

Gates: just check green (prettier 3.9.6, markdownlint 0 issues, tsc,
bun test 444 pass, cargo fmt/check/clippy/test 79+20 pass).

Refs #130
Task: CTX-0075

* [CTX-0075] fix(docs): repoint IPC and Agent RFC link to bitty-ai-docs (review PX-0390)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:devtools devtools area fix Bug fix P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TERM-DEV-008] Investigate variable-size trace chunk pagination

1 participant