Skip to content

docs: SPEC for checked integer arithmetic in fallible bodies, and Q17 for the input encoding contract - #333

Merged
xzawed merged 2 commits into
mainfrom
docs/spec-checked-arithmetic
Sep 26, 2026
Merged

xzawed merged 2 commits into
mainfrom
docs/spec-checked-arithmetic

Conversation

@xzawed

@xzawed xzawed commented Sep 26, 2026

Copy link
Copy Markdown
Owner

This PR is a draft SPEC plus an open question. There is no product code. The user confirmed the direction on 2026-09-26: design A+as from §9-69.2, and put the encoding question in OPEN_QUESTIONS.

docs/slices/SPEC-checked-arithmetic.md

Inside fallible bodies (-> T!, -> string!, -> [T]!), these operations fail with a new reserved status ML_ST_OVERFLOW = -3 instead of wrapping or saturating:

  • i32 + - * and unary -;
  • i32::MIN / -1;
  • f64 as i32 when the value is NaN or out of range.

Infallible functions keep today's semantics. That means the wrap decisions (DP-I4, DP-U4, the D2 row) and the saturation rule (§2.3) still hold for them.

Evidence (§0). This comes from the §7 measurements and the local design-A prototype (E2, 626 rows):

  • A+as turns 101 of 161 silent wrong answers into a status.
  • It falsely refuses 9 rows; only 1 of those is a realistic input.
  • It changes the behaviour of 0 existing oracle tests.

DPs. DP-O1 and DP-O2 are confirmed by the user. DP-O3 through DP-O9 await confirmation:

DP Question Proposal
DP-O3 Status value A new -3, not a reused -2
DP-O4 Fingerprint and ABI version Both unchanged
DP-O5 % MIN % -1 stays 0, the true remainder
DP-O6 Failure after result Same as -2: buffer undefined
DP-O7 Escape hatch No new one; infallible helpers already wrap
DP-O8 Migration No marker in the fingerprint or manifest
DP-O9 Overflowing literal or constant expressions Fail at run time, no constant folding

docs/OPEN_QUESTIONS.md Q17

Reopen DP-S2 (input string encoding)? It covers:

  • the CP949 measurement;
  • the EUC-KR counterexample (SMS/LMS limits are defined in EUC-KR bytes);
  • the fact that the recorded reopen condition was case-insensitivity or normalization, not this evidence.

It lists three options. The recommendation is (A) keep it open and document the hazard, awaiting confirmation.

Grok

Following the user's instruction, every call carried one claim and ran in parallel. All of them finished in 2 to 4 turns.

Plan gate, one call per DP:

Verify, 5 single-claim calls, all CONFIRMED:

  • checked_rem on MIN % -1;
  • the HOST_ABI status row covering failures after result;
  • the 312,949,672 arithmetic;
  • which DPs are confirmed versus proposed;
  • the Q17 text.

One unasked line found a gap: an overflowing literal-only expression was unspecified. It is now DP-O9.

Evidence: cargo test -p ml_oracle --test doc_claims --locked gives 50 passed.

Related: D17, D18, SPEC-i32 DP-I4, SPEC-unary DP-U4, SPEC-i32-division D2, SPEC-numeric-conversion §2.3, SPEC-array-return DP-R9, SPEC-fixed-decimals DP-M4, SPEC-string-input DP-S2, §9-69.

🤖 Generated with Claude Code

xzawed and others added 2 commits September 26, 2026 14:05
… for the input encoding contract

The user confirmed the direction (design A+as, §9-69.2) and asked for SPEC and the Q17 table.
SPEC-checked-arithmetic: in `!` bodies, i32 + - *, unary -, MIN/-1 and f64 as i32 fail with a
new ML_ST_OVERFLOW (-3); % keeps MIN % -1 = 0; fingerprint and ABI version unchanged; after
`result` it behaves like -2. DP-O3..O8 await confirmation; Grok's plan gate chose -2 for the
status at first, and its own verify then confirmed that -2 carries most of the same cost.
OPEN_QUESTIONS Q17: reopening DP-S2, with the CP949 measurement and the EUC-KR counterexample;
recommendation (A) keep it open, awaiting confirmation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… time, and names who confirmed

Grok's unasked line: the SPEC left open whether an overflowing constant expression in a `!`
body folds or fails. DP-O9: it fails at run time with -3; a compile-time diagnostic stays a
separate candidate. The two confirmed DPs now say the user confirmed them.

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 배점은 측정값이 아니므로 총점을 부분 점수로 보세요.

🔵 SCAManager 분석 결과

총점: 89/100 (등급 B)

점수 상세

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

@xzawed
xzawed merged commit 5b00fbf into main Sep 26, 2026
2 checks passed
@xzawed
xzawed deleted the docs/spec-checked-arithmetic branch September 26, 2026 05:18
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