Repository navigation
Description
The promise
A user who wants a C library from Conan types with get c.<lib> and uses the whole library from safe With: no unsafe, no project facade, no copying files out of the compiler repo, no compiler bugs in the first hour. Mission: "C interop is first-class ... without making the programmer become the build system."
What happened instead (2026-11-10 secret-shopper transcript, postal-mcp)
A user building an MCP server wanted libcurl and yyjson. with get c.libcurl presented 15 of 152 functions; the easy, header-list and multipart APIs stayed raw (#3111). Writing the facade by hand hit four grammar walls, three compiler bugs (#3112, #3113, #3114), a reserved word (error) as a field name, a representation trick to get a str's bytes, and refusals that did not say what to write instead. The user finished only by keeping raw calls behind a hand-written safe function.
Root cause
Facades come from inference at fetch time, and Law 4 rightly stops inference short of ownership and retention. The backstop that should carry a library the rest of the way, a reviewed registry facts file (§16.2b.15), exists for 2 packages (zlib, libxml2). And no test plays the user: "fetch a popular library, use it fully, safely".
Plan
- Measure: draft every library on the list and publish coverage and refusal reasons (child issue).
- Fix the grammar from the clustered refusals, before writing facades (child issues, one per gap).
- Fix the proof engine's misreads (child issues).
- One reviewed, complete facade per library in
registry/c/<lib>/, each with a UAT doing the library's canonical tasks in a fresh project with zerounsafe(one child issue per library). - UX:
with getreports what it delivered; refusals name the fix; idiomatic surfaces; secret-shopper UATs as a routine (child issues).
Children
Measure and report
- Facade coverage report: draft every library on the #3115 list and publish presented/raw counts and clustered refusal reasons #3116 coverage report across the list (do first)
-
with getmust say what it delivered: coverage on fetch, andwith facade report c.<lib>to explain the raw rest #3117with getprints coverage;with facade report - lib/facades/*.w (libcurl, sqlite3, sdl, zlib, bzip2) are unreachable from
with get: users copy them out of the compiler repo #3118 lib/facades/*.w reachable throughwith get
Facade grammar
- Facade grammar: a variadic case that is an out-pointer (
curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &long)) has no form #3119 variadic out-pointer case (getinfo) - Facade grammar: a retained pointer case cannot be a resource (
CURLOPT_HTTPHEADER: &HeaderList,CURLOPT_MIMEPOST: &Mimekept until the transfer ends) #3120 retained case that is a resource (HTTPHEADER, MIMEPOST) - Facade grammar: a producer whose resource parameter is NULL on creation and whose result is the head (
curl_slist_append(NULL, s)creates,curl_slist_append(list, s)appends) #3121 producer with a NULL resource param; append returning the head - Facade grammar: a producer taking an optional parent (
curl_mime_init(easy), NULL allowed since 7.87.0) is presented on the parent and collides with itsnew#3122 producer with an optional parent collides with the parent'snew - Modeled C: only the first callback case of a variadic contract infers its userdata type; a second pair (CURLOPT_HEADERFUNCTION after WRITEFUNCTION) fails 'cannot infer U' #3113 second callback pair: userdata type not inferred
- Modeled C: 'returns borrow Part from param 0' on a producer-less resource generates code naming undefined type BorrowedPart #3114 borrowed child resource with no producer generates an unknown type
Facade proof
- Facade proof: an opaque
typedef void CURLhandle is refused as "a pointer to no record", taking the whole libcurl easy API raw #3123 opaquetypedef void Thandle - Facade proof: "retains param 0" over-approximates a library storing its own handle in its own state (
curl_easy_cleanupreported as retaining the handle it destroys) #3124 self-state stores read as retention - Facade proof: a destroyer is reported as retaining what it frees (
curl_slist_free_all: "retains param 0 (stored in a global)") #3125 destroyer reported as retaining - Facade proof: a producer is refused through a parameter that may be NULL (
curl_mime_init(easy)→Curl_rand_alnum→random), leavingcurl_mime"destroyed but never produced" #3126 producer refused through a NULL-able parameter - Facade proof:
curl_versionreturns a static buffer it rewrites on each call; raw as "a pointer to no record" #3127 static text returns
Compiler bugs met in the first hour
- Bare 'mut self' on a dotted method (fn T.m(mut self, …)): field write is an ICE (invalid MIR), field read loses its type — #897 sibling #3112 bare
mut selfon a dotted method: ICE on a field write
Experience
- Facades present C's call shape: the user must learn "check every setopt against CURLE_OK", "declare the sink before the handle", "build the handle in a helper" from compile errors #3128 facades present C's call shape (setopt checks, sink order, helper rule)
- Facade refusals don't say what to write: an agent following the spec guessed the grammar for an hour #3129 refusals name the accepted spelling
- No safe way to hand a
str's bytes to a C(const void *, size_t)parameter: the user read the str header like std/regex.w does #3130 astr's bytes to a C buffer parameter;str.as_bytes() -
erroris a reserved word but only ever starts a declaration: make it contextual soerrorworks as a field, binding or parameter name #3131errorbecomes contextual - Audit §29.11's reserved words: every word that only opens a declaration becomes contextual (candidates: module, union, opaque, global, extend, select, spawn) #3132 audit the reserved words
- Secret-shopper UATs: an agent with only the docs builds a realistic program in a fresh project; every stumble is an issue, first-hour failures block the release #3133 secret-shopper UATs and the
first-hourrelease blocker - std.http rides std.tls, a hand-written TLS stack users won't trust with credentials: audit it or back std.http with a vetted engine #3134 std.http's TLS: audit or a vetted engine
Registry facades, one per library
- Registry facade for c.zlib (compression): complete, reviewed, with a zero-unsafe UAT #3135 c.zlib
- Registry facade for c.zstd (compression): complete, reviewed, with a zero-unsafe UAT #3136 c.zstd
- Registry facade for c.lz4 (compression): complete, reviewed, with a zero-unsafe UAT #3137 c.lz4
- Registry facade for c.bzip2 (compression): complete, reviewed, with a zero-unsafe UAT #3138 c.bzip2
- Registry facade for c.xz_utils (compression): complete, reviewed, with a zero-unsafe UAT #3139 c.xz_utils
- Registry facade for c.libarchive (archives): complete, reviewed, with a zero-unsafe UAT #3140 c.libarchive
- Registry facade for c.openssl (TLS and crypto): complete, reviewed, with a zero-unsafe UAT #3141 c.openssl
- Registry facade for c.libsodium (crypto): complete, reviewed, with a zero-unsafe UAT #3142 c.libsodium
- Registry facade for c.libcurl (HTTP): complete, reviewed, with a zero-unsafe UAT #3143 c.libcurl
- Registry facade for c.nghttp2 (HTTP/2): complete, reviewed, with a zero-unsafe UAT #3144 c.nghttp2
- Registry facade for c.libssh2 (SSH): complete, reviewed, with a zero-unsafe UAT #3145 c.libssh2
- Registry facade for c.sqlite3 (database): complete, reviewed, with a zero-unsafe UAT #3146 c.sqlite3
- Registry facade for c.libxml2 (XML): complete, reviewed, with a zero-unsafe UAT #3147 c.libxml2
- Registry facade for c.expat (XML): complete, reviewed, with a zero-unsafe UAT #3148 c.expat
- Registry facade for c.libyaml (YAML): complete, reviewed, with a zero-unsafe UAT #3149 c.libyaml
- Registry facade for c.yyjson (JSON): complete, reviewed, with a zero-unsafe UAT #3150 c.yyjson
- Registry facade for c.cjson (JSON): complete, reviewed, with a zero-unsafe UAT #3151 c.cjson
- Registry facade for c.pcre2 (regex): complete, reviewed, with a zero-unsafe UAT #3152 c.pcre2
- Registry facade for c.libpng (images): complete, reviewed, with a zero-unsafe UAT #3153 c.libpng
- Registry facade for c.libjpeg-turbo (images): complete, reviewed, with a zero-unsafe UAT #3154 c.libjpeg-turbo
- Registry facade for c.freetype (fonts): complete, reviewed, with a zero-unsafe UAT #3155 c.freetype
- Registry facade for c.harfbuzz (text shaping): complete, reviewed, with a zero-unsafe UAT #3156 c.harfbuzz
- Registry facade for c.sdl (windows and input): complete, reviewed, with a zero-unsafe UAT #3157 c.sdl
- Registry facade for c.glfw (windows and input): complete, reviewed, with a zero-unsafe UAT #3158 c.glfw
- Registry facade for c.raylib (games): complete, reviewed, with a zero-unsafe UAT #3159 c.raylib
- Registry facade for c.libuv (event loop): complete, reviewed, with a zero-unsafe UAT #3160 c.libuv
- Registry facade for c.libevent (event loop): complete, reviewed, with a zero-unsafe UAT #3161 c.libevent
- Registry facade for c.libgit2 (git): complete, reviewed, with a zero-unsafe UAT #3162 c.libgit2
- Registry facade for c.protobuf-c (serialization): complete, reviewed, with a zero-unsafe UAT #3163 c.protobuf-c
Umbrella for the libcurl case: #3111 (its grammar gaps and proof observations are split out above).
Activity
ehartford commentedon Nov 9, 2026
Measurement done (#3116)
tools/facade_coverage.wdrafted the whole list; the table isdocs/spec/toolchain/facade-coverage.md(regenerate withwith build :facade-coverage). 20 of 29 libraries produced a facade: 7279 functions, 1768 presented safely (24%). raylib 66%, zlib 30%, libxml2 22%, sdl 22%; libcurl 9%, sqlite3 11%, libuv 8%, pcre2 7%, freetype 5%, libyaml 1%; cjson, libpng and harfbuzz near 0 for infrastructure reasons.Issues from the survey, to add to the checklist:
Fetch and read infrastructure
c.nghttp2does not resolve; Conan's name is libnghttp2 (name the near match)with getthen roots the project at a relative path and CMake refuses the relative compiler path #3166 (fixed in the Facade coverage report: draft every library on the #3115 list and publish presented/raw counts and clustered refusal reasons #3116 stack) a child spawned with a relative cwd got a relative PWDClusters of raw verdicts (function counts across the 20 drafted libraries)
curl_versionreturns a static buffer it rewrites on each call; raw as "a pointer to no record" #3127 static text returns (307*const c_char), Facade grammar: a variadic case that is an out-pointer (curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &long)) has no form #3119 out-pointers (185 scalar pointer params, 179 scalar pointer returns, 51 + 30 pointer-to-pointer), Facade proof: an opaquetypedef void CURLhandle is refused as "a pointer to no record", taking the whole libcurl easy API raw #3123void*(121 params, 103 returns), Facade proof: "retains param 0" over-approximates a library storing its own handle in its own state (curl_easy_cleanupreported as retaining the handle it destroys) #3124 self-state stores (564 "stored in a field")Not drafted on this host, by D171 (not a bug): zstd, lz4 (non-CMake), libarchive→libiconv (autotools), openssl and libgit2→openssl (Perl).
#3116: tools/facade_coverage.w drafts every library on the #3115 list…
ehartford commentedon Nov 9, 2026
Survey rerun on main 6d478f1 (docs/spec/toolchain/facade-coverage.md, #3201): 22 of 29 libraries drafted, 7607 functions, 1798 presented (23%). Since the first table: cjson 1 → 79 functions read (#3167), xz_utils 16 → 26 presented, libxml2 316 → 320, libarchive 111 → 112, libcurl 15 → 16, expat and libjpeg-turbo drafted for the first time, yyjson 9 → 4 (its allocator field no longer taken for malloc by name: Law 4, see #3150/#3151 for the registry convention both need). Fixed on the way: #3165 #3166 #3167 #3170 #3171 #3172 #3179 (2 of 3) #3187 #3195; #3175 is in PR #3200. Still no facade for zstd and lz4 (non-CMake), openssl and libgit2 (Perl), libsodium and protobuf-c/abseil (recipe index has no folder for the version), nghttp2 (the name is libnghttp2).
ehartford commentedon Nov 9, 2026
Survey on main 4cf358b (table refreshed): 22 of 29 libraries, 7863 functions, 1748 presented (22%). Gains: libpng reads (0 → 256, #3168), libxml2 320 → 330, libarchive 112 → 118, libcurl 16 → 18, libevent 57 → 59. Losses that are corrections: pcre2 6 → 0, libssh2 10 → 3, sdl 549 → 493, yyjson 4 → 1 — those rested on a struct field named
free/mallocor a dispatch field named like a function (Law 4). The two largest gaps now: #3206 calls through function-pointer fields (1648 functions, 14 libraries; needs a ruling) and #3173 caller-allocated structs by pointer (1538, 21 libraries; grammar). Fixed since the last note: #3168, #3174 (wording), #3175 (2 shapes), #3176 (wording), #3205 (attributes from the AST, malloc-annotated allocators).ehartford commentedon Nov 18, 2026
Measured 2026-11-18 on darwin-aarch64 (main plus the survey fix): what a program gets from
with get c.<lib>.By default every library that fetched arrives as a Conan Center binary. Under §31.8.5 ('the build that was proved') the proofs over its separately configured source are evidence and grant nothing. Across 22 libraries a program is presented 13 functions: zlib 3 and libxml2 10 (registry lines), 0 for every other library. The source evidence for the same 22 says about 1,816 would be presentable.
With
with get --from-source c.<lib>(the build the proofs count for), 25 libraries tried:libnghttp2Total presented from source: 1,239 functions in 16 libraries, against 13 by default.
So proof-engine work (#3173, #3174, #3175, #3176, #3178) reaches a program only for a library built from source or one with registry lines. The published coverage document (2026-11-10) predates the prebuilt-binary rule and shows the from-source numbers.
ehartford commentedon Nov 24, 2026
Labelled
blocked: the epic moves through its children, and the open ones each wait on a ruling stated on the child: the libcurl set under #3111 (#3119, #3120, #3121, #3122, #3124), the proof rules (#3174 with #3176 and #3206, #3175), and #3132 (the reserved-word list). #3173 (caller-allocated structs) and #3128 (the call shape facades present) are the two children still being worked without a ruling outstanding.