Skip to content

refactor(runtime): unify ArchiveRead canonical document and response-budget ownership #4452

Description

@liugddx

Part of #4267. Follow-up to #4355 and #4380.

Motivation

The ArchiveRead retrieval work in #4380 fixes the immediate correctness failures (non-advancing line pagination, Unicode search coordinates, and inspect response overflow), but the review also exposed a structural issue: coordinate semantics and response-budget fitting are currently implemented by several independent branches.

The follow-up should make the invariants explicit without expanding #4380 or breaking its line-facing contract.

Proposed scope

  • Introduce one canonical archive-document projection for plain text, terminal pipes, PTY streams, and structured JSON.
  • Make internal read/search coordinates derive from that document authority.
  • Keep the public unit: "line" / line-offset facade from harness: ArchiveRead search / line reads / section index ergonomics (item 3 of #4267) #4355 while allowing the implementation to use character ranges internally.
  • Introduce one field-aware fitArchiveResponse() owner for the final TOOL_RESULT_ARCHIVE_MAX_RESPONSE_CHARS envelope across inspect, read, query, and search.
  • Optimize line reads so large windows do not repeatedly materialize and stringify the same content.
  • Define the coordinate/ref contract for queryable items[] subdocuments.
  • Add operation × payload-shape regression/property tests for the response-size invariant and continuation progress.

Non-goals

  • Do not change the shell capture/preservation contract or recover output already dropped before archiving.
  • Do not reopen archive threshold policy.
  • Do not remove or silently change the line-oriented API in the first iteration.

Acceptance

  • Every successful and failure ArchiveRead response stays within the configured response budget after final serialization.
  • Search offsets, snippets, and continuations are in the documented canonical coordinate space.
  • Line reads either return progress or an actionable bounded failure for an oversized line.
  • Long accepted search patterns remain representable without silent truncation.
  • Existing harness: ArchiveRead search / line reads / section index ergonomics (item 3 of #4267) #4355 behavior and current ArchiveRead refs remain backward compatible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions