Skip to content

c.bzip2: complete registry facade, D243 capacity/of(param N), and zero-unsafe UAT (#3138) - #3656

Merged
ehartford merged 1 commit into
mainfrom
c-bzip2-facade-3138
Nov 27, 2026
Merged

ehartford merged 1 commit into
mainfrom
c-bzip2-facade-3138

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #3138.

Summary

Delivers a complete, source-cited registry facade for [email protected] (23 of 24 public functions presented safely; only BZ2_bzReadGetUnused stays raw, with its reason explained), along with two small mission-settled contract-language extensions (D243) and a zero-unsafe, zero-project-facade UAT exercising all three bzip2 APIs.

Changes

  1. Contract language (D243, delegated under D237):
    • buffer param P capacity param L [elements] (without inout): pairs a writable pointer P (*mut) with a by-value integer capacity L, rendering []mut u8 (or []mut T with elements) with pre-call count overflow checking and returning C's own return value (BZ2_bzread, BZ2_bzRead, gzread, read, etc.). Refuses *const pointers.
    • of R(param N): hosts a lend operation on resource R receiving self at parameter N (defaulting to parameter 0 when omitted), paralleling D209's drop/destroys/abandon f(param N) (BZ2_bzRead, BZ2_bzWrite).
    • Updated docs/spec/031_contract-language.md, docs/spec/016_ffi.md, and recorded docs/meetings/2026-11-27-D243-buffer-capacity-and-of-param.md.
  2. Facade renderer / Sema bugfixes surfaced by c.bzip2:
    • FacadeRender.facade_render_deps: skip buffer-paired, fixed, and discarded parameters (matching SemaFacade.facade_param_receives) so BZ2_bzReadOpen's void *unused buffer is not mistaken for an ambiguous *mut BZFILE (*mut c_void) resource parameter.
    • SemaFacade.apply_facade_dependency_effects: project parent parameter indices past omitted fixed/discarded/buffer_len parameters (BZ2_bzReadOpen / BZ2_bzWriteOpen have param 0 discarded before FILE *f at param 1).
  3. Registry facts & drafter (src/CiFacts.with, src/CiFacadeDraft.with):
    • Carry named pointer resources with positioned destroyers (drop/destroys F(param N)) or multiple resources over one C record (ReadStream, WriteStream beside BZFILEHandle over *mut BZFILE) and fn stanzas carrying of R[(param N)], buffer param ..., param N discarded, param N fixed ..., ok ..., returns static CStr, and lend.
    • Exclude functions claimed by named registry resources from auto-drafted producer/destroyer sets for the same C record.
  4. Complete registry/c/bzip2/facts.with + expanded UAT (uat/bzip2.uat, uat/fixtures/bzip2_main.with):
    • Covers Compressor/Decompressor (BZ2_bzCompressInit/Compress/End, BZ2_bzDecompressInit/Decompress/End), ReadStream/WriteStream (BZ2_bzReadOpen/Read/Close, BZ2_bzWriteOpen/Write/Close/Close64), BZ2_bzBuffToBuffCompress/Decompress, and BZFILEHandle (BZ2_bzread/write/error beside auto-proven BZ2_bzopen/bzdopen/flush/close and BZ2_bzlibVersion).
    • Removed the inline project contract from uat/bzip2.uat and expanded uat/fixtures/bzip2_main.with to exercise BZ2_bzBuffToBuffCompress/Decompress, Compressor/Decompressor stream loop, and WriteStream/ReadStream on a real file via CFile.fopen with zero unsafe.
  5. Tests:
    • Added test/behavior/behav_3138_buffer_capacity_and_of_param.with, test/compile_errors/err_3138_buffer_capacity_const.with, and test/compile_errors/err_3138_of_param_wrong_type.with.
    • Updated err_c_facade_buffer_capacity_no_inout.with and err_c_facade_buffer_inout_len_not_ptr.with for D243's settled diagnostics.

Verification

  • Fresh-project with get c.bzip2: facade bzip2: 24 functions, 23 presented safely, 1 raw (BZ2_bzReadGetUnused), bzip2 UAT passed.
  • Seed-driven battery and :release-checks pending (will be posted below before marking ready).

@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven verification on 30d2a0ab4:

  • Battery (WITH=$PWD/src/main with run tools/battery.with): GREEN (rc=0, wall=843s, verdict.with: out/battery/battery.log: rc=0 green; uat: bzip2 ... pass (6 steps, 2.4s)).
  • Release checks (WITH=$PWD/src/main ./src/main build :release-checks): GREEN (wall=597.7s, stage2 == stage3 over all 16 units, 6-target rt-bundle-fixpoint, all 8 wo-drift, EMIT-C OK, EMIT-C FIXPOINT).

@ehartford
ehartford marked this pull request as ready for review November 27, 2026 16:10
@ehartford
ehartford merged commit 3b652b8 into main Nov 27, 2026
1 check passed
@ehartford
ehartford deleted the c-bzip2-facade-3138 branch November 27, 2026 16:10
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.

Registry facade for c.bzip2 (compression): complete, reviewed, with a zero-unsafe UAT

1 participant