Skip to content

feat: contract namespace reduce scripts in user repo adoption - #8

Open
ttschampel wants to merge 5 commits into
mainfrom
f/namespace-no-scripts
Open

feat: contract namespace reduce scripts in user repo adoption#8
ttschampel wants to merge 5 commits into
mainfrom
f/namespace-no-scripts

Conversation

@ttschampel

Copy link
Copy Markdown
Collaborator

Summary

Contracts

  • Implements: CONTRACT:___ (new implementation)
  • Modifies behavior of: CONTRACT:___ (check contract still holds)
  • New contract: architecture/CONTRACT-___ (requires plan mode review)
  • No contract impact (refactor, docs, tests only)

Checklist

  • Every new/modified source file has a CONTRACT: header comment
  • Contract references point to existing files (./scripts/check-contract-refs.sh)
  • No untracked TODO: comments (./scripts/check-todos.sh)
  • Tests pass at T2+ (package-level or higher)
  • Docs updated if behavior changed (QUICKCONTEXT, TODO, relevant READMEs)

Test Plan

  • T1 — targeted test(s): ___
  • T2 — package suite: ___
  • T3+ — cross-package / full suite

setup-rebar.sh now accepts a version positional arg and installs to
~/.rebar/versions/<version>/ with a 'current' symlink.

- Release tags (vX.Y.Z): download prebuilt binary from GitHub Releases,
  fall back to source build if no binary for this platform
- Branches / dev refs: clone repo and build from source with version
  injected via ldflags
- Multiple versions coexist; projects pin via .rebar-version
- curl pipe: bash -s -- v3.0.0-beta.2
…d logic

pre-commit.sh calls `rebar check --pre-commit`.
ci-check.sh calls `rebar audit`.

All enforcement logic lives in the rebar binary (sourced from the rebar
installation), not in scripts copied into adopting repos. Adopting repos
no longer carry embedded copies of rebar's check internals; upgrading
rebar upgrades enforcement automatically without any script sync.

Removed 23 scripts from templates/project-bootstrap/scripts/ that were
duplicating logic from the rebar install. The two remaining entry-point
scripts (pre-commit.sh, ci-check.sh) are the only surface adopting repos
need to carry.
config.go: add ContractNamespace field, read from contract_namespace key
in .rebarrc. Existing repos without the key are unaffected (zero value).

steward.sh: replace literal CONTRACT:<id> grep with an extended-regex
pattern that matches both legacy (CONTRACT:<id>.<v>) and namespaced
(CONTRACT:<ns>:<id>.<v>) references. Repos in transition between forms
are scanned correctly without any changes to source files.

.rebarrc template: add contract_namespace as a commented-out example
with an explanation of the legacy vs namespaced forms and when to use it.

No migration required. Both reference forms remain valid indefinitely.
Both architecture/CONTRACT-TEMPLATE.md and
templates/project-bootstrap/architecture/CONTRACT-TEMPLATE.md updated:

- Title: CONTRACT-{NAMESPACE}:{NAME}.{MAJOR}.{MINOR}
- Naming comment: explains filename (unnamespaced) vs title vs in-source
  reference, and when to use legacy vs namespaced form
- VERSIONING comment: superseded-by/supersedes use namespaced form
- Dependencies: example CONTRACT: ref uses {NAMESPACE}:{NAME}
- Implementing Files: adds in-source header comment example; grep uses
  extended-regex pattern matching both legacy and namespaced forms
- Retirement: predecessor reference uses NAME + namespace-aware regex
- Companion File: filename example drops legacy C1-prefix
check --pre-commit now resolves the rebar installation via findRebarRoot()
and runs check-todos.sh + check-contract-refs.sh from there directly.
Project scripts/pre-commit.sh is a 7-line entry point only.

This eliminates:
- Circular chain: pre-commit.sh → rebar check → pre-commit.sh → ∞
- Enforcement logic in adoption repos (only entry point lives there)
- Stale logic when rebar upgrades (rebar home scripts update automatically)

Also fixes:
- setup-rebar.sh: REBAR_REPO env now used as clone URL in source builds
- init.go: findRebarRoot() marker changed to setup-rebar.sh (steward.sh
  was removed from templates/project-bootstrap/scripts/ in thin-scripts
  refactor, breaking framework detection for source installs)
- init.go: bootstrapV2Files() log message reflects thin-scripts count
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