GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cluckwork/CONTRIBUTING.md at main · mforce/cluckwork

Expand file tree

/

CONTRIBUTING.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
292 lines (236 loc) · 14.7 KB
/

CONTRIBUTING.md

Copy path

File metadata and controls

292 lines (236 loc) · 14.7 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Contributing

Humans start here. Coding agents start at AGENTS.md, which is the canonical rule set — this file is the short human-facing path through it and links there rather than restating rationale.

Once per clone

git config core.hooksPath .githooks

Run this yourself: the agent guard refuses a core.hooksPath write from an agent. Enables three hooks: pre-commit (refuses a commit on main or in the shared checkout, a main worktree that has linked worktrees beside it, then runs unit tests for staged .NET changes and npm run typecheck for staged web/ changes), commit-msg (rejects a message release-please would silently drop from the changelog) and pre-push (refuses a push to main, a force push, and a push under another branch name, and warns when the Docs impact check would fail). Integration tests are deliberately excluded — Docker, slow; CI is the authority. Skip once with --no-verify.

In the shared checkout (a main worktree with linked worktrees beside it), pre-commit refuses commits. The agent guard (tools/agent-guard/git_guard.py) runs only inside agent harnesses; there it refuses git writes in the shared checkout (except git pull --ff-only on a clean main), git stash and shallow fetches anywhere, and the routes around the hooks (git push --no-verify, git config core.hooksPath, git send-pack, gh api writes to main's history or protection). For a deliberate commit there, put the override on that one command in your own shell:

GIT_GUARD_ALLOW_SHARED=1 git commit -m "…"

Never export it, or set it for a harness or Paseo: every agent started from that environment inherits it and loses these checks.

Local development

Prerequisites: .NET 10 SDK, Docker, Node 26+, Aspire CLI 17.0.

dotnet build Cluckwork.slnx compiles the Aspire AppHost, which takes its dashboard and orchestrator from an extracted Aspire CLI bundle: the one next to the aspire on PATH, else the one in ~/.aspire. The build does not check that bundle's version, so an older bundle left in ~/.aspire builds and runs silently. Put Aspire CLI 17.0 on PATH and run aspire setup once. To point the build at another bundle, set ASPIRE_HOME or pass -p:AspireCliBundlePath=<dir>. Only when no bundle exists at all does the build run dnx [email protected] setup itself. That fallback needs Microsoft's portable .NET SDK; a distro-built SDK fails it with ASPIRE009. CI is not affected: it fetches the bundle itself, or restores one cached under the same Aspire version, and checks its contents.

Before the AppHost builds in CI, .github/scripts/aspire-bundle-fingerprint.sh compares a SHA-256 over every file in the bundle except the root .leases/, including each file's execute bit, with the value in .github/aspire-bundle.fingerprint, and fails on any symlink or other non-regular entry. It pins DCP and the dashboard byte for byte, as the NuGet lock files did before Aspire 17. The CLI's own bootstrap code, which dnx runs before the check, is covered by NuGet's package signature verification, not by this fingerprint. The check runs only in CI, only on Linux x64, and never on local machines. On a Dependabot PR that bumps Aspire.Hosting.AppHost, CI's aspire-fingerprint job fingerprints a fresh download of the new bundle, and the Dependabot lockfix workflow pushes the value with the lock files. If that job left no usable value, the lockfix still pushes the locks and warns. When you bump Aspire by hand, or after such a warning, update the file in the same commit: the failing check prints the command that computes the new value. A Dependabot PR that changes the file is merged by the maintainer.

Frontend:

cd web
npm install
npm run dev        # http://localhost:5173, proxies /api to the API

API from the IDE / CLI — start just the database, then run the API (config comes from user-secrets, never files):

docker compose -f deploy/docker-compose.dev.yml up -d   # Postgres on :5432
dotnet run --project src/Cluckwork.Api

ASPNETCORE_ENVIRONMENT matters: unset means Production, which fails the boot against a plaintext local Postgres (the #261/#262 TLS floor).

First run on a fresh clone also needs a local JWT signing keypair — the API refuses to boot without one (the #510 key-boot-check guard) rather than serve traffic it can't sign or validate tokens for. Generate one and store it in the API's user-secrets, once per clone:

openssl genrsa -out /tmp/jwt-private.pem 2048
openssl rsa -in /tmp/jwt-private.pem -pubout -out /tmp/jwt-public.pem
dotnet user-secrets --project src/Cluckwork.Api set "Jwt:PrivateKeyPem" "$(cat /tmp/jwt-private.pem)"
dotnet user-secrets --project src/Cluckwork.Api set "Jwt:PublicKeyPem" "$(cat /tmp/jwt-public.pem)"
rm /tmp/jwt-private.pem /tmp/jwt-public.pem

This key is dev-only and never committed; a missing or empty Jwt:PublicKeyPem/Jwt:PrivateKeyPem fails the boot with InvalidOperationException: Jwt:PublicKeyPem is not configured (or PrivateKeyPem) rather than a vaguer failure later.

A fresh database has no admin user — base data is migration-baked, credentials never are. Provision one: first admin provisioning.

Aspire local stack: see Aspire local development to orchestrate Postgres, Redis, API and Vite locally. It is not a deployment path.

Aspire runs its own Postgres — separate container, separate volume, username postgres, and a generated password in the AppHost's user-secrets. It is a second database, not a view of the Compose one, and the two are kept on different ports on purpose so a stray localhost:5432 cannot mean both. Aspire injects its connection string into the api resource it launches and nowhere else, so a one-shot verb you run by hand (bootstrap-admin, seed, migrate) reaches the Compose database unless you pass ConnectionStrings__Default yourself — see form 4 and #565. Provision an admin once per database; neither knows about the other's.

Resetting the dev database

This resets the Compose database only. The Aspire stack keeps its own volume, cluckwork-apphost-postgres-pg18; wiping one leaves the other exactly as it was, which looks like the wipe silently failed. The Aspire reset is a different, guarded procedure — resolve the volume from the running resource, do not type that name from memory: Aspire local development § Persistence and reset.

Always wipe through Compose:

docker compose -f deploy/docker-compose.dev.yml down -v
docker compose -f deploy/docker-compose.dev.yml up -d

Do not docker volume rm a volume name from memory. The live volume is cluckwork-dev_cluckwork-dev-pg18, and an older …-pg volume may still be lying around from before the Postgres 18 bump — removing that one succeeds, prints the name back, and leaves the real database untouched, so a wipe can look like it worked when nothing happened.

You need a wipe (not a migration) if boot fails with 42P07: relation "Accounts" already exists. That database still carries the pre-squash migration history: the 34 migrations were replaced by a single InitialCreate, which EF then sees as pending and tries to apply over tables that already exist. Such a database cannot migrate forward — recreate it.

Tests

dotnet test Cluckwork.slnx    # integration tests spin up Postgres via Docker
cd web && npm test           # Vitest + Testing Library

Backend coverage is a separate, non-gating measurement: tools/coverage/collect.sh (report only, no threshold — #776).

Expectations, enforced at review like a missing feature:

  • every change under src/ ships with tests in the same PR;
  • every change under web/ ships with Vitest tests in the same PR;
  • every aggregate mutation bumps Version and gets a parallel-race integration test — see the Version bullet in src/AGENTS.md;
  • a new guard (a test whose job is to fail when someone later does the wrong thing) is mutation-checked before you claim it catches anything — docs/decisions/407-writing-a-guard.md.

Changing the database schema

Add a migration. Never edit InitialCreate.

# Against the local dev Postgres. The connection is fail-closed (#318): there is
# no default, and every target is held to the same TLS floor as a Production
# boot — the loopback opt-out below is what permits plaintext, and only for
# localhost/127.0.0.1/::1.
CLUCKWORK_MIGRATIONS_CONNECTION='Host=localhost;Port=5432;Database=cluckwork;Username=…;Password=…' \
CLUCKWORK_MIGRATIONS_ALLOW_INSECURE_LOOPBACK=true \
  dotnet ef migrations add <Name> \
  -p src/Cluckwork.Infrastructure -s src/Cluckwork.Api

EF never re-runs an applied migration, so a column hand-folded into InitialCreate silently does not exist on any booted database. It surfaces as broken behaviour — a failing login, a missing field — not as a migration error, which is what makes it worth a rule. InitialCreate is also not regenerable: it carries four lower("Name") expression indexes EF cannot model plus the guarded reference-data SQL, and re-adding it mints a new timestamp that desynchronises __EFMigrationsHistory everywhere. MigrationSecurityReviewTests fails if it stops being the first migration or loses its recorded id.

Same PR: regenerate the schema docs (tools/schema-docs/generate.sh) and commit them — CI runs generate.sh --check and fails a stale PR (#417).

Full reasoning: docs/decisions/407-migration-freeze.md.

Branches and PRs

  • main is protected. Branch, push, open a PR — never commit to main.
  • Branches: feat/…, fix/…, chore/…, docs/…, spec/…. PRs squash-merge.
  • The PR body is prefilled from pull_request_template.md. Delete lines that do not apply rather than ticking them.
  • Keep the phase epic in sync: a new slice issue goes on the epic's checklist (epic #14 = Phase 1.1, #15 = Phase 1.5); tick it when the PR merges. Milestone assignment alone is not enough — the epics are how work is navigated.

Commit messages

Conventional Commits. Subject: type(scope): summary, lowercase type, no space before the colon. The scope is free-form — the area touched.

type changelog section example
feat Features feat(eggs): make cracked and dirty eggs sellable stock via condition grades
fix Bug fixes fix(sales): reject fractional order-line quantities
perf Performance perf(reports): stream the CSV export instead of buffering it
refactor Refactoring refactor(api): extract service registration from Program
docs Documentation docs(agents): record the guard-writing rules #407 paid five rounds for
deps Dependencies deps(web): Bump the production-minor-patch group in /web with 6 updates
ci hidden ci(e2e): workflow_dispatch job for the Playwright smoke suite
test hidden test(e2e): Playwright smoke suite for the SPA over the #243 sim fixture
build hidden build(deps): bump Npgsql to 10.0.2
chore hidden chore(web): drop the unused date-fns dependency
style hidden style(web): apply Prettier to the untouched settings screens

Commit types choose only the changelog section; the version comes from the branch you release from (docs/releasing.md). Add ! to the PR title for a breaking change — feat(api)!: drop the v0 endpoints. It marks the changelog entry and moves no version digit. Hidden types stay out of the changelog text.

PRs squash-merge with the PR title as the commit subject and an empty body. A plain BREAKING CHANGE: or Release-As: footer written in a branch commit or the PR description is dropped. Text reaches the commit body only when typed at merge time (gh pr merge <N> --squash --body "…" or the squash dialog's extended description). Separately, release-please's commit-override block in the PR description replaces the message release-please parses for that commit; the git commit itself keeps only its subject (see Forcing a version).

Two traps, both producing a green run with no changelog entry:

1. The PR title is the release note. It is always the squashed subject, and no local hook can see it. A non-conventional title silently drops the entry.

2. In text typed at merge time, a line starting with word( that has another ( inside it breaks the parser — and an unparseable commit is dropped entirely, not just that line. Two commits have already been lost this way. Backticks do not protect it:

Assert.Single(AllMigrations())      ← breaks the parser
  Assert.Single(AllMigrations())    ← fine (indented)
- Assert.Single(AllMigrations())    ← fine (list item)
see Assert.Single(AllMigrations())  ← fine (word in front)

Only line starts matter, so see foo(x) and bar(y()) mid-sentence was never a problem. .githooks/commit-msg catches this in your branch commits and prints the rewrite, but those messages no longer reach main; it cannot see a PR title or text typed at merge time.

Reviewing

Block on these like a missing test:

  • a hardcoded credential, in application or test code (GitGuardian scans PRs);
  • a hardcoded hosting-provider name in code, config, or a committed doc — see Host-agnostic repo in AGENTS.md;
  • a third-party Action pinned to a tag rather than a full commit SHA;
  • an aggregate mutation with no Version++;
  • a new Production boot guard that does not also update the sim harness (#370);
  • a user-visible change with no matching doc update — specs/product/GLOSSARY.md when a concept appears or changes meaning, plus the SPA Help page and in-app glossary.

Dependencies

  • NuGet versions live in Directory.Packages.props at the repo root (Central Package Management, #684); the .csproj files carry no Version=. Bump there, then dotnet restore Cluckwork.slnx.
  • A package add or bump commits the regenerated packages.lock.json in the same commit — CI restores --locked-mode and otherwise fails with NU1004.
  • A known-vulnerable production dependency fails CI. The only mute is a dated entry in .github/security-exceptions.json — see SECURITY.md.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.