Repository navigation
AI-140 Standing roles: badged persistent threads with check-ins, polled triggers and per-thread compaction - #27
Merged
Merged
Conversation
…ed triggers and per-thread compaction A role is a pinned thread per client that never settles, snoozes or archives (like the release manager). It wakes on check-ins (scheduled tasks bound to its thread) and on triggers: commands run every N minutes in the project's main checkout that print new items (t4-probe). New items are deduped, batched, held in quiet hours and capped per day, then delivered as one message; nothing is spent while nothing is new. Roles and release managers get a compaction point per thread (Codex model_auto_compact_token_limit, Claude autoCompactWindow): usa-rs's release manager carried ~286k tokens into each of 3,172 requests in two days. API: GET/POST /api/t4/roles, /roles/:id/delete, /roles/:id/run, /roles/release-manager; /api/t4/state gains standingRoles.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosNo All 64 scenario measurements
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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.
AI-140. Standing roles: persistent, pinned, badged threads per client (like the release manager) that wake on check-ins and on polled triggers, plus a compaction point per thread for roles and release managers.
What changes
t4_rolestable (migration 5) andt4/T4Roles.ts: list / save / delete / run, check-ins as scheduled tasks bound to the role thread (threadMode: continue), and thet4-rolesjob (every minute). The job runs each due trigger (bash -c <command>in the project's main checkout, 60 s cap,T4_PROBE_STATE/T4_PROBE_SINCE), dedupes items by id, gathers them forbatchMinutes, and delivers one message when the thread is idle, outside quiet hours and under the daily cap. A trigger's first run only records what it sees. Three failures in a row send the thread one note (at most every 6 h).T4Ledger.standingRoleOf: settle refusal,t3_thread_organize, auto-archive), androleOfgives them rolerolewithroleKind/roleTitlein thread facts.t4/threadCompaction.ts: a per-thread compaction point, rebuilt every minute from the roles and the release managers (releaseManager.compactAtTokensin t4-server.json, or a client override). Codex getsmodel_auto_compact_token_limitin the thread config; Claude getsautoCompactWindow= point + 33,000. usa-rs's release manager sent ~286k tokens with each of 3,172 requests (11-21..23) because Codex compacts only near its 475k window.GET/POST /api/t4/roles,/roles/:id/delete,/roles/:id/run,/roles/release-manager;/api/t4/stategainsstandingRoles.Verified
pnpm run typecheck(effect-tsgo) clean.T4Roles.test.ts(baseline, dedupe, batching, message format, Pacific quiet hours across midnight, roleOf, compaction table) plus the t4 suites around it: 9 files, 237 tests pass.ClaudeAdapterV2.test.ts: 477 pass.t4-probe, the catalog, the role skills and the dashboard's Roles tab; its probes were run against usa-rs's real Sentry, Linear, GitHub and AI-cost data.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.