quad/.claude/audit/handtrace-round10-reference-impl/spikes/t6_effect_gate.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

28 lines
1.1 KiB
Text

--!nocheck
local q = require("./core")
-- A ──> gated(Block) ──┐
-- └──> plain ─────────┴──> Effect(fn, gated, plain)
local A = q.Source(1)
local plain = q.State(function(self, prev, a) return a:Get() end, {A}, "plain")
local b = q.Blocker()
local gated = q.Gate(A, function(emit) return b:Policy(emit) end, "gated")
-- effect-plan.md의 확정 의사코드 그대로: 공용 EpochMap 하나, true일 때만 Rerun
local epochs = q.EpochMap()
local runs = {}
local function onDep(self, from)
if epochs:Update(from) then
table.insert(runs, ("run(gated=%s, plain=%s)"):format(tostring(gated:Get()), tostring(plain:Get())))
end
end
local o1 = q.Observer(gated, onDep, "dep_gated")
local o2 = q.Observer(plain, onDep, "dep_plain")
b:On()
print("blocker ON — 이 구간의 변경은 gated 쪽에서 유보되어야 한다")
A:Set(2)
print("fn 실행 기록:", table.concat(runs, " | "))
print("gated가 아직 붙들고 있나:", next(gated.withheld) ~= nil)
b:Off()
print("Off() 이후 fn 실행 기록:", table.concat(runs, " | "))
print("gated observer 발화 횟수:", o1.fires, "| plain observer:", o2.fires)