mirror of
https://github.com/stablyai/orca.git
synced 2026-10-27 00:02:48 +00:00
A managed block missing its end marker was treated as Orca-owned through EOF, so uninstall/reinstall deleted appended user tables. The same shape existed a second time in the Codex legacy profile cleanup. Ownership is now two separate claims: a marker pair proves extent, and a provider that can recognize its own emitted tables owns them wherever they sit. An orphaned marker owns only its own line. Recognition uses the same test for remove, install and status, so a table Orca cannot see is never one it leaves running. Co-authored-by: maoking <secretxierluo@gmail.com> Fixes #18861
39 lines
1.7 KiB
TypeScript
39 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { stripLegacyManagedProfileBlock } from './codex-hook-legacy-cleanup'
|
|
|
|
const START = '# BEGIN ORCA AGENT STATUS HOOKS'
|
|
const END = '# END ORCA AGENT STATUS HOOKS'
|
|
|
|
describe('legacy Codex managed profile block', () => {
|
|
it('strips a well-formed block and keeps the surrounding config', () => {
|
|
const content = `model = "o3"\n\n${START}\n[[hooks]]\nx = 1\n${END}\n\ntail = true\n`
|
|
expect(stripLegacyManagedProfileBlock(content)).toBe('model = "o3"\n\ntail = true\n')
|
|
})
|
|
|
|
it('leaves a file with no managed block untouched', () => {
|
|
expect(stripLegacyManagedProfileBlock('model = "o3"\n')).toBe('model = "o3"\n')
|
|
})
|
|
|
|
it('rejoins a CRLF config with CRLF', () => {
|
|
const content = `model = "o3"\r\n\r\n${START}\r\n[[hooks]]\r\n${END}\r\n\r\ntail = true\r\n`
|
|
const next = stripLegacyManagedProfileBlock(content)
|
|
expect(next).toBe('model = "o3"\r\n\r\ntail = true\r\n')
|
|
expect(next).not.toMatch(/[^\r]\n/)
|
|
})
|
|
|
|
// CodeRabbit on #20148: a stray marker above a complete block must not hide it.
|
|
it('removes a complete block that sits below an orphaned marker', () => {
|
|
const content = `${START}\nstray = 1\n\n${START}\n[[hooks]]\nx = 1\n${END}\n\ntail = true\n`
|
|
const next = stripLegacyManagedProfileBlock(content)
|
|
expect(next).not.toContain('[[hooks]]')
|
|
expect(next).toContain('stray = 1')
|
|
expect(next).toContain('tail = true')
|
|
})
|
|
|
|
// #18861: the old strip ran to EOF whenever the end marker was gone.
|
|
it('fails closed when the end marker was hand-deleted', () => {
|
|
const content = `model = "o3"\n${START}\n[[hooks]]\nx = 1\n\n[user.table]\nkeep = "mine"\n`
|
|
expect(stripLegacyManagedProfileBlock(content)).toBe(content)
|
|
})
|
|
})
|