Repository navigation
Apply the Closura thread type policy at turn start (CLO-924) - #114
Merged
nullStack65 merged 3 commits intoNov 20, 2026
Merged
Conversation
RuntimePolicy reads ~/.config/closura/thread-type-policy.json (installed by closura-agent-config machine_sync) and classifies each thread as standing, coding, review, research, ops or conversational. A model the type refuses, such as gpt-6-astra on a standing thread, fails the turn start with a clear message. Claude turns get the type's prompt cache TTL and compaction point; Codex threads get model_context_window and model_auto_compact_token_limit. A missing or invalid policy file keeps today's behavior. Model: claude-opus-5-5 Task: CLO-924 Agent: claude-code Lane: magpie Harness: t3/claude-code Model-family: Claude Model-generation: 5.5 Skills-SHA: 709beb59 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude's percent override now targets the effective window, the model's context minus the 20k output reserve, so the compaction point matches the table. The cache TTL is set on the env var Claude ranks above the setting. A disabled auto-compact still reports no threshold. Codex receives only the compaction limit. Refusal covers stacked prefixes, openai. slugs, a trailing -fast, and [1m]. A title pattern JavaScript cannot compile fails open with one warning, and a missing policy warns once. Dispatch and rollback surface the refusal message. Model: grok/grok-4.7 Task: CLO-924 Agent: grok Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: e6cf8938; skills/github-repository-ops/SKILL.md, docs/delivery/provenance-trailers.md Co-Authored-By: Grok 4.7 <noreply@x.ai>
The refusal test read model off the whole resolve error union, so the server typecheck exited 2 and the Linux ARC check failed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Owner
Author
{"reviewed_head":"9a2413c66e1ce9e8b23085ca42fc1cf6e094c3c1","reviewer":"grok-4.7-build (claudeAgent, read-only)","findings":[]} |
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.
Problem
Kameron approved per-thread-type cache and compaction settings and taking gpt-6-astra off standing role threads (CLO-924, from the token burn report in closura-agent-config PR 953). closura-agent-config PR 957 adds the one policy table and installs it on every synced host at
~/.config/closura/thread-type-policy.json. This PR makes the fork honor it.Behavior
ThreadTypePolicy.tsreads and validates the table and classifies a thread: the T3standingpersona wins, then a[type]title tag, then the title rules (child threads skip the top-level-only rules), then the default.T3_THREAD_TYPE_POLICY_PATHoverrides the path.RuntimePolicyV2.resolveapplies it at every turn start, after the runtime mode ceiling. A refused model fails withThreadTypeModelRefusedError, whichProviderTurnStartServicesettles as "Model refused on this thread type" with the policy message. The resolved policy carriesthreadType(type, context window, compaction point, cache TTL).autoCompactWindowbecomes the policy window.CLAUDE_AUTOCOMPACT_PCT_OVERRIDEiscompact_atdivided by the effective window (the model context, capped at the 272k policy window, minus Claude's 20k output reserve), rounded up to two decimals.CLAUDE_CODE_PROMPT_CACHE_TTLis set to the type's TTL so it wins over the setting and over a subagent or instance TTL. The reported threshold uses that same formula. If auto-compact is disabled, no threshold is reported.model_auto_compact_token_limitonly. It does not setmodel_context_window.openai.slug,[1m], and a trailing-fast. Dispatch and checkpoint rollback show that refusal message.Prior art
RuntimePolicy.ts(refuseAboveCeiling): the refusal follows the same pattern and settle path.standingthread property (PR 110) is the standing signal; titles are only the fallback.promptCacheTtl,autoCompactWindow,CLAUDE_AUTOCOMPACT_PCT_OVERRIDE,CLAUDE_CODE_PROMPT_CACHE_TTL; Codexmodel_auto_compact_token_limit.Evidence
pnpm run typecheckin apps/server: clean.vp test runon ThreadTypePolicy, RuntimePolicy, ClaudeAdapterV2, CodexAdapterV2, GrokAdapterV2 and ProviderTurnStartService: 769 pass. Two fail locally (Claude native fork, Grok multi-select question) and fail the same way on the untouched base, because this host's Node 22 cannot strip TypeScript in a spawned child.openai.slugs,-fast, and[1m], per-type values, a JavaScript-invalid pattern failing open, RuntimePolicy refusal and threadType from a fixture file, Claude percent and cache env, Codex compaction limit without a context-window override, and the dispatch error showing the refusal message.vp test runon ThreadTypePolicy, the thread-type cases in ClaudeAdapterV2 and CodexAdapterV2, RuntimePolicy, and UserFacingErrors passed. Full typecheck was not rerun on this host because the load was already high.Deploy: fleet
Model: claude-opus-5-5
Task: CLO-924
Agent: claude-code
Lane: magpie
Harness: t3/claude-code
Model-family: Claude
Model-generation: 5.5
Skills-SHA: 709beb59
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
🤖 Generated with Claude Code