feat(fs): append recovery remedy to guarded-mutation errors

write/edit failures with FS_STALE_VERSION or FS_NOT_OBSERVED now reach the
model with the correct recovery instruction appended (re-read / read, then
retry) while preserving the structured code and chaining the cause. The
edit-intent waterfall sits inside the same try, so the policy's
FS_NOT_OBSERVED refusal is remediated too. Re-recorded the fs-policy-reject
keyless snapshot and the bilingual README pairs.
This commit is contained in:
_Kerman
2026-08-03 19:49:30 +08:00
parent 012bc40f04
commit 1ee167aeac
13 changed files with 174 additions and 16 deletions
+2 -1
View File
@@ -397,12 +397,13 @@ describe('write tool', () => {
expect(text(result)).toContain('file_path must be a non-empty string')
})
it('propagates a backend FsError as an isError result carrying its code', async () => {
it('propagates a backend FsError as an isError result carrying its code and remedy', async () => {
const { ctx, fs } = await setup()
fs.rejectWith = new FsError('blocked', 'FS_STALE_VERSION')
const result = await call(ctx, 'write', { file_path: 'a.txt', content: 'hi' })
expect(result.isError).toBe(true)
expect(result.error).toMatchObject({ info: { name: 'FsError', code: 'FS_STALE_VERSION' } })
expect(text(result)).toContain('re-read the file, then retry')
})
})