Skip to content

feat(codegen): a helper under a fallible caller is checked too — the call path decides - #339

Merged
xzawed merged 3 commits into
mainfrom
feat/helper-check-propagation
Sep 26, 2026
Merged

xzawed merged 3 commits into
mainfrom
feat/helper-check-propagation

Conversation

@xzawed

@xzawed xzawed commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

SPEC-helper-check-propagation §6 작업 1. DP-P1~P11 사용자 확인(2026-09-26, 권고안 그대로). 관련: DP-O7(뒤집는다) · DP-O4/O6/O8 · D17 · #238.

무엇이 바뀌나

! 함수가 실행하는 산술은 어디에 쓰여 있든 검사된다 — 자기 본문이든, (여러 단계로) 부른 무한 함수 안이든(export된 함수 포함). 같은 함수를 무한 본문·호스트가 부르면 오늘처럼 wrap·포화한다.

  • 한 집합(ir::checked_helpers, DP-P6): ! 본문에서 무한 호출로 닿고 자기 본문이나 그 아래가 넘칠 수 있는 무한 함수. codegen과 .h·.pas가 이 집합 하나를 읽는다 — 시험 구현은 헬퍼 경로로 -3을 내면서 바인딩이 선언하지 않았다.
  • 사본 ml_ck_<name>(DP-P7): ! 본문과 다른 사본이 부르고, -3은 호출 자리에서 try처럼 전파된다(DP-P4). 사본이 사본을 불러 깊이에 제한이 없다.
  • 참조되는 본문만(DP-P8): 평범한 본문은 ! 본문과 사본만 부를 때에만 빠진다 — 이 슬라이스가 닿지 않는 모듈의 생성 Rust는 글자 그대로 같다(생성 Rust 골든 불변).
  • Cx { abi, checked } — 모듈 수준 집합을 반환 모양과 함께 넘긴다(전역 상태 없음). 이 기계적 변경이 방출 텍스트를 바꾸지 않음을 Grok이 확인했다.
  • DP-O7 고정 테스트를 새 규칙으로 뒤집었다. 지문·ABI 불변(DP-P9). 헤더·유닛 골든은 주석 문구만 바뀐다(IFACE_HASH 0줄).
  • 문서: LANGUAGE.md · HOST_ABI.md · SPEC 상태 · 색인 · STATUS · reserved.rs 머리 주석(feat(codegen): one name, one body — split every export into a body and an adapter #101 이후 낡음 — Grok UNASKED).

근거 (E2)

  • 전체 게이트(세 게이트 require) exit 0, 바이너리 81개. fmt · clippy -D warnings · doc_claims 50/50 · language_gaps 9/9.
  • 새 테스트: 오라클 7(세 반환 모양 · 깊이 3 · bool/f64 · export 호출 대상 · 단락과 순서 · 이름 무충돌 · 무한 호출자의 wrap·포화), 컴파일러 3(바인딩 술어 · 방출 범위 · 지문), -D warnings 빌드 1, 바인딩 행렬 1행.
  • 결함 심기 7/7 적발(커밋된 트리, --no-fail-fast): 사본으로 안 부름 · 자기 본문만 보는 술어 · export 제외 · 평범한 본문 모두 유지 · 사용자 이름공간 안의 사본 이름 · 사본이 사슬을 안 탐 · 직접 호출만 도달. 이름 충돌 심기는 처음에 값 테스트를 통과했다 — 평범한 본문이 전부 빠져 충돌할 것이 없었다 → 무한 호출자를 더해 테스트를 강화했고 E0428로 떨어지는 것을 확인했다(624f7b6).

Grok (한 번에 주장 하나)

  1. ir.rs 집합·술어·걷기 — CONFIRMED
  2. codegen 라우팅·사본·평범한 본문 규칙 — CONFIRMED
  3. Cx 리팩터가 호출 자리의 abi를 하나도 바꾸지 않음 — CONFIRMED
  4. 바인딩 한 술어·주석 ASCII·IFACE_HASH 불변 — CONFIRMED
  5. 문서 ↔ 테스트 — DISCREPANCY: 호스트 호출의 포화가 헬퍼 쪽에서 재지 않았다 → 단언 추가(b3fbf64). (헬퍼 경로 선언은 컴파일러 쪽 테스트가 이미 단언한다.)

남은 것 (작업 2)

예제에 헬퍼를 넣어 실제 C 호스트가 -3을 받는 수용 F · §9-71의 626행 재측정 · 슬라이스 닫기.

🤖 Generated with Claude Code

xzawed and others added 3 commits September 26, 2026 20:09
…call path decides

SPEC-helper-check-propagation §6 task 1 (DP-P1..P11, user-confirmed 2026-09-26).

Arithmetic a fallible body executes is checked wherever it is written. ir::checked_helpers
is the one set: infallible functions (exported included, DP-P2) reached from a fallible
body through infallible calls whose body or callees can overflow. Codegen gives each member
a checked copy `ml_ck_<name>` (DP-P7) and a fallible body calls it, propagating -3 where the
call stands (DP-P4); a copy calls its callees' copies, so any depth is covered. The plain
body is dropped only when nothing but fallible bodies and copies call it (DP-P8), so a module
this slice does not reach emits byte-identical Rust — the generated-Rust golden is unchanged.
The same set decides ML_ST_OVERFLOW in both bindings (DP-P6): the prototype returned -3
through a helper while neither binding named it. The Cx context carries the set alongside
the return shape instead of global state.

DP-O7 is reversed (DP-P10): the checked_arithmetic.rs line that pinned it now asserts -3.
Fingerprint and ABI version unchanged (DP-P9); header/unit goldens change only in the
comment wording. Docs: LANGUAGE.md, HOST_ABI.md, SPEC status, slice index, STATUS; the
reserved.rs header no longer says internal function names are emitted raw (#101).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…iding scheme can fail it

Planting copy names inside the user namespace (ml_fn_ck_<name>) passed the value test: every
function there was called only from a fallible body, so no plain body was emitted to collide
with. An infallible caller keeps them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…where HOST_ABI says it

Grok verify: the host-call saturation sentence had no helper-side assertion.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@xzawed

xzawed commented Sep 26, 2026

Copy link
Copy Markdown
Owner Author

⚠️ AI 리뷰가 완전 검증되지 않음 — 기본값이 적용됐습니다(비활성/API 키 없음/빈 diff). AI 배점은 측정값이 아니므로 총점을 부분 점수로 보세요.
ℹ️ 범용 검사기만 본 언어 포함: rust — 이 배포에서 해당 언어의 전담 분석기가 하나도 실행되지 않아, 다언어 범용 분석기 하나에만 기대었습니다. 그 규칙 밀도는 언어마다 편차가 큽니다 — 여기서의 만점은 "깨끗함" 이 아니라 "거의 검사 안 됨" 입니다 — AI 리뷰와 수동 검토로 보완하세요.

🔵 SCAManager 분석 결과

총점: 89/100 (등급 B)

점수 상세

항목 점수 만점
커밋 메시지 13 15
코드 품질 25 25
보안 20 20
구현 방향성 (AI) 21 25
테스트 10 15

@xzawed
xzawed merged commit 338140b into main Sep 26, 2026
2 checks passed
@xzawed
xzawed deleted the feat/helper-check-propagation branch September 26, 2026 11:42
xzawed added a commit that referenced this pull request Sep 26, 2026
…heck-propagation slice closes (§9-72) (#340)

* test(c-host): the helper path reaches a real C host, and the helper-check-propagation slice closes (§9-72)

- examples/basket.mls: the line total moves into an internal helper `line_total` with no `!`.
  The C host's existing overflow check now measures the helper path (acceptance F): the
  compiler before #339 answers status 0 with -2 for that input, today -3. Internal, so no
  IFACE_HASH line moves; only basket's generated Rust changes in the golden.
- 626 rows re-measured with the implementation: identical to the prototype on every row
  (acceptance I) — §9-71.3's table holds.
- SPEC closed banner and status; index row ✅; candidates: the slice leaves, `wrapping_*`
  builtins enter (DP-P10).
- Session wrap: 9-72.md, HISTORY stub, ▶ entry (6), entry (5) byte-identical to
  start-block-053.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs: §9-72.5 records this PR's four Grok rounds

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant