Skip to content

🤖 refactor: name the truncate-history admission and scope decision - #6278

Merged
ThomasK33 merged 1 commit into
mainfrom
crap/truncate-history-admission-scope
Oct 12, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
crap/truncate-history-admission-scope

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

WorkspaceService.truncateHistory opened with two decisions written inline. First, its admission: take the context-mutation guard when the request may remove rows, or else refuse while a turn is active. Second, its truncation scope: all, none, or whatever the history preflight classifies, with null when history cannot be read. Each decision is now a named private method, and the explanatory comments moved with them. Behavior is unchanged.

Background

This PR is part of the CRAP pilot on src/node/services/workspaceService.ts. CRAP = CC² × (1 − coverage)³ + CC.

Function CC before CC after CRAP after (related tests)
truncateHistory 43 37 37
acquireTruncateHistoryAdmission (new) 5 5
classifyTruncationScope (new) 3 3

make crap-check with related-test coverage: PASS, 0 violations, 0 warnings. A follow-up PR will move the full-clear preparation and the full-clear state discard, which brings truncateHistory under 30.

Implementation

  • acquireTruncateHistoryAdmission returns the guard result unchanged for a percentage above 0, so the caller returns the same error. For 0 or below it keeps the same busy refusal text, and otherwise returns Ok(null).
  • classifyTruncationScope replaces the nested ternary with early returns, and keeps the same .catch that logs and returns null.

Validation

  • The 16 suites that call truncateHistory pass unchanged (1,100 tests).
  • I ran mutants against the new steps. "Never take the guard" and "treat a failed preflight as partial" fail existing tests.
  • "Skip the busy refusal for a percentage of 0 or below" was untested. I added "a zero-percent truncation refuses while a stream is active and keeps history" in workspaceService.truncateHistory.test.ts. It is refused while streaming and succeeds once idle with the row kept. It passes on the code before this PR and fails against that mutant.
  • "Return all for 100% only through the history preflight" is an equivalent mutant: HistoryService.classifyTruncationRemoval itself returns "all" for 1.0 or more.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $5.23

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T21:08:33.079181Z 659c414 PR opened
🔒 Security Review ✅ Completed 2026-10-12T21:08:32.845564Z 659c414 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit d859098 Oct 12, 2026
33 checks passed
@ThomasK33
ThomasK33 deleted the crap/truncate-history-admission-scope branch October 12, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant