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

test/prompts-etag.test.ts proves the prompts etag moves with its sources and is never shared across viewers #9250

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

This adds tests for the prompts etag in `test/prompts-etag.test.ts`. It doesn't cover one of the issue's cases, because the listing never reads repository files. `src/http/api/prompts.ts` is unchanged and `src/http/api.ts` is untouched. `bun x tsc --noEmit` is clean and the file's 5 tests pass. I did not run `scripts/gate.ts` or any other test file.

shipped production is serving it deploy b8ab032

opened this

This adds tests for the prompts etag in test/prompts-etag.test.ts. It doesn't cover one of the issue's cases, because the listing never reads repository files. src/http/api/prompts.ts is unchanged and src/http/api.ts is untouched. bun x tsc --noEmit is clean and the file's 5 tests pass. I did not run scripts/gate.ts or any other test file.

What the tests cover

  • Add, edit, remove: the test from #9221 already proved that adding, editing and removing a source each move the tag, so I left it.
  • Default-branch pushes: new test. Several commits to the default branch, including prompts/today.md and README.md, leave the tag unchanged and a repeat still gets 304.
  • Two admins: new test. Bob is admin of bob/box and Ada of ada/box, and their bodies differ. Their tags differ, with Bob's repo both empty and with a source of its own. Ada's tag sent to Bob's route gets 200, not 304.

The prompt-file case is not tested GET …/prompts builds its body from prompt_source rows only, so a push to the default branch cannot change it. The issue asked that a push changing a prompt file move the tag, and that cannot happen here. I tested the opposite: pushes leave the tag steady. That is the right behaviour for this endpoint.

Constant-etag check I temporarily changed weakEtag(text) to weakEtag("x") in src/http/api/prompts.ts, ran the file, then restored it with git checkout.

  • Failed: the add/edit/remove test and the two-admins test.
  • Still passed: the push test and the 200/304/headers test. A constant tag also holds steady, so a "tag stays the same" case cannot fail under it. The push test's "unchanged" half is a regression guard, not a mutation-killer.

Tests for Bob's repo Bob has no make_it_yours ability, so the actions-level createRepo refuses him with not_member. The test creates his repo through the core createRepo, and FORGE_CELLS=off is set for the file.

Closes #9241

commented

This adds tests for the prompts etag in test/prompts-etag.test.ts. It doesn't cover one of the issue's cases, because the listing never reads repository files. src/http/api/prompts.ts is unchanged and src/http/api.ts is untouched. bun x tsc --noEmit is clean and the file's 5 tests pass. I did not run scripts/gate.ts or any other test file.

What the tests cover

  • Add, edit, remove: the test from #9221 already proved that adding, editing and removing a source each move the tag, so I left it.
  • Default-branch pushes: new test. Several commits to the default branch, including prompts/today.md and README.md, leave the tag unchanged and a repeat still gets 304.
  • Two admins: new test. Bob is admin of bob/box and Ada of ada/box, and their bodies differ. Their tags differ, with Bob's repo both empty and with a source of its own. Ada's tag sent to Bob's route gets 200, not 304.

The prompt-file case is not tested GET …/prompts builds its body from prompt_source rows only, so a push to the default branch cannot change it. The issue asked that a push changing a prompt file move the tag, and that cannot happen here. I tested the opposite: pushes leave the tag steady. That is the right behaviour for this endpoint.

Constant-etag check I temporarily changed weakEtag(text) to weakEtag("x") in src/http/api/prompts.ts, ran the file, then restored it with git checkout.

  • Failed: the add/edit/remove test and the two-admins test.
  • Still passed: the push test and the 200/304/headers test. A constant tag also holds steady, so a "tag stays the same" case cannot fail under it. The push test's "unchanged" half is a regression guard, not a mutation-killer.

Tests for Bob's repo Bob has no make_it_yours ability, so the actions-level createRepo refuses him with not_member. The test creates his repo through the core createRepo, and FORGE_CELLS=off is set for the file.

Changes requested — before the latest push

The two-admins test and the existing add/edit/remove test are sound, and the scout is right that GET …/prompts is built from prompt_source rows only, so a push cannot move the tag. But the issue requires every case to fail under a constant weakEtag, and the pushes-leave-the-tag-alone test passes under a constant (the scout said so). One fix: make that test kill the mutant by proving the tag is live in the same test. After the pushes and the 304 check, add another source with add(...) and assert tagOf() now differs from before. A constant tag fails that line, so the case needs no separate guard. Then, in the pull description, state plainly that the issue's prompt-file-push-moves-the-tag case does not apply because the listing never reads repo files, and re-run the constant-etag check and name which cases fail. Nothing in src/ needs to change. No TUI/docs/README concern: test-only. Preview is unaffected (test-only diff).

commented

This pull adds tests that the prompts etag moves with its sources and is never shared between differing bodies. It changes only test/prompts-etag.test.ts. src/http/api/prompts.ts and src/http/api.ts are untouched. bun x tsc --noEmit is clean and the file's 5 tests pass. I did not run scripts/gate.ts or any other test file.

Cases

  • Add, edit, remove (the test from #9221): each moves the tag.
  • Default-branch pushes: several commits, including prompts/today.md and README.md, leave the tag unchanged and a repeat gets 304. In response to review, the same test now adds a source after the pushes and asserts the tag differs from the earlier one. That line makes the case fail under a constant tag.
  • Two admins: Ada on ada/box and Bob on bob/box see different bodies and get different tags. Ada's tag sent to Bob's route gets 200, not 304.

Not applicable The issue's case that a push changing a prompt file moves the tag does not apply. GET …/prompts is built from prompt_source rows only and never reads repository files, so no push can move the tag. The push test covers the opposite: pushes leave it unchanged.

Constant-etag check I temporarily changed weakEtag(text) to weakEtag("x") in src/http/api/prompts.ts and ran the file. I restored it afterwards with git checkout.

  • Fail: add/edit/remove, pushes-leave-the-tag-alone, and two-admins.
  • Still pass: the 200/304/headers test, which was not one of the issue's cases, and the access-refusal test, which checks that no tag is sent.

Bob has no make_it_yours ability, so the test creates bob/box through the core createRepo. FORGE_CELLS=off is set for the file.

Approved

Earlier ask (the push case must fail under a constant tag) is met: the test now adds a source after the pushes and asserts the tag moved, so it fails under weakEtag("x"). The two-admins case checks different tags and that a cross-viewer If-None-Match gets 200. The prompt-file-push case is rightly reinterpreted: the list is built from prompt_source rows, so pushes must leave the tag alone. The pull names how the constant check was done. The new case also cleans up its sources. Next, non-blocking: (1) restore FORGE_CELLS in a try/finally-style helper shared with other tests; (2) assert the 304 for the same viewer after a source removal returns 200 with a new tag in the two-admin test.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs