Skip to content

Establish _contracts.dag sidecar convention + fail-closed hygiene gate - #5689

Closed
briansrls wants to merge 4 commits into
mainfrom
session/crisp-deer-391
Closed

briansrls wants to merge 4 commits into
mainfrom
session/crisp-deer-391

Conversation

@briansrls

@briansrls briansrls commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Establishes the *_contracts.dag sidecar convention for wire-contract declarations and adds a fail-closed hygiene gate that rejects misplaced declarations at CI floor discovery time.

What and why

CoproductWireContract and VariantEncoding data items (wire encoding declarations for coproduct serialization) previously lived inline in primary extdeps modules. This scatters serialization policy across business-logic modules and makes the convention implicit. This PR:

  1. Establishes the convention: wire-contract declarations must live in dedicated *_contracts.dag sidecar files (e.g. anthropic.dag → anthropic_contracts.dag).
  2. Adds a fail-closed gate (cli_run.rs): generalizes the existing _test.dag sidecar gate into a SIDECAR_PLACEMENT_RULES array that covers both _test.dag and _contracts.dag. discover_floor_corpus_rows returns Err if any .dag file outside its designated sidecar suffix contains guarded declarations — misplacement is a loud build error, never a silent pass.
  3. Migrates 7 primary modules: github, pulls, llm, anthropic, openai, container_inspect, systemd — inline wire-contract decls moved to their *_contracts.dag sidecars; primary modules import from sidecars where still needed.
  4. Wires the emitter: v1_compiler_emit_rust.rs fetches sidecar items/imports and passes them as the wire_context_items/wire_context_imports for wire_contract_item lookup and emit_coproduct_wire_contract_validations, so contracts in sidecars remain visible during emit. New contracts_items_for_module and contracts_imports_for_module helpers.
  5. Discriminating claim witness (contracts_placement_test.dag): 4 test fn claims verify sidecar items resolve and compare correctly (coproduct field, VariantEncoding equality).

Test plan

  • cargo test -p v1-compiler sidecar_placement: 4 unit tests all ok (scan detects CoproductWireContract/VariantEncoding; ignores non-wire-contract; misplaced decl drives discover_floor_corpus_rows to Err with correct message).
  • cargo test -p v1-compiler floor_corpus_every_lens_is_justified: ok — gate does not fire on the now-correctly-structured corpus (54s run).
  • cargo check -p v1-compiler: clean.

Brian Searls and others added 2 commits June 23, 2026 23:24
Establishes the convention that wire-contract declarations
(CoproductWireContract and VariantEncoding data items) must live in
dedicated *_contracts.dag sidecar files, not inline in primary modules.

Changes:
- cli_run.rs: generalize the existing _test.dag sidecar gate into
  SIDECAR_PLACEMENT_RULES covering both _test.dag and _contracts.dag;
  discover_floor_corpus_rows now returns Err on any misplaced wire-contract
  decl; 4 unit tests (scan + misplaced-drives-Err discriminating test)
- v1_compiler_emit_rust.rs: wire_contract_item lookup falls back to the
  *_contracts sidecar module; emit_coproduct_wire_contract_validations
  receives wire_context_items/imports (primary + sidecar) so CoproductWireContract
  rows in sidecars are visible during emit; new contracts_items_for_module
  and contracts_imports_for_module helpers
- New *_contracts.dag sidecar files for 7 modules (github, pulls, llm,
  anthropic, openai, container_inspect, systemd) with wire contracts moved out
- Primary modules updated to import from their sidecars; inline decls removed
- contracts_placement_test.dag: discriminating claim witness verifying
  sidecar items resolve correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gunbai-bot
gunbai-bot Bot marked this pull request as ready for review June 23, 2026 23:32
@gunbai-bot

gunbai-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Superseded by #5654 (session/gentle-wren-161). Both PRs independently arrived at identical designs: same 7 _contracts.dag sidecars, same SIDECAR_PLACEMENT_RULES + emit_discovery approach in cli_run.rs, same contracts_placement_test.dag. gentle-wren's PR has both tests green and review findings addressed; this one does not.

@gunbai-bot gunbai-bot Bot closed this Jun 24, 2026
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