The section tells you promotions are fast-forward-only and never says which tool does that. `tea pr merge` does not: it offers merge, rebase, squash and rebase-merge, and each one births a commit on main — the exact drift the rule exists to prevent. Reaching for the obvious command therefore produces the thing the paragraph above it forbids. Gitea's API takes the style the CLI omits, so the promotion for 26.9.0-beta.2 went through curl. Recording the call, and the 405 that precedes it: main is protected and a promotion PR runs its own checks rather than inheriting the ones develop already passed, so the first attempt is refused for checks that simply have not finished yet. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
153 lines
12 KiB
Markdown
153 lines
12 KiB
Markdown
# AGENTS.md
|
|
|
|
Guidance for AI coding assistants working in this repository. Claude Code, Codex, Cursor and anything else that reads this file.
|
|
|
|
If you are an assistant: a person reads every line of what you produce before it lands, and the person submitting it signs off on it. Make that reading worth their time — leave the reasoning visible, don't quietly widen the scope you were asked for, and say what you were unsure about instead of smoothing over it. The "Working with AI assistance" section of `CONTRIBUTING.md` applies to your output.
|
|
|
|
## What this is
|
|
|
|
`@green-tea/core` — a type-safe HTTP framework where the API is a dependency graph rather than a middleware chain. You declare what each step needs and provides; the framework computes execution order, fails at boot if something is missing, and can print the whole pipeline. Runs on Node, Deno, Bun and the edge from one codebase.
|
|
|
|
**Hard constraint: one runtime dependency.** `reflect-metadata`, and nothing else. `busboy` and `ws` are peer dependencies. Anything that would add a third belongs in a plugin, not in core.
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
npm run lint # eslint
|
|
npm run format:check # prettier, src/**/*.ts only
|
|
npm run typecheck # must be clean; includes the compile-time-guarantee type test
|
|
npm test # vitest
|
|
npm run build # tsup
|
|
npm run complexity:check
|
|
|
|
npm run test:deno # the other runtimes are NOT covered by `npm test`
|
|
npm run test:bun
|
|
npm run test:edge
|
|
```
|
|
|
|
Run the first four before proposing anything as finished. The runtime suites stay separate commands on purpose — a change to shared code that passes `npm test` may still be broken on Deno or Bun — but they are no longer optional: CI runs all three on every push and each one gates a merge. Run them yourself for anything touching `src/http/`, the adapters, or `src/mesh/`, rather than finding out from CI.
|
|
|
|
## Two forges
|
|
|
|
Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main` and `develop` automatically — `develop` under the name `contrib` — and release tags only by hand.
|
|
|
|
```
|
|
feature/* → develop → main → [promote.yml] → GitHub main
|
|
│ │
|
|
└─[promote.yml]┼──→ GitHub contrib ← external PRs
|
|
↑ │ │
|
|
└── carried back by hand ─┘ (a PR into develop)
|
|
│
|
|
v* tag ────┴─── Gitea: [stage.yml] → Verdaccio
|
|
└─── GitHub (pushed by hand): [release.yml] → npm + JSR
|
|
```
|
|
|
|
- **Gitea `develop`** — active development.
|
|
- **Gitea `main`** — staging. Merging here publishes nothing. A `v*` tag here publishes to the internal Verdaccio, never to a public registry.
|
|
- **GitHub `main`** — production mirror. No human touches it. Protected against force-push and deletion, with no review requirement, because `promote.yml` pushes to it directly and a review rule would block that.
|
|
- **GitHub `contrib`** — mirror of `develop`, pushed by `promote.yml` on every develop merge, and where outside contributions land. GitHub only: there is no Gitea `contrib`.
|
|
|
|
`develop` and `main` on Gitea have direct push disabled with an empty whitelist, so nobody can push to them, admins included. Advance them by opening a PR and merging it.
|
|
|
|
## Procedure
|
|
|
|
**Promotions are fast-forward-only.** `develop → main` merges with Gitea's fast-forward-only style, so `main` becomes an exact copy of `develop` and no commit is ever born on `main`. This is not a preference: merge-style promotions created seven of the ten commits of drift that had to be cleaned up in August 2026, because each one lived on `main` and never travelled back. Release boundaries are marked by `v*` tags, not by promotion commits.
|
|
|
|
**Only `hotfix/*` can still cause real drift**, since it branches from and returns to `main`. That case genuinely needs a back-merge; nothing else does.
|
|
|
|
**`tea pr merge` cannot do the promotion.** The CLI offers `merge`, `rebase`, `squash` and `rebase-merge`, and every one of them births a commit on `main` — the drift this section exists to prevent. Gitea's API has the style the CLI lacks, so promote through it:
|
|
|
|
```bash
|
|
curl -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
|
|
-d '{"Do":"fast-forward-only"}' \
|
|
https://git.svc.zoit.services/api/v1/repos/Green-Tea/core/pulls/<n>/merge
|
|
```
|
|
|
|
A `405 Not all required status checks successful` means the pull request's own CI has not finished — `main` is protected, and a promotion runs its own checks rather than inheriting `develop`'s. Wait for them; the call is the same afterwards.
|
|
|
|
**Delete the branch when the work lands.** Both sides, as the last step of merging rather than a chore left for later:
|
|
|
|
```bash
|
|
git branch -d <branch> && git push origin --delete <branch>
|
|
```
|
|
|
|
On 2026-09-22 this repository carried 36 branches on Gitea and 29 locally, every one but a single stale docs branch already merged into `develop`, some of them since July. At that size the branch list stops describing the work in flight and becomes something a release has to audit commit by commit — which is both when it costs the most and when nobody has the patience for it. `git branch -r --merged origin/develop` is the check. A branch whose commits were rebased on the way in will not appear there even though its content did land, so confirm that case by content (`git diff <branch> develop -- <file>`) rather than by the flag. Never `develop`, `main`, or a `release/*` that has not shipped yet.
|
|
|
|
**Diagnosing "this branch is ahead of main".** Usually it is pre-rebase duplication, not unmerged work: the same content under different SHAs, because contributions are rebased on their way into `develop`. Confirm before acting:
|
|
|
|
```bash
|
|
git diff <branch> <main> -- <suspect file> # empty means the content is already in main
|
|
```
|
|
|
|
Merging such a branch to "recover" the commits duplicates the work and drags stale history along.
|
|
|
|
**External contributions.** They arrive on GitHub `contrib`. Merge the pull request there, fetch GitHub `contrib` into a branch on Gitea, then open a pull request from it into `develop` and merge it. The next develop push mirrors back to `contrib`, and fast-forwards because `develop` now contains everything `contrib` had. Merge rather than rebase: because promotions are fast-forward-only, `develop` and `main` are the same commit, so there is no main-only history for a merge to drag in. Rebasing would rewrite the contributor's SHAs for no gain and leave `contrib` with commits `develop` does not have, so the mirror push is refused until someone forces it. Merging keeps their commits reaching `main` under their own name and hash.
|
|
|
|
The exception is a `hotfix/*`, which lands on `main` without passing through `develop` and leaves the two out of step. Back-merge before taking a contribution through, or rebase that one and accept the force-push. If you do rebase, take the commit range from the pull request itself and never "everything since main": if a second contributor branched from `contrib` after the first one merged, the broad range sweeps up work that isn't theirs.
|
|
|
|
**Nothing to reset after a promotion.** `contrib` follows `develop` through the mirror, and there is no Gitea `contrib` to keep in step. The one thing the mirror will not do is push over external merges that were never carried in: that push is refused, the promote job fails, and the fix is to carry them as above — never to force.
|
|
|
|
A conflict against `develop` is visible to the contributor through `contrib`, so it can be theirs to resolve: ask them to rebase onto the current `contrib`. Only a conflict against a feature branch that has not merged yet is the maintainer's alone, because that code they cannot see.
|
|
|
|
## Releasing
|
|
|
|
**Close the `CHANGELOG` section as the step immediately before the tag, never earlier.** A version
|
|
heading with a date is a claim that the release exists. Until the tag is pushed and the registries
|
|
have it, that claim is false — and a `[26.8.0-beta.1] - 2026-08-17` sitting above work that shipped
|
|
nowhere is worse than no heading at all, because the next reader believes it.
|
|
|
|
This is not hypothetical: the beta.1 section was written the day the version was *decided*, the
|
|
release slipped, and a day of further work landed underneath it as `[Unreleased]`. The file then said
|
|
two contradictory things — that beta.1 was released, and that everything in it was not.
|
|
|
|
So the order is: everything merged and promoted → **close the section with the release date** → tag →
|
|
registries. Until that step, work accumulates under `[Unreleased]`, however certain the next version
|
|
number feels.
|
|
|
|
Bumping `package.json` and `deno.json` ahead of the tag is fine and necessary — those say what the
|
|
*next* publish will be called, and the docs repo's `verify:release` compares the tag against them.
|
|
A version number is a plan; a changelog heading is a receipt.
|
|
|
|
**A tag is created twice, on purpose.** Pushing `v*` to Gitea stages that exact commit to
|
|
Verdaccio through the real publish path; pushing the same tag to GitHub publishes it to npm and
|
|
JSR. Nothing promotes the tag for you — `promote.yml` mirrors `main` and only `main`, so the
|
|
second push is a decision made after reading the first run:
|
|
|
|
```bash
|
|
git push origin v<version> # Gitea → Verdaccio, reversible
|
|
git push gh v<version> # GitHub → npm + JSR, permanent on JSR
|
|
```
|
|
|
|
The split exists because a mistake caught on Verdaccio costs a re-tag, and the same mistake
|
|
caught on JSR costs the version number forever.
|
|
|
|
**After a beta release, move the channel tag by hand.** A publish sets exactly one dist-tag, and it
|
|
is the only npm write the release workflow can make — Trusted Publishing's OIDC exchange lives inside
|
|
`npm publish`, so the token it hands back is rejected by `npm dist-tag` (`E401`, learned the hard way
|
|
on `v26.8.0-beta.1`). While there is no stable release the publish spends that one tag on `latest`,
|
|
since that is what a bare `npm install @green-tea/core` resolves to, and the workflow prints the
|
|
command for the rest:
|
|
|
|
```bash
|
|
npm dist-tag add @green-tea/core@<version> beta
|
|
```
|
|
|
|
Once a stable version exists this stops being a chore: `latest` belongs to the stable release, the
|
|
publish gives a beta its channel tag directly, and there is nothing left to move.
|
|
|
|
## CI
|
|
|
|
The audit gate is scoped, not severity-filtered: `npm audit --omit=dev` blocks, everything else is `continue-on-error`. A critical in the test runner reaches nobody; a high in `reflect-metadata` reaches everyone. It runs *after* the code gates, because an advisory published by a third party must never decide whether a contributor sees their own lint and typecheck output.
|
|
|
|
**The forges disagree about where workflows come from.** GitHub reads `pull_request` workflows from the base branch, so a workflow fix cannot validate itself and must reach the base before it gates anything. Gitea reads from the head. Likewise, `continue-on-error` steps report as `success` on GitHub, hiding the advisory in the log, but as `failure` with the job still green on Gitea.
|
|
|
|
GitHub does not run workflows on fork pull requests until a maintainer approves them. A contributor's first push may sit with no checks at all.
|
|
|
|
## Conventions
|
|
|
|
- Conventional Commits, focused on the *why*. Every commit signed off (`git commit -s`) — the project uses a DCO, and unsigned commits are rejected. No AI co-authoring attribution.
|
|
- Comments carry reasoning the code cannot show. When editing a block, keep them; if one explains an ordering or a version floor, it is load-bearing.
|
|
- A new option or method on a public interface has to change `src/app/types.ts` too. An implementation that grows a parameter alone is unreachable for anyone consuming the package.
|
|
- Behaviour that differs between runtimes must be explicit. An "unavailable here" is fine; silently accepting an option that does nothing is a bug.
|
|
- New public API needs a note in `README.md` **and a companion pull request to the documentation repository**, [green-tea-docs](https://github.com/Expressive-Tea/green-tea-docs) — separate, because a pull request cannot span two repositories. Since the split, nothing here imports those pages and nothing fails when they disagree with this code — the CI job that used to build them is gone. That makes this the only thing standing between a rename and a guide that quietly documents a version nobody can install.
|