Conversation
`arrange_core`, `reduce_with_tactic`, and `arrange_from_upsert` build their trace and hard-wire the reader they return to `TraceAgent`, which hides the trace inside its `TraceBox`. A trace that shares state with something outside the operator, for example a handle through which other threads observe its batches, then has no stable way to hand that state to its caller: `TraceAgent::trace_box_unstable` is the only path. The `Agent` trait abstracts the reader an operator returns: `Agent::new` takes the trace by value and returns the reader and a `TraceWriter`. `TraceAgent` implements it by delegating to `TraceAgent::new`. The new `arrange_core_with_agent`, `reduce_with_tactic_and_agent`, and `arrange_from_upsert_with_agent` return `Arranged<A>` for a caller's agent `A`, which can keep the trace's shared state before wrapping a `TraceAgent`. The existing functions delegate with `TraceAgent`, so their callers are unchanged. The writer stays concrete. `TraceWriter::new` and `TraceBox::new` are public, so any agent can build one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015tLhSbZdXrTSK2KwSocT59
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
arrange_core,reduce_with_tactic, andarrange_from_upsertbuild their trace and hard-wire the reader they return toTraceAgent, which hides the trace inside itsTraceBox. A trace that shares state with something outside the operator, such as a handle through which other threads observe its batches, can only hand that state back throughTraceAgent::trace_box_unstable.This adds an
Agenttrait for the reader an operator returns.Agent::newtakes the trace by value and returns the reader and aTraceWriter, andTraceAgentimplements it by delegating toTraceAgent::new.arrange_core_with_agent,reduce_with_tactic_and_agent, andarrange_from_upsert_with_agentreturnArranged<A>for a caller's agent, which can take the trace's shared state before wrapping aTraceAgent. The existing functions delegate withTraceAgent, so no caller changes. The writer stays concrete, sinceTraceWriter::newandTraceBox::neware already public.This is the alternative to #915, which injects a trace factory instead. Here the handle becomes part of the returned type rather than leaving through a closure. Open points for discussion:
TraceWriter<Self::Trace>in the trait rules out agents that intercept writes. Adding a writer associated type later would break implementers.TraceReadercontract of the trace it wraps.reduce_abelian,reduce_core, andreduce_tracestill returnTraceAgent.Posted by Claude Code.
🤖 Generated with Claude Code
https://claude.ai/code/session_015tLhSbZdXrTSK2KwSocT59