|
| 1 | +# tripwire |
| 2 | + |
| 3 | +a firewall for your repo. |
| 4 | + |
| 5 | +tripwire reads every incoming change request and decides whether it is safe. |
| 6 | +it then blocks it, passes it, or sends it to a human. this happens before a |
| 7 | +maintainer ever opens it. |
| 8 | + |
| 9 | +it works on github and on open-git. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## the problem |
| 14 | + |
| 15 | +an open repository takes changes from strangers. most are fine. some are spam, |
| 16 | +some are a wallet address swapped into a config file, and some are an account |
| 17 | +made an hour ago. |
| 18 | + |
| 19 | +a maintainer reads all of them. that is the cost of being open, and it is the |
| 20 | +part that does not scale. |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## what tripwire does |
| 25 | + |
| 26 | +1. a change request arrives. the forge sends a webhook. |
| 27 | +2. tripwire runs a set of **rules** against it. |
| 28 | +3. a **workflow** combines those results into one verdict. |
| 29 | +4. tripwire writes a **check** on the commit and comments on the thread. |
| 30 | + |
| 31 | +three verdicts: |
| 32 | + |
| 33 | +| verdict | what happens | |
| 34 | +| --- | --- | |
| 35 | +| pass | the check goes green. nobody is interrupted. | |
| 36 | +| block | the check fails. the merge button is dead. | |
| 37 | +| review | a human is asked to decide. | |
| 38 | + |
| 39 | +the check is the gate. a failing check means the change cannot merge. |
| 40 | + |
| 41 | +### it fails closed |
| 42 | + |
| 43 | +if tripwire cannot read what a rule needs, that rule declines. it does not |
| 44 | +guess, and it never reports a pass for something it did not examine. a change |
| 45 | +tripwire could not judge goes to a human, not through. |
| 46 | + |
| 47 | +### every run is auditable |
| 48 | + |
| 49 | +each verdict keeps its inputs, the result of each rule, and the evidence. |
| 50 | +you can open a run and see why. you can replay history against new rule code |
| 51 | +and see which verdicts would change, before you ship the change. |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## agentic use |
| 56 | + |
| 57 | +tripwire is built to be driven by coding agents, and most of it was. |
| 58 | + |
| 59 | +### why it suits an agent |
| 60 | + |
| 61 | +the repository is arranged so an agent can work in it without breaking things |
| 62 | +it cannot see. |
| 63 | + |
| 64 | +- **the rules are pure.** rule code does no i/o. effects are passed in. a rule |
| 65 | + is a plain function over a fixed input, so an agent can test one without a |
| 66 | + database, a network, or a forge. |
| 67 | +- **the dependency arrows are enforced.** `bun run check:boundaries` fails the |
| 68 | + build on a wrong-direction import. an agent cannot quietly couple two |
| 69 | + packages that must stay apart. |
| 70 | +- **the type rules are strict on purpose.** a custom lint suite rejects the |
| 71 | + shortcuts a language model reaches for first, such as widening a known value |
| 72 | + or casting through `unknown`. see `docs/agent-guidelines.md`. |
| 73 | +- **the checks are one command each.** lint, typecheck, boundaries, tests. an |
| 74 | + agent can run all four and read a clear pass or fail. |
| 75 | + |
| 76 | +### using tripwire from an agent |
| 77 | + |
| 78 | +``` |
| 79 | +bun run rule-check # evaluate rules against a change request |
| 80 | +bun run replay # re-run stored history against current rule code |
| 81 | +``` |
| 82 | + |
| 83 | +`replay` is the important one. it answers "what would this rule change have |
| 84 | +done to the last thousand change requests" before the change reaches anyone. |
| 85 | + |
| 86 | +### contributing with an agent |
| 87 | + |
| 88 | +agents are welcome here. the rules are the same as for a person, and they are |
| 89 | +written down in `docs/agent-guidelines.md`. the short version: |
| 90 | + |
| 91 | +1. run lint and typecheck before every push. no exceptions. |
| 92 | +2. no `any`. no casting around a type error. |
| 93 | +3. a ui change needs a before-and-after screenshot. |
| 94 | +4. a commit message needs the right shape. |
| 95 | +5. a huge pull request gets split, not reviewed. |
| 96 | + |
| 97 | +read `docs/CONTRIBUTING.md` first. read `docs/agent-guidelines.md` second. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## local development |
| 102 | + |
| 103 | +### the demo, one command, no docker |
| 104 | + |
| 105 | +``` |
| 106 | +bun run dev:demo |
| 107 | +``` |
| 108 | + |
| 109 | +a seeded, presentable app at `http://localhost:3000`. the web head only. the |
| 110 | +database is embedded, in-process postgres, running the same schema and |
| 111 | +migrations as production. |
| 112 | + |
| 113 | +it seeds a realistic story across all three verdicts and drops you on a full |
| 114 | +dashboard. re-running resets to the same clean state. |
| 115 | + |
| 116 | +a dev build also has a persona switcher, at the bottom left. it jumps between |
| 117 | +real product states: a fresh maintainer, one repo, many repos, an empty |
| 118 | +dashboard, and the anonymous stranger view. it is excluded from production |
| 119 | +builds at compile time. |
| 120 | + |
| 121 | +### the full stack |
| 122 | + |
| 123 | +``` |
| 124 | +bun run db:up # postgres in docker |
| 125 | +bun run db:migrate # apply migrations |
| 126 | +bun run dev # web, api, worker, and a tunnel |
| 127 | +``` |
| 128 | + |
| 129 | +`bun run dev` opens one terminal ui. arrow keys move between the web, api, |
| 130 | +worker, and tunnel panes. |
| 131 | + |
| 132 | +the tunnel pane prints a public url routed to the api. point your forge app's |
| 133 | +webhook at `<that-url>/webhooks/github` or `<that-url>/webhooks/opengit` to |
| 134 | +receive local deliveries. |
| 135 | + |
| 136 | +smaller pieces: |
| 137 | + |
| 138 | +``` |
| 139 | +bun run dev:local # the same, without the tunnel |
| 140 | +bun run dev:web # the web head only |
| 141 | +bun run dev:api # the api head only |
| 142 | +bun run dev:worker # the queue consumer only |
| 143 | +``` |
| 144 | + |
| 145 | +set `BETTER_AUTH_SECRET` to turn on real sign-in and the auth gates. leave it |
| 146 | +unset for an open local posture. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## checks |
| 151 | + |
| 152 | +run these four before you push. continuous integration runs the same four. |
| 153 | + |
| 154 | +``` |
| 155 | +bun run check # format and lint |
| 156 | +bun run typecheck # every package |
| 157 | +bun run check:boundaries # the dependency arrows |
| 158 | +bun test # unit and integration tests |
| 159 | +``` |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## live end-to-end tests |
| 164 | + |
| 165 | +`bun test` proves the logic against a fake forge. a separate harness proves the |
| 166 | +real thing against a real forge, on a sacrificial repository. |
| 167 | + |
| 168 | +it needs real credentials, a running worker, and a tunnel. it is a pre-release |
| 169 | +tool. it does not run on each pull request. |
| 170 | + |
| 171 | +``` |
| 172 | +bun run test --list # the github scenarios |
| 173 | +bun run test --everything # all of them, with a summary |
| 174 | +``` |
| 175 | + |
| 176 | +open-git has its own harness. it never closes a pull request, because open-git |
| 177 | +has no page for a closed one, so a closed pull request cannot be read. |
| 178 | + |
| 179 | +``` |
| 180 | +bun run scripts/e2e/opengit.ts --list |
| 181 | +``` |
| 182 | + |
| 183 | +what is deliberately not automated: whether the comment copy READS well. the |
| 184 | +harness proves the mechanics. a human reads the thread once. taste stays human. |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## docs |
| 189 | + |
| 190 | +| file | what it covers | |
| 191 | +| --- | --- | |
| 192 | +| `docs/CONTRIBUTING.md` | setup, checks, commits, tests | |
| 193 | +| `docs/agent-guidelines.md` | rules for agent contributors | |
| 194 | +| `docs/opengit-progress.md` | what open-git still needs | |
| 195 | +| `docs/LICENSE-EXPLAINED.md` | the license in plain words | |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +## license |
| 200 | + |
| 201 | +mit. see `LICENSE`, and `docs/LICENSE-EXPLAINED.md` for what it means. |
0 commit comments