quad/.claude/session/2026-08-12-04-compute-self-get-audit.md
qwreey 34ded8b953
fix(docs): missing :Get() on :Compute callback args across base docs
state:Compute(fn)'s fn receives lazy State handles, not raw values, per
the confirmed self/with contract. Found and fixed the same class of bug
the user caught in the Animate example in three more spots (slot-plan.md
x2, tag-plan.md). Added a warning note near the contract since this is
an easy mistake to repeat.
2026-08-12 11:22:26 +09:00

3.3 KiB

2026-08-12 네 번째 세션 — :Compute 콜백 인자 :Get() 누락 버그 전역 감사

앞선 세션(2026-08-12-03)에서 추가한 AnimateCanAnimate 예시가 reduceMotion:Compute(function(r) return not r end)으로 돼 있었는데, r이 raw boolean이 아니라 lazy State 핸들(bind-system-plan.md의 "self/with 값 둘 다 lazy State 핸들로 통일" 확정 계약)이라 not r은 항상 false(State 객체는 절대 nil/false가 아니므로)로 새는 버그라고 사용자가 직접 지적. 같은 클래스의 실수가 다른 곳에도 있는지 .claude/ 전체를 :Compute(function(/:Observer(function(/:Apply(function( 그렙으로 감사.

발견된 버그(전부 수정):

  • research/tween-plan.mdnot rnot r:Get()(사용자가 직접 지적).
  • base/slot-plan.md:578layoutOrder:With(offset):Compute(function(i, o) return i + o end)i:Get() + o:Get()(LayoutOrder 계산 예시).
  • base/slot-plan.md:966Slot:Singlestate:Compute(function(v) return v == nil and {} or { v } end)v:Get() == nil and {} or { v:Get() }. 프로즈로 같은 패턴을 다시 언급하는 1218행도 동기화.
  • base/tag-plan.md:42store.activeTag:Compute(function(name) return name == "btn1" and ...)name:Get() == "btn1".

감사 방법과 스코프: grep -rn ":Compute(function(" 등으로 .claude/ 전역(initreq/ 제외)을 훑고, 히트마다 콜백 파라미터가 비교/연산/테이블 삽입 등 "raw 값이어야 말이 되는" 방식으로 쓰였는지 확인. :Observer/ :Apply 콜백은 전부 인자 없이 외부 변수를 클로저로 캡처하는 관용구라 (function() state:Get() ... end) 이 클래스의 버그 자체가 성립하지 않음 — 확인만 하고 수정 없음. archive/batch-rejected.md:29(function(av, bv) return av + bv end)는 self/with-lazy-핸들 확정 이전의 기각된 초안이라 원문 그대로 보존(archive는 원문을 안 고치는 게 원칙). bind-system-plan.md:1993의 예시는 이미 올바르게 key1:Get()을 쓰고 있어 수정 불필요.

일반 규칙 문서화: base/bind-system-plan.md의 "self/with 값 둘 다 lazy State 핸들로 통일" 절 바로 뒤에 "이 실수가 반복되기 쉬움 — .claude/ 문서에서만도 4곳 발견"이라는 감사 결과+주의 노트 추가 — :Compute/:With 콜백 인자를 비교/연산/테이블 삽입에 쓰기 전엔 항상 :Get()부터 거칠 것.

반영된 파일: research/tween-plan.md, base/slot-plan.md(2곳+프로즈 1곳), base/tag-plan.md, base/bind-system-plan.md(감사 결과 노트).

여전히 열려있는 것: 안 바뀜 — 자연 완료(Completed) 시 per-instance 북키핑 정리 여부 하나(research/pre-implementation-audit.md 2-10번).

다음 세션이 할 일: 안 바뀜(ROADMAP.md M0부터, .claude/luau-test/ 결과 확인 우선).