Skip to content

Document internal C API contracts and IR string equality conventions#229

Open
VelariumAI wants to merge 2 commits into
vercel-labs:mainfrom
VelariumAI:docs/internal-c-api-contracts
Open

Document internal C API contracts and IR string equality conventions#229
VelariumAI wants to merge 2 commits into
vercel-labs:mainfrom
VelariumAI:docs/internal-c-api-contracts

Conversation

@VelariumAI
Copy link
Copy Markdown

@VelariumAI VelariumAI commented May 23, 2026

Summary

Addresses #181.

This PR addresses #181 by documenting the internal C API contract vocabulary, pointer access effects, ownership/lifetime conventions, boundary expectations, and observed IR string equality behavior. It also records unresolved contract debt.

The change is documentation/comment-only.

What changed

  • Added internal C contract documentation under native/zero-c/docs/internal-c-contracts.md.
  • Documented contract vocabulary such as in, inout, out, opt out, sink, return owned, return borrowed, retains, no-retain, nullable, non-null, alias ok, and no alias.
  • Added targeted contract comments around public/internal C boundaries in zero.h.
  • Added targeted comments in checker.c for checker boundary behavior and source-backed AST annotation mutation.
  • Added targeted comments in ir.c for IR lowering, lookup helpers, string equality sites, ownership/copy behavior, and destructor behavior.
  • Documented why IR currently deals with strings based on observed source behavior.
  • Documented observed IR string equality as value equality where source shows strcmp, strncmp, or equivalent comparison.
  • Recorded unresolved follow-up questions with stable contract debt IDs.

Scope

This PR does not change:

  • compiler behavior
  • parser behavior
  • checker behavior
  • IR representation
  • code generation
  • function signatures
  • public CLI behavior
  • dependencies
  • lockfiles
  • build scripts

Validation

  • Confirmed the committed scope is limited to four documentation/comment files.
  • Confirmed the C diff is comment-only, with no executable code, declarations, signatures, includes, macros, or behavior changes.
  • Confirmed no local validation artifacts are included in the public repository.
  • Local validation passed using the native Zero CLI through a custom validation harness with strict scope separation, receipt capture, and independent review.

Notes

The IR string section intentionally documents current observed behavior only. It does not claim string interning, canonical symbolic identity, or future symbol-handle design. Those are recorded as follow-up design questions where appropriate.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@VelariumAI is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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