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

A rule test fails any page whose form answers with a full page, and the list of today's pages can only shrink #18495

opened this

Merged 3h 8m ago, live in production

I added a rule test that fails any page form that answers with a full page where the in-place path could answer, and a list of today's 536 offenders. test/in-place-rule.test.ts passes, tsc is clean and the gate ran. I did not run the full suite or test/pages-budget.test.ts.

Notes

opened this

I added a rule test that fails any page form that answers with a full page where the in-place path could answer, and a list of today's 536 offenders. test/in-place-rule.test.ts passes, tsc is clean and the gate ran. I did not run the full suite or test/pages-budget.test.ts. The forge's check runs them on push.

  • The test: the form finder is test/helpers/in-place-forms.ts. It reads every <form method="post"> under src/web. A form without data-in-place is an offender, named file POST normalised-action, for example src/web/pages/infra.ts POST /infra/:/keep.
  • The list: test/in-place-offenders.json holds those names, not a count.
    • A new offender fails the test, and so does a list entry that no longer offends. The list can only shrink. It must also stay sorted and free of repeats.
    • The failure message names the route and says to mark the form data-in-place and answer {ok, redraw} or a 422 {ok:false, error}. It points to src/web/in_place.ts and src/web/studio/crew.ts.
  • The crew page: its seat forms (add, slot count, remove) are in place and not on the list. A third test checks this. Three other forms in src/web/studio/crew.ts are still on the list: /settings, /settings/autonomy and /settings/crew/:/role. They are converted in later pulls.
  • What I left out:
    • The test is a static scan of form markup. It does not post to each route to see whether the answer really is a full page.
    • It does not check that a form marked data-in-place has a server route that answers JSON. The crew test covers that for the crew card.
    • Forms built outside src/web are not scanned.

I added no dependency and changed no page, route or tool, so the commit says No door:. To try it, run bun test test/in-place-rule.test.ts. Then add a post form without data-in-place under src/web and the test fails with its route.

Closes #18460

3 earlier comments
commented

I added a rule test that fails any page form that answers with a full page where the in-place path could answer, and a list of today's 536 offenders. test/in-place-rule.test.ts passes, tsc is clean and the gate ran. I did not run the full suite or test/pages-budget.test.ts. The forge's check runs them on push.

  • The test: the form finder is test/helpers/in-place-forms.ts. It reads every <form method="post"> under src/web. A form without data-in-place is an offender, named file POST normalised-action, for example src/web/pages/infra.ts POST /infra/:/keep.
  • The list: test/in-place-offenders.json holds those names, not a count.
    • A new offender fails the test, and so does a list entry that no longer offends. The list can only shrink. It must also stay sorted and free of repeats.
    • The failure message names the route and says to mark the form data-in-place and answer {ok, redraw} or a 422 {ok:false, error}. It points to src/web/in_place.ts and src/web/studio/crew.ts.
  • The crew page: its seat forms (add, slot count, remove) are in place and not on the list. A third test checks this. Three other forms in src/web/studio/crew.ts are still on the list: /settings, /settings/autonomy and /settings/crew/:/role. They are converted in later pulls.
  • What I left out:
    • The test is a static scan of form markup. It does not post to each route to see whether the answer really is a full page.
    • It does not check that a form marked data-in-place has a server route that answers JSON. The crew test covers that for the crew card.
    • Forms built outside src/web are not scanned.

I added no dependency and changed no page, route or tool, so the commit says No door:. To try it, run bun test test/in-place-rule.test.ts. Then add a post form without data-in-place under src/web and the test fails with its route.

commented

All five review points are fixed and pushed. The rule test, including the new scanner fixture test, passes (4 tests) and tsc is clean. I didn't run the full suite, which the forge's check runs on push.

  • Scanner: test/helpers/in-place-forms.ts now finds each form tag and its action by brace depth. It skips quotes and nested templates inside ${}, so a > in an expression no longer ends the tag early.
  • Unreadable actions: a form whose action can't be read is labelled file POST (form n), where n counts the forms in that file.
  • List: I regenerated test/in-place-offenders.json. It has 573 entries (the file is 575 lines with the brackets), none containing ${, and 98 carry the (form n) label.
  • Failure message: it now says to use the in-place helper in src/web/in_place.ts: put data-in-place on the form and answer a JSON ask with {ok, redraw:[fragment urls]} or a 422 {ok:false, error}.
  • Crew test: it now runs offenders() and asserts that no src/web/studio/crew.ts entry ends in /settings/crew, /settings/pillars or /settings/crew/:/remove. It also checks that none of those is on the list.
  • Scanner fixture test: it covers an in-place form, an offender, a > inside ${}, a data-in-place set by an expression, a GET form and a <formal tag.
  • Tidy: the stray blank line in the helper is gone.

The gate prints two similarity hints, which I left as they are. files() resembles a helper in test/image-carries-runtime-reads.test.ts, and expressionEnd resembles one in test/spawn-pipes.test.ts. Neither is a duplicate-import or dead-code rule failure.

commented

The check failed because a form that arrived from main broke the new in-place rule. That form is the owner's power-cycle confirm in src/web/games_machine.ts, which posts to /games/:/@cycle and answers with a full page. I listed it in test/in-place-offenders.json, as the rule's design expects for existing offenders. The in-place rule test file (test/in-place-rule.test.ts) passes again, 4 of 4. I didn't run the rest of the suite here, so the forge's check on this push will be the full verdict.

I merged current origin/main into the branch to pick up that file. The only change of mine is the one added line in the list.

I did not convert that form to answer in place. That is a separate change to the form's handler, and the list exists so such forms can be fixed one at a time.

This is a test-list change only, so no terminal or how-to change goes with it (the commit says "No door").

To try it, run bun test test/in-place-rule.test.ts.

commented

Left #18460 open: 1 unticked item remain (the crew page is not on the list).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs