quad/.claude/audit/handtrace-round7-reference-impl/spikes/t7_poisoned.luau
qwreey 6f939a8d2d
audit: 7라운드 4·5·6차 패스의 참조 구현·스파이크를 저장소로 (재현 가능하게)
지금까지 세션 스크래치패드에만 있던 것을
.claude/audit/handtrace-round7-reference-impl/로 옮긴다. 다음 세션이
발견 52건을 판정하려면 이게 있어야 한다.

구성:
- spikes/core.luau      — 반응형 코어(state-epoch §2~§5, 전파 모델,
                          gate 4·8번, Blocker, H-23 스냅샷)
- spikes/dispatch.luau  — Length/Offset 부기(getOffsetAt 접두합 캐시,
                          recompute, setLength/setOffsetSource, 배치 게이팅)
- spikes/chain.luau     — Dispatch 체인(하강 diff, retractFrom)
- spikes/*.luau         — 시나리오 29개(런타임 18 + 타입 11)
- RUN-runtime.txt / RUN-typecheck.txt — 2026-08-25 실행 결과 스냅샷
- README.md             — 원문 대조표 + 스파이크→발견 대조표

⚠️ README가 가장 중요하다: 이 참조 구현은 base/의 확정 의사코드를 손으로
옮긴 **전사물**이라 그 자체가 틀렸을 수 있다. 그래서 "재실행은 검증이
아니다"를 못박고, (a) 어느 파일이 어느 절을 옮긴 것인지 대조표와
(b) 문서와 **의도적으로** 다른 곳 3개(H-72 때문에 임시로 둔 PeekDiffers,
H-102의 A/B 대조를 위한 위치 박스, 생명주기 게이팅 부재=H-97)를 같이
싣는다. 그 셋 외의 모든 차이는 전사 오류 후보다.

부수로 round7 문서 머리에 이 폴더 포인터와 같은 경고를 달았고,
.claude/README.md의 audit/ 행에도 등재했다.

Co-authored-by: qwreey <me@qwreey.moe>
2026-08-25 12:00:08 +09:00

40 lines
1.7 KiB
Text

--!nocheck
local q = require("./core")
-- dispatch-core-plan.md "배치 등록을 안전하게 만드는 Blocker 게이팅" 그대로
local blockers = {} -- Relate(ownerKey) 자리
local function getBlocker(owner)
if not blockers[owner] then blockers[owner] = q.Blocker() end
return blockers[owner]
end
local recomputes = 0
local function gatedRecompute(owner)
if getBlocker(owner):IsOn() then return end -- 배치 중이면 스킵
recomputes += 1
end
local function drive(owner, positions)
local bl = getBlocker(owner)
bl:On()
for _, p in positions do
p() -- 각 position 처리(사용자 코드가 여기서 돈다)
gatedRecompute(owner) -- setLength가 트리거하는 자리
end
bl:OffWithoutEmit() -- 4번: 배치 끝
recomputes += 1 -- "그 직후 딱 한 번" 명시적 recompute
end
local inst = {} -- ownerKey
print("-- 정상 배치 --")
drive(inst, {function() end, function() end})
print("recompute 횟수:", recomputes, "| blocker.IsOn():", getBlocker(inst):IsOn())
print("-- 두 번째 배치에서 사용자 코드가 error --")
local ok = pcall(drive, inst, {function() end, function() error("컴포넌트 실패") end})
print("drive가 던졌는가:", not ok, "| blocker.IsOn():", getBlocker(inst):IsOn(), "← 영구 On")
print("-- 이후 런타임 :Add() 등이 부르는 setLength --")
local before = recomputes
gatedRecompute(inst); gatedRecompute(inst); gatedRecompute(inst)
print("recompute가 몇 번 돌았나:", recomputes - before, "(0이면 그 owner는 영영 재계산 안 됨)")
print("-- 새 배치를 열어도 --")
pcall(drive, inst, {function() end})
print("blocker.IsOn():", getBlocker(inst):IsOn(), "| 총 recompute:", recomputes)