Skip to content

Commit 96c40c3

Browse files
committed
fix(tests): pin the exact-range redirect-once behaviour in the breaker/write-guard test
bf14d04 changed a repeated exact line-range read to redirect to the cached output once and then fail open for that same range (CHANGELOG, tests/hooks_read.test.ts 'redirects an exact served range once'). The pin here still expected the second identical retry to be locked. It now expects the let-through and that a shifted window inside the served lines stays denied.
1 parent 21e5f63 commit 96c40c3

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎tests/hooks_read_breaker_write_guard.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** The re-read denial circuit breaker and the Write blind-drop guard compose: a whole-file denial loop the breaker ends hands over one real read the Write guard counts as seen, while a line-range retry is locked rather than let through, so a refused retry is never counted as seen. Provenance: HAND-DERIVED from a 200-line file; the whole-file rows read it unranged, the range rows serve its first 60 lines; the first version of the range sequence was driven through the built hook entry (PreToolUse/PostToolUse payloads with Read and Write tool inputs) and printed the deny, the breaker's advisory note, and the blind-drop refusal quoted in the merge report. The range rows pin main's 44e95a016, where a refused range read locks later slices instead of going through the breaker (the fileRereadDenyKey comment in src/hooks_read.ts). */
1+
/** The re-read denial circuit breaker and the Write blind-drop guard compose: a whole-file denial loop the breaker ends hands over one real read the Write guard counts as seen, while a line-range retry is redirected once and then let through for that same range, so a refused retry is never counted as seen. Provenance: HAND-DERIVED from a 200-line file; the whole-file rows read it unranged, the range rows serve its first 60 lines; the first version of the range sequence was driven through the built hook entry (PreToolUse/PostToolUse payloads with Read and Write tool inputs) and printed the deny, the breaker's advisory note, and the blind-drop refusal quoted in the merge report. The range rows pin main's 44e95a016, where a refused range read locks later slices instead of going through the breaker (the fileRereadDenyKey comment in src/hooks_read.ts). */
22
import * as fs from 'node:fs'
33
import * as os from 'node:os'
44
import * as path from 'node:path'
@@ -87,16 +87,19 @@ describe('the re-read circuit breaker and the Write blind-drop guard', () => {
8787
expect((await preWriteRewriteHandler(writeEvent(target, FIRST_60_ONLY))).hookType).toBe('pass')
8888
})
8989

90-
it('locks the second identical line-range retry instead of letting it through the breaker', () => {
90+
// bf14d04ad (CHANGELOG: "redirect to the cached output once, then fail open for that same range") replaced the old second-retry lock: the redirect is spent on the first retry, the identical retry is let through, and a shifted window stays denied.
91+
it('lets the second identical line-range retry through after one redirect, and keeps a shifted window denied', () => {
9192
const target = seed('ts')
9293
serveFirstWindow(target)
9394
expect(preReadHandler(rangeReadEvent('pre_tool_use', target)).hookType, 'the first retry is denied').toBe('deny')
9495
const second = preReadHandler(rangeReadEvent('pre_tool_use', target))
95-
expect(second.hookType, 'the second identical range retry stays denied').toBe('deny')
96-
if (second.hookType === 'deny') expect(second.message).toContain('Line-range reads of this file are locked')
96+
expect(second.hookType, 'the second identical range retry is let through').toBe('context')
97+
if (second.hookType === 'context') expect(second.context).toContain('Read allowed after the prior redirect')
98+
const shifted = preReadHandler(makeHookEvent({ eventName: 'pre_tool_use', toolName: 'Read', toolInput: { file_path: target, offset: 2, limit: 58 }, sessionId: 'breaker-write' }))
99+
expect(shifted.hookType, 'a shifted window inside the served lines stays denied').toBe('deny')
97100
})
98101

99-
it('still refuses a Write that drops lines nobody saw after a locked line-range retry', async () => {
102+
it('still refuses a Write that drops lines nobody saw after line-range retries', async () => {
100103
const target = seed('ts')
101104
serveFirstWindow(target)
102105
preReadHandler(rangeReadEvent('pre_tool_use', target))

0 commit comments

Comments
 (0)