Sequential computation increasingly produces long traces containing nested branches, status transitions, textual payloads, and compact summaries of earlier execution. This paper introduces budgeted dynamic trace structures (BDTS), a data-structural framework for maintaining rooted trace graphs and append-only histories under an explicit byte or token budget. BDTS combines status-filtered reachability, cursor pagination, soft-capped recency logs, reference-counted observation keys, delta overlays, bounded cost caches, and summary-plus-suffix compaction. We give formal invariants, asymptotic bounds, and an ancillary Rust implementation with reproducible benchmarks. Across synthetic traces with 10,000-40,000 vertices, the prototype builds graphs in 0.58-2.72 ms, enumerates all descendants in 0.24-1.42 ms, and compacts histories of 350k-2.71M approximate tokens to 1,048-4,120 approximate tokens. Tokenizer and forward measurements with three public model targets reduce 3,359-3,360 trace tokens to 432-433 tokens.
翻译:顺序计算日益产生包含嵌套分支、状态转换、文本负载以及前期执行紧凑摘要的长序列追踪。本文提出预算约束动态追踪结构(BDTS),一种可在明确字节或令牌预算下维护有根追踪图与仅追加历史的数据结构框架。BDTS融合了状态过滤可达性、游标分页、软上限最近日志、引用计数观察键、增量覆盖、有界代价缓存以及摘要加后缀压缩技术。我们给出了形式化不变量、渐近界以及附带可复现基准测试的配套Rust实现。在包含10,000至40,000个顶点的合成追踪数据上,该原型构建图耗时0.58-2.72毫秒,枚举所有后代节点耗时0.24-1.42毫秒,并将含350k-2.71M近似令牌的历史压缩至1,048-4,120个近似令牌。使用三个公开模型目标进行的分词器与前向测量表明,可将3,359-3,360个追踪令牌缩减至432-433个令牌。