refactor(hashline-edit): stabilize hashes and tighten prefix stripping

Switch line hashing to significance-aware seeding so meaningful lines stay stable across reflows while punctuation-only lines still disambiguate by line index.

Also narrow prefix stripping to hashline/diff patterns that reduce accidental content corruption during edit normalization.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-02-23 18:51:25 +09:00
parent afec1f2928
commit ab768029fa
3 changed files with 20 additions and 6 deletions
@@ -21,7 +21,7 @@ describe("computeLineHash", () => {
expect(hash1).toMatch(/^[ZPMQVRWSNKTXJBYH]{2}$/)
})
it("produces different hashes for same content on different lines", () => {
it("produces same hashes for significant content on different lines", () => {
//#given
const content = "function hello() {"
@@ -29,6 +29,18 @@ describe("computeLineHash", () => {
const hash1 = computeLineHash(1, content)
const hash2 = computeLineHash(2, content)
//#then
expect(hash1).toBe(hash2)
})
it("mixes line number for non-significant lines", () => {
//#given
const punctuationOnly = "{}"
//#when
const hash1 = computeLineHash(1, punctuationOnly)
const hash2 = computeLineHash(2, punctuationOnly)
//#then
expect(hash1).not.toBe(hash2)
})