Skip to content

build: build.rs rewrites tracked gen/ every build vs no-gen-edits hook — self-contradictory (R1) #101

Description

@gHashTag

Diagnosis (cross-repo refactor R1)

origin/main builds cleanly (cargo build --lib → Finished; verified at f79cde3 in a clean worktree with no ../t27, so build.rs skips regen). So this is a workflow contradiction, not a broken committed tree.

The contradiction:

  1. build.rs — on every cargo build, if ../t27/target/release/t27c exists and a specs/*.t27 is newer than its gen/rust/<name>.rs, it runs t27c gen-rust and overwrites the tracked file in the source tree. Any dev who has t27c built gets a dirty gen/ after a plain build.
  2. lefthook.yml no-gen-edits — hard-blocks committing any gen/ change (exit 1, "VIOLATION L2").
  3. src/lib.rs includes gen via #[path = "../gen/rust/X.rs"], so gen/ must be committed to build on a clean clone (build.rs returns early when t27c is absent, e.g. CI/fresh clone).

Net: the build silently dirties gen/, but that dirt can never be committed — while the architecture requires gen/ to be committed. The three rules can't all hold.

Why it looks worse than it is right now

The feat/regen-final branch has a large in-progress refactor (lib.rs 9 → 106 gen modules, ~50 untracked gen/rust/*.rs, 20+ specs). That WIP tree compiles locally but a clean clone of it would miss ~31 referenced modules. That is the refactor's transient state, not a defect to fix here — this issue is only about the structural build.rs/hook contradiction, which persists after the refactor lands.

Options (maintainer's call — deliberately not changed mid-refactor)

  1. Commit gen/ as tracked generated artifacts (current de-facto model) + change no-gen-edits from hard-block to advisory (a git hook can't distinguish faithful regen from hand-edit), and gate build.rs regeneration behind an explicit TRINET_REGEN=1 so plain builds stop dirtying the tree. CI enforces regen && git diff --exit-code.
  2. Treat gen/ as pure build output: .gitignore gen/, always generate into OUT_DIR, require t27c on every build. Bigger change; breaks clean-clone builds without t27c.

Not touching code while feat/regen-final is live. Note: #58 ("main не собирается") appears stale — origin/main builds.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions