Public: anyone can read this; the crew can change it.

The rosters: generate the route table roster from one file per member (child of #14248) #14439

opened this

Merged 14d 0h ago, live in production

The route marks, which are the forge's roster of its route table, are now built from a directory, one file per head. They're in src/http/marks/, 171 files. The tests I ran pass and tsc is clean.

Notes

opened this

The route marks, which are the forge's roster of its route table, are now built from a directory, one file per head. They're in src/http/marks/, 171 files. The tests I ran pass and tsc is clean. I did not run bun scripts/fast.ts.

What moved where

  • HEADS and ROUTES in src/http/route_marks.ts were two hand-edited tables of about 400 lines. They now come from readMembers(), which reads src/http/marks/*.json in file-name order.
  • Each file holds { head, mark }. Where the mark is mixed, it also holds that head's routes, with each route's mark. Every entry of the old ROUTES sits in the file of its own head.
  • I checked that the rebuilt HEADS and ROUTES equal the old literals entry for entry. Matching, markOf, isAdminRoute and the admin gate are unchanged, so no behaviour moved.
  • A pull that adds a route head now adds one file. It no longer edits a shared list.
  • docs/ROLES.md points at the directory.

Test

  • test/route-marks-roster.test.ts checks that HEADS equals the directory's heads, each once. It checks that ROUTES equals the directory's routes, each under its own head. It also checks that a mixed head lists routes and that no file is hidden or not .json.
  • test/route-marks.test.ts, open-routes-floor, security-floor-routes and mutations-same-origin pass unchanged.

What I left out

  • The route table in server.ts still has its 608 router.add calls. Route order there matters, because the first match wins, so I did not split it. The marks were the roster pulls collide on.
  • I dropped the one inline comment on /api/v1/runner ("A runner's own door…"). The JSON files have no comment field.
  • Two file names are not obvious from the head: /__forge is forge.json and /- is dash.json. / is root.json and the trailing-slash /api/v1/ is api-v1-slash.json. The files are keyed by their head field, not their name.

How to try it Add src/http/marks/<name>.json with {"head":"/new","mark":"open"}. A route under /new is then marked, and test/route-marks.test.ts stops reporting it as unmarked.

I pushed an empty "Try:" commit because the pre-push hook asked for one. The pull is the one the forge opens from this branch.

Closes #14437

commented

The route marks, which are the forge's roster of its route table, are now built from a directory, one file per head. They're in src/http/marks/, 171 files. The tests I ran pass and tsc is clean. I did not run bun scripts/fast.ts.

What moved where

  • HEADS and ROUTES in src/http/route_marks.ts were two hand-edited tables of about 400 lines. They now come from readMembers(), which reads src/http/marks/*.json in file-name order.
  • Each file holds { head, mark }. Where the mark is mixed, it also holds that head's routes, with each route's mark. Every entry of the old ROUTES sits in the file of its own head.
  • I checked that the rebuilt HEADS and ROUTES equal the old literals entry for entry. Matching, markOf, isAdminRoute and the admin gate are unchanged, so no behaviour moved.
  • A pull that adds a route head now adds one file. It no longer edits a shared list.
  • docs/ROLES.md points at the directory.

Test

  • test/route-marks-roster.test.ts checks that HEADS equals the directory's heads, each once. It checks that ROUTES equals the directory's routes, each under its own head. It also checks that a mixed head lists routes and that no file is hidden or not .json.
  • test/route-marks.test.ts, open-routes-floor, security-floor-routes and mutations-same-origin pass unchanged.

What I left out

  • The route table in server.ts still has its 608 router.add calls. Route order there matters, because the first match wins, so I did not split it. The marks were the roster pulls collide on.
  • I dropped the one inline comment on /api/v1/runner ("A runner's own door…"). The JSON files have no comment field.
  • Two file names are not obvious from the head: /__forge is forge.json and /- is dash.json. / is root.json and the trailing-slash /api/v1/ is api-v1-slash.json. The files are keyed by their head field, not their name.

How to try it Add src/http/marks/<name>.json with {"head":"/new","mark":"open"}. A route under /new is then marked, and test/route-marks.test.ts stops reporting it as unmarked.

I pushed an empty "Try:" commit because the pre-push hook asked for one. The pull is the one the forge opens from this branch.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs