Skip to content

feat(contract): wire 1.6.0, build_options in env_file (cli#471 D3) - #522

Merged
apotema merged 2 commits into
mainfrom
feat/contract-build-options
Oct 1, 2026
Merged

apotema merged 2 commits into
mainfrom
feat/contract-build-options

Conversation

@apotema

@apotema apotema commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of #471 (§3 "Contract 1.4" row, decision D3). Wire numbers 1.4 and 1.5 went to other features, so this ships as 1.6.0, an additive minor.

What

  • build_options: a target owner's before generate / before build hook may put build_options: [{"name": "...", "value": "..."}] in its env_file.
  • Where they go: the CLI appends them as -D<name>=<value> to every zig build the environment reaches: the fingerprint pass, the core compile and watched rebuilds. They come after its own arguments, in hook then list order. For example: zig build -Doptimize=ReleaseFast -Ddevice=true.
  • Why: this is how labelle-ios requests device builds (-Ddevice=true) without replacing the whole build.

Rules

  • Shape (checked when the file is read): identifier names [A-Za-z_][A-Za-z0-9_-]*, single-line values, no duplicate names. optimize and target are refused as CLI-owned.
  • Gating (checked when the hook's file is merged): only the target owner, only before generate/before build, only on a negotiated wire of 1.6.0 or newer. Anything else is an invalid env_file error naming the hook, even for an empty list.
  • Conflicts: two hooks giving different values, or an option the CLI's argv already sets, is an error naming both.
  • --docker: unchanged. It already refuses contributing hooks.

Notes

  • A replace build hook stands in for the compile, so its owner's options reach only the fingerprint pass.
  • A change in options during a watched session does not force a restart; only environment changes do.

Tests

  • Unit tests for parsing, gating, wire gating, argv and conflicts.
  • A new e2e build-options section in provider_hooks_e2e.py: 81 invocations pass locally, with its pre-existing macOS --docker block skipped.
  • zig build test passes 13/13 steps (1160 tests).

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

A target owner's before-generate or before-build hook may put
`build_options: [{name, value}]` in its env_file. The CLI appends them as
-D<name>=<value> to every zig build the environment reaches: the
fingerprint pass, the core compile and watched rebuilds. They come after
its own arguments, in hook then list order. This is how labelle-ios asks
for -Ddevice=true (the RFC's D3), with no full build replacement.

- Shape: identifier names, single-line values, no duplicates. optimize and
  target are refused as CLI-owned.
- Gating: only the target owner, only before generate/build, only on
  negotiated wire >= 1.6.0. Anything else is an invalid env_file error
  naming the hook.
- Conflicts: two hooks giving different values, or an option the CLI's
  own argv already sets, is an error naming both.
- --docker keeps refusing contributing hooks.

The supported wire list gains 1.6.0. Fixtures, e2e version assertions and
the contract docs are updated, and there is a new e2e build-options
section.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: da088e9e-05ef-46c0-bd89-e5f5aab71e71

📥 Commits

Reviewing files that changed from the base of the PR and between 17e8dfc and 1ba80e9.

📒 Files selected for processing (17)
  • docs/provider-contract-v1.md
  • docs/provider-hooks.md
  • src/cli/pipeline/build.zig
  • src/cli/pipeline/rebuild.zig
  • src/cli/provider_contract.zig
  • src/cli/provider_dispatch_test.zig
  • src/cli/provider_env.zig
  • src/cli/provider_hooks.zig
  • src/cli/provider_hooks_env_test.zig
  • src/cli/provider_manifest.zig
  • src/cli/provider_run_outcome.zig
  • src/cli/runner.zig
  • test/provider_android_like_e2e.py
  • test/provider_dispatch_e2e.py
  • test/provider_hooks_e2e.py
  • test/provider_run_outcome_e2e.py
  • test/provider_targets_e2e.py

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Wire version 1.6.0 adds validated build_options contributions from eligible provider hooks. The CLI merges those options with its Zig arguments for fingerprint probes, core builds, and watched rebuilds. Contract documentation and tests now reflect the new version and contribution rules.

Changes

Provider build-option contributions

Layer / File(s) Summary
Wire version and contribution rules
src/cli/provider_contract.zig, src/cli/provider_manifest.zig, src/cli/provider_dispatch_test.zig, src/cli/provider_run_outcome.zig, docs/provider-contract-v1.md, docs/provider-hooks.md, test/provider_android_like_e2e.py, test/provider_dispatch_e2e.py, test/provider_hooks_e2e.py, test/provider_run_outcome_e2e.py, test/provider_targets_e2e.py
The contract advances to 1.6.0. Negotiation, hook eligibility, documentation, and version expectations now cover build-option support.
Validate and collect hook options
src/cli/provider_env.zig, src/cli/provider_hooks.zig, src/cli/provider_hooks_env_test.zig
Env-file parsing validates option names and values. The accumulator merges options in hook order and reports conflicts. Hooks that do not meet the owner, phase, or wire-version requirements are rejected.
Pass options to Zig builds
src/cli/pipeline/build.zig, src/cli/pipeline/rebuild.zig, src/cli/runner.zig, test/provider_hooks_e2e.py
Fingerprint probes, host compiles, and watched rebuilds use composed Zig arguments. End-to-end tests check option delivery and rejection cases.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ProviderHook
  participant HookProcessing
  participant OptionAccumulator
  participant FingerprintAndBuild
  participant Zig
  ProviderHook->>HookProcessing: Submit env_file with build_options
  HookProcessing->>OptionAccumulator: Validate and merge eligible options
  FingerprintAndBuild->>OptionAccumulator: Compose Zig arguments
  OptionAccumulator-->>FingerprintAndBuild: Return arguments with build options
  FingerprintAndBuild->>Zig: Run fingerprint probe and core build
Loading

Suggested reviewers: danielmurta

Merge Risk: ⚪ Minimal · up to 1ba80

No concrete merge-blocking issue is established. The build-option contribution rules and documented scope are consistent; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the wire 1.6.0 change, build_options behavior, validation rules, gating, conflicts, and test results. It directly matches the changeset.
Title check ✅ Passed The title clearly identifies the main changes: wire 1.6.0 support and build_options in env_file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T11:51:15.844775Z 1ba80e9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@opencode-agent

Copy link
Copy Markdown

User coderabbitai[bot] does not have write permissions

github run

@apotema

apotema commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c1481c250

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/provider_env.zig
pub const File = struct {
set: []const Var = &.{},
path_prepend: []const []const u8 = &.{},
build_options: ?[]const Var = null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Distinguish an omitted build_options key from null

Declaring this field as an optional slice makes std.json.parseFromSliceLeaky map both an omitted key and an explicit "build_options": null to null. Consequently, the later file.build_options != null validation is bypassed: malformed null values are accepted, and even hooks on older wires or hooks that do not own the target can include the otherwise-forbidden key without rejection. Use a representation that tracks key presence separately from its required array value.

Useful? React with 👍 / 👎.

std.json reads an omitted optional key and an explicit null alike, and
only a present key is gated (owner, step, wire). So {"build_options":
null} slipped past the gating. Refuse null at parse time: the key is
either absent or an array.
@apotema
apotema merged commit 99e85c0 into main Oct 1, 2026
4 checks passed
@apotema
apotema deleted the feat/contract-build-options branch October 1, 2026 12:00
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.

2 participants