quad/.claude/audit/handtrace-round10-reference-impl/spikes/d7_splice_fix.luau
qwreey d2d67c7aeb
qa: 10라운드 광범위 탐사 완료 — 발견 H-150~H-157 (🔴 0 / 🟡 5 / 🟢 3), §4 배치 문항 7건 회신 대기
- 신선한 탐사자(fable) 단일 컨텍스트, 지시서 -round10-brief.md §2 레인 A·C 완료, B 부분, D ALL PASS
- audit/handtrace-round10-reference-impl/: round7 참조 구현을 현재 계약으로 갱신·재실행
  (부수: round7/ref9 _recompute 첫 인자 오류 발견·정정)
- base/·인덱스 레이어는 미변경 — 결정은 사용자 배치 회신 뒤 -round10-followup.md로

Co-authored-by: qwreey <me@qwreey.moe>
Claude-Session: https://claude.ai/code/session_01546hjsYNLSMZdHdPyTZaGb
2026-08-28 01:03:05 +09:00

39 lines
1.5 KiB
Text

--!nocheck
local q = require("./core"); local D = require("./dispatch")
-- RETUNE = true면 splice가 이동된 observer의 위치 인덱스를 실제 위치로 다시 맞춘다
local function run(RETUNE)
local function spliceArraysDown(ownerKey, index)
local bk = D.getBookkeeping(ownerKey)
for i = index, bk.N - 1 do
bk.lengthList[i] = bk.lengthList[i + 1]
bk.sourceList[i] = bk.sourceList[i + 1]
bk.observers[i] = bk.observers[i + 1]
end
bk.lengthList[bk.N] = nil; bk.sourceList[bk.N] = nil; bk.observers[bk.N] = nil
bk.N -= 1
bk.invalidAfter = math.min(bk.invalidAfter, index)
if RETUNE then
for i = index, bk.N do
local o = bk.observers[i]
if o and o.box then o.box.pos = i end
end
end
end
local owner, s = {}, {}
for i = 1, 3 do s[i] = D.newSlot("s" .. i) end
local bl = D.getBlocker(owner); bl:On()
for i = 1, 3 do
D.setOffsetSource(owner, i, s[i].Offset)
D.setLength(owner, i, s[i].Length, owner)
s[i].Length:Set(1)
end
bl:OffWithoutEmit(); D.recompute(owner, D.getBookkeeping(owner))
spliceArraysDown(owner, 1)
D.recompute(owner, D.getBookkeeping(owner))
s[2].Length:Set(5)
print(("[%s] s3.Offset = %d (기대 5) | invalidAfter = %d")
:format(if RETUNE then "위치 재조정함" else "확정 설계 그대로", s[3].Offset:Get(),
D.getBookkeeping(owner).invalidAfter))
end
run(false)
run(true)