Skip to content

correct: Poll the deadline inside structural traversals - #137

Open
BenWestgate wants to merge 1 commit into
reviewability-v1from
claude/indel-deadline
Open

BenWestgate wants to merge 1 commit into
reviewability-v1from
claude/indel-deadline

Conversation

@BenWestgate

@BenWestgate BenWestgate commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Before: correct(CorrectionContext(Profile.MS), "ms10tests" + "q" * 122) returned after 14.2 s, despite the documented ten-second deadline. Some alignment traversals on repeated-symbol input did minutes of work without yielding, so _search_target never reached its deadline check: one traversal on a 126-character all-q string ran 237 s.

After: the same call returns at 10.00 s. A search that stops at the deadline in its last layer now reports itself incomplete.

How: indel._views takes the deadline. It checks it before each edit or swap, including swaps of two equal symbols that are then skipped, and every 1024 deletion choices, the way _competitors._known_swaps already does. Once the deadline passes, every level returns without visiting its remaining siblings, so a traversal stops within a millisecond of the deadline. _search_target returns False when the deadline has passed by the end of its layers. One consequence is deliberate: a search that finishes just after the deadline is now reported as incomplete instead of complete, which errs on the safe side.

Swap and insertion traversals on ordinary input show no measurable slowdown. On all-repeated input, where most edits are skipped, the deletion loop is about 20% slower (3.6 s to 4.4 s for one pathological layer) and so is a swap layer (0.52 s to 0.62 s at 1,023 symbols).

Security review (focused): ACK.

  • Completeness: an early stop can't be reported as a complete search. The clock only moves forward, so the next layer check, the best cutoff path, _search_many and _search_competitors all see the deadline as passed.
  • No change below the deadline: with no deadline or a distant one, the traversal yields exactly the same 928,728 alignments as the parent commit.
  • Polling gaps: the longest stretch without a poll is about 0.07 s, measured across every shape on 119–135 character inputs. Codex then found that equal-symbol swaps skipped the poll, so a 1,023-symbol all-q swap layer ran 0.5 s past an expired deadline; the poll now comes before that skip and it stops at once. That follow-up only moves the check earlier, so the completeness argument above covers it unchanged.

Tests: four deterministic clock tests cover both traversal branches, the skipped equal swaps and the incomplete result. All four fail on the current code. The full suite passes (911 tests).

Stacked on #130: on reviewability-v1 this change would push the package past the 5,200-line budget, and #130 brings it down to 4,959. With this change it is 4,971.

Fixes #136. Found by Codex on #94.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1

@BenWestgate BenWestgate self-assigned this Oct 7, 2026
@BenWestgate
BenWestgate force-pushed the claude/indel-deadline branch from 07cc26b to 86a789d Compare October 7, 2026 09:47
@BenWestgate
BenWestgate marked this pull request as ready for review October 7, 2026 09:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 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-08T07:48:54.370624Z 56bba33 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 86a789d0f4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/codex32/indel.py Outdated
@BenWestgate
BenWestgate force-pushed the claude/indel-deadline branch from 86a789d to f1d223c Compare October 7, 2026 10:11
@BenWestgate
BenWestgate force-pushed the claude/remove-unused-api branch from 0c5d3f0 to c8bedfd Compare October 8, 2026 01:51
@BenWestgate
BenWestgate force-pushed the claude/indel-deadline branch from f1d223c to 3fe58cd Compare October 8, 2026 01:56
Base automatically changed from claude/remove-unused-api to reviewability-v1 October 8, 2026 07:42
_search_target checked the deadline once per layer and once per 32
yielded alignments. indel._views skips duplicate edits inside a run of
one symbol, so on repeated-symbol input some layers did millions of
steps between yields: a 126-character all-q string spent 237 s in one
('I', 'I', 'I', 'AT') traversal without yielding, and correct() on
"ms10tests" + "q" * 122 returned after 14.2 s instead of 10 s.

Pass the deadline into _views and poll it before each edit or swap,
including swaps of equal symbols that are then skipped, and every 1024
deletion choices, as _competitors._known_swaps already does; once it
passes, every level returns without touching its remaining siblings.
A search whose last layer stops at the deadline now reports itself
incomplete. The same input now returns at 10.00 s, and a 1,023-symbol
all-q distant swap layer stops at once instead of 0.5 s past the
deadline.

Fixes #136

Claude-Session: https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1
@BenWestgate
BenWestgate force-pushed the claude/indel-deadline branch from 3fe58cd to 56bba33 Compare October 8, 2026 07:45

This branch has not been deployed

No deployments
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