Fix open issues #26-#33, #36-#38 in one batch#40
Conversation
Implements the bug fixes and quality work the open issues called for: - #26 resume-token validation and event replay: new ResumeRegistry tracks issued tokens until the window elapses; SessionActor validates the token + principal on reconnect, restores the original session id, and replays events past last_event_seq. Terminal envelopes (job.result, job.error) are now included in replay so a resuming client sees the final state. - #27 subscribe_job default attach: an explicit subscribe always sends job.subscribe (unless the client is the submitter); the subscribe feature is required for every observer subscribe. - #28 subscription history replay: EventLog now indexes envelopes by job id; SessionActor.handle_subscribe replays from the job index so a late-joining observer sees prior events regardless of which session produced them. - #29 stream_result writer totals: ChunkWriter#close persists totals back to the context, and finish reads from those totals so the non-block writer path no longer raises TypeError. - #30 budget currency denial: try_spend! raises BudgetExhausted when a currency is absent from a budgeted lease while still allowing all spending on unbudgeted leases. - #31 lease_constraints.max_budget: LeaseConstraints now parses max_budget as a CostBudget and enforces it before lease construction; over-budget submits raise LeaseSubsetViolation. - #32 client waiter safety: pending waiters are registered before the outbound envelope is sent so a fast reply cannot beat them. Reply matching is keyed strictly on reply_to. get_result handles a nil dequeue with ProtocolViolation instead of NoMethodError. - #33 session.bye on close: client.close sends session.bye before flipping @closed, so the peer receives the close reason exactly once. - #36 RBS + Steep: signatures for the resume registry, event log, subscription manager, lease constraints, and feature constants were added/updated. Steep is wired into CI on the small file set whose sigs are accurate today; remaining files are flagged as ongoing work. - #37 branch coverage: added unit + integration specs covering transport EOF paths, body decoders, lease branches, client waiter races, resume registry expiry, and pagination stability. Branch coverage rose from 56% to 80%+ and a SimpleCov minimum (line 90, branch 80) now guards regressions. - #38 list_jobs pagination: jobs are walked from an insertion-ordered index keyed by a monotonic seq cursor instead of re-sorting the entire table per page; cursors stay stable when new jobs are submitted between page reads. Also fixes a pre-existing race in JobManager#submit where the post-task `status: 'running'` assignment could clobber an agent's terminal status. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (22)
WalkthroughThis PR implements session resumption via a new resume registry, adds stable cursor-based pagination for job listing, enforces budget constraints on leases, enables job-indexed event replay for efficient history reconstruction, refactors streamed result accounting, and improves client protocol safety. It includes comprehensive integration and unit tests plus type system updates. ChangesResume Sessions, Job History, and Result Streaming
Job Pagination and Budget Constraints
Client Protocol Enhancements
Type System and Type Definitions
Testing and Configuration
🎯 4 (Complex) | ⏱️ ~75 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Closes the eleven open issues on the tracker (#26, #27, #28, #29, #30, #31, #32, #33, #36, #37, #38) in a single batch.
Bug fixes
Arcp::Runtime::ResumeRegistrytracks issued tokens until the resume window elapses;SessionActorvalidates the token + principal on reconnect, restores the original session id, and replays buffered events pastlast_event_seq. Terminal envelopes (job.result,job.error) are now included in replay so a resuming client sees the final state.job.subscribe(unless the client is the submitter). Thesubscribefeature is required for every observer subscribe regardless of whetherfrom_event_seqis supplied.EventLognow indexes envelopes by job id;handle_subscribereplays from that index so a late-joining observer sees prior events regardless of which session produced them.ChunkWriter#closepersists totals back to the context, andfinishreads from those totals so the non-block writer path no longer raisesTypeError.try_spend!raisesBudgetExhaustedwhen a currency is absent from a budgeted lease while still allowing all spending on unbudgeted leases.LeaseConstraintsnow parsesmax_budgetas aCostBudgetand enforces it before lease construction; over-budget submits raiseLeaseSubsetViolation.reply_to.get_resulthandles a nil dequeue withProtocolViolationinstead ofNoMethodError.Client#closesendssession.byebefore flipping@closed, so the peer receives the close reason exactly once.Quality
Steepfile).seqcursor instead of re-sorting the entire table per page; cursors stay stable when new jobs are submitted between page reads.Also fixes a pre-existing race in
JobManager#submitwhere the post-taskstatus: 'running'assignment could clobber an agent's terminal status.Test plan
bundle exec rspec— 200 examples, 0 failuresbundle exec rubocop --parallel— cleanbundle exec steep check— clean on the scoped target setbundle exec yard --fail-on-warning— exits 0🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Infrastructure