fix(hashline): accept legacy hashes for indented anchors

Keep persisted LINE#ID anchors working after strict whitespace hashing by falling back to the legacy hash for validation-only lookups.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-03-14 13:42:17 +09:00
parent f03de4f8a8
commit bbd2e86499
4 changed files with 43 additions and 11 deletions
+10 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from "bun:test"
import { computeLineHash } from "./hash-computation"
import { computeLineHash, computeLegacyLineHash } from "./hash-computation"
import { parseLineRef, validateLineRef, validateLineRefs } from "./validation"
describe("parseLineRef", () => {
@@ -116,6 +116,15 @@ describe("validateLineRef", () => {
expect(() => validateLineRef(lines, "1#ZZ")).toThrow(/>>>\s+1#[ZPMQVRWSNKTXJBYH]{2}\|/)
})
it("accepts legacy hashes for indented lines", () => {
//#given
const lines = [" function hello() {", " return 42", " }"]
const legacyHash = computeLegacyLineHash(1, lines[0])
//#when / #then
expect(() => validateLineRef(lines, `1#${legacyHash}`)).not.toThrow()
})
it("shows >>> mismatch context in batched validation", () => {
//#given
const lines = ["one", "two", "three", "four"]