Skip to content

D198 (§16.2b.5): the draft states reads, fills and updates param N from proofs; a drafted value record is flat - #3216

Merged
ehartford merged 2 commits into
mainfrom
value-records-draft
Nov 10, 2026
Merged

ehartford merged 2 commits into
mainfrom
value-records-draft

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

The drafter half of spec v7.43's 'Value records' (D198, #3173): with get writes the clauses itself, from proofs over the library's source. Two commits.

A clause is stated only when everything it depends on is read: the record is flat (no pointer anywhere inside it) and complete in a header the package installs; no function of the package produces, destroys or retains a pointer to that record type; the body keeps no pointer to the record or into it, touches only the one record (no index, no arithmetic, no part's address, no copy of the pointer), and passes it on only to package functions the same holds for. const T * is reads; T * written and never read is fills; any other T * is updates.

The flat rule is a safety condition beyond the spec's words, found on freetype (FT_Outline_Get_CBox follows outline->points); it is in the drafter only and surfaced to Eric on #3173.

The report says 'value records: reads param 0 (proof: …)' or, for a record pointer left raw, which condition failed; the survey tool clusters that reason.

Checked end to end: the facade block the drafter wrote for the fixture's library compiles and runs as a program (12 20 40 4 5).

Fixture: conan_facade_value_record_draft_test. Battery GREEN on 4bc10be (with run tools/battery.w in ~/.local/with-staging/vdraft, wall 448 s after a green gate and internals lane; GREEN BATTERY_DONE).

Eric Hartford added 2 commits November 9, 2026 22:30
… N` from proofs over the library's source

A draft states a value-record clause only when everything it depends on
is read (D198). CImport.w records how each body uses a pointer
parameter (ci_value_record_evidence): a write through it, a read
through it, the parameter passed on, and anything that leaves the one
record or keeps a pointer (an index, pointer arithmetic, the address of
a part, a copy, a store, a return). The scan records where each record
is complete, and `with get` keeps those a header the package installs
defines. CiFacadeDraft.w draws the records with identity (some function
produces, destroys or retains a pointer to one: zlib's z_stream) and
gives a parameter its word (fd_value_record_word): the record is
complete in an installed header and has no identity; the body keeps no
pointer to it or into it and touches only the one record; it is passed
on only to package functions the same holds for. `const T *` is
`reads`; `T *` written and never read is `fills`; any other `T *` is
`updates`. The clause is written in the function's item with its proof;
an operation over value records alone states no `lend`.

The report says 'value records: reads param 0 (proof: …)' and, for a
record pointer left raw, which condition failed. The survey tool
clusters that reason.

Fixture: conan_facade_value_record_draft_test (each word; an indexed
array, a part's address, a retained pointer and a record with identity
stay raw).
A record with a pointer in it is not one record to the callee:
freetype's FT_Outline_Get_CBox(const FT_Outline *) follows
`outline->points`, and whoever builds the record chooses where that
points, so presenting it as `&FT_Outline` would let a safe call read
arbitrary memory. The body evidence saw only a read through the
parameter. The draft now states a clause only for a record that is
complete in an installed header and flat: arithmetic types and enums,
fixed arrays of such, and defined records made only of such
(ci_type_is_flat). A hand-written facade's clause remains the author's
assertion (§16.2b.5); this is the limit of what a draft can prove.

The report's reason reads '<Record> is not a flat record complete in a
header the package installs (it holds a pointer, or is opaque there)'.
Fixture: span_first (a record holding a pointer stays raw).
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