Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7fd1e90
Kill the api-keys and attributes mutation survivors
claude Jul 30, 2026
6a6fe10
Answer the review: move the CRUD cases, split the suite, make inserts…
claude Jul 30, 2026
707a48e
Kill the join, i18n, rebrand, and remaining api-keys survivors
claude Jul 30, 2026
1b2d2a1
Kill the attributes tab, option edit/move, and database-reset survivors
claude Jul 30, 2026
b57c9b4
Pin the site forms' labels, hints, and markdown affordance
claude Jul 30, 2026
21ea8a8
Answer the review, unify the ordered inserts, kill the last survivors
claude Jul 30, 2026
b5c2565
Import the client statically in the trigger helper
claude Jul 30, 2026
dbd1025
Follow inputNamed's wider contract in its own test
claude Jul 30, 2026
52910d3
Answer the review: sentence case, named contract, splits, rollback tests
claude Jul 30, 2026
9528978
Pin field schemas, split the site suite, and shard the equivalent reg…
claude Jul 30, 2026
596ce08
Mirror the answer tests to the split answers module
claude Jul 30, 2026
dd448a9
Pin the field input metadata and the builder and autofocus views
claude Jul 30, 2026
32c2aed
Answer the second review round: registry hygiene, typed contract, sen…
claude Jul 30, 2026
93c6dba
Join the not-found import onto one line for the formatter
claude Jul 30, 2026
b70bd07
Finish the sentence-case sweep and preflight the registry copy-back
claude Jul 30, 2026
2ec5a06
Give the listing-choice factory its own mirror test
claude Jul 30, 2026
606d218
Mirror-test the id-table wrapper
claude Jul 30, 2026
27c7203
Refresh shifted registry records, recheck copy-back at write time, No…
claude Jul 30, 2026
db8219e
Keep the No check-in rename out of code comments
claude Jul 30, 2026
c985d99
Tell the questions, details, and front-page stories in Cucumber
claude Jul 30, 2026
1813dcf
Merge origin/main, keeping the curried take-down helper
claude Jul 30, 2026
d669a9f
Keep the owner-was-told helper with the story support only stories load
claude Jul 30, 2026
1f58f63
Full stops on the duration errors, and the free-text refusal in the c…
claude Jul 30, 2026
c0cc322
Sentence-case the site editor headings, refresh table records, roll b…
claude Jul 30, 2026
c4506a1
Share the two-file setup between the copy-back failure tests
claude Jul 30, 2026
cb80ec6
Sentence-case the question and attribute buttons, keep mid-run edits …
claude Jul 30, 2026
8c5702f
Word the site editor forms from the catalog, finish the listing-type …
claude Jul 30, 2026
5ee84cc
Address the CodeRabbit round: casing sweep, sturdier undo, stricter h…
claude Jul 30, 2026
adf3ace
Report undo problems instead of throwing them
claude Jul 30, 2026
85a9d20
Hand the snapshot child the parent's registry list, refresh 27 records
claude Jul 30, 2026
da36269
Share one flag-splitting helper between the spec and audit commands
claude Jul 30, 2026
8463395
Read the builder and listing-filter copy from the catalog, drop a don…
claude Jul 30, 2026
5a33bdf
One mechanism for the shared built-site boxes
claude Jul 30, 2026
9f15574
Pin the payments guide schema with its own direct suite
claude Jul 30, 2026
1e915f2
Tighten the flag parsing, control matching, and refusal assertions
claude Jul 30, 2026
89e0a47
Prove the ticked box is really offered, finish three copy edges
claude Jul 30, 2026
2e81e83
Send stories through the served forms, catalog the last touched copy
claude Jul 30, 2026
9b5e2b8
Commit the lock update for @std/csv
claude Jul 30, 2026
3b82cfe
Cover both arms of the form-preference choice directly
claude Jul 30, 2026
730c254
Refuse a hand-passed --registry in the audit parent
claude Jul 30, 2026
d8a843b
Kill the gate's nineteen survivors: tighter pins and five equivalents
claude Jul 30, 2026
1748578
Catalog the provider labels, bound the field ranking, drop optional c…
claude Jul 30, 2026
79bbcfd
Sentence-case the builder, logistics, questions, join, setup, and hol…
claude Jul 30, 2026
e7a6912
Sentence-case the last Title Case labels on the touched pages
claude Jul 30, 2026
e1fdb04
Match the Other attendees pins to the renamed heading
claude Jul 30, 2026
c63fa7d
Finish the agreement error, write copy-backs whole or not at all
claude Jul 30, 2026
4fdf504
Make every registry write whole-or-nothing, tick the real order box
claude Jul 30, 2026
28c2a21
Name the registry file path once, string or URL alike
claude Jul 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/mutation/equivalent-mutants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ src/features/admin/group-page-data.ts:194:49 ?? → || # dayPrices.get(): Day

# questions.ts form `id`s feed only CSRF/flash-form coordination, never the
# rendered CsrfForm id, which is "new-question".
src/features/admin/questions.ts:133:7 questionText → "" # defineForm config.id: only feeds CSRF/flash-form coordination; the page's CsrfForm uses id="new-question", so this value is never rendered observably
src/features/admin/questions.ts:146:7 answerText → "" # answerTextForm config.id: same as questionText — unobservable form-coordination id

# buildAssetPathsModule embed-script gate `pathConst === "EMBED_JS_PATH"`:
# pathConst is the string 4th element of an AssetDef tuple compared against a
Expand Down Expand Up @@ -994,3 +992,17 @@ src/features/admin/listing-page-data.ts:282:61 ?? → || # Map.get returns Li
# The news card query names a single table, so its columns need no alias to
# resolve.
src/shared/db/news-posts.ts:148:47 news_post → "" # dropping the alias leaves the column names unqualified, and the read selects from one table (news_posts AS news_post) plus scalar subqueries that carry their own qualified id, so every name still resolves to the same column
src/features/admin/api-keys.ts:147:75 ?? → || # entity-page load: find() returns a key row object or undefined — a row object is always truthy, so `?? null` and `|| null` agree on every input

# rebrand scanner — four provably-equivalent survivors.
# tagIsCode is read in exactly one place: stepTag's close, reachable only while
# inTag is true — and every assignment of inTag=true (stepProse's unfinished
# tag) also assigns tagIsCode. So a stale tagIsCode value can never be read.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Split the equivalent-mutant registry before extending it

These additions take scripts/mutation/equivalent-mutants.txt from 996 to 1,008 lines, crossing the repository's hard 1,000-line ceiling. Refactor the ignore loader to consume focused registry files, or otherwise split this registry, instead of continuing to append proofs to a single oversized file.

AGENTS.md reference: AGENTS.md:L82-L82

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9528978 — the registry is now the scripts/mutation/equivalent-mutants/ directory: nine focused per-area files (largest 236 lines) plus a README with the recording rules. loadIgnoreList merges every *.txt in the directory, the static audit checks and prunes each file in place, and cross-file duplicates fail the run just as same-file ones did. Covered by new loader and audit tests (directory merge, cross-file duplicate, per-file prune).


Generated by Claude Code

src/shared/rebrand.ts:66:14 false → true # freshScan's tagIsCode: inTag starts false, so stepTag cannot run before stepProse has overwritten tagIsCode — the initial value is never read
src/shared/rebrand.ts:138:26 false → true # stepTag's tagIsCode reset after closing: inTag is false from here, and the next inTag=true assignment rewrites tagIsCode first — the residual value is never read
# scanTagEnd treats "<" as an inert character (it is neither a quote nor ">"),
# so starting the scan at the "<" itself instead of one past it visits one
# extra no-op character and returns the same index with the same quote state.
src/shared/rebrand.ts:152:36 + → * # `open + 1` → `open * 1` = open: the scan starts on the inert "<" and behaves identically
src/shared/rebrand.ts:152:39 1 → 0 # `open + 0` = open: same inert-"<" start, identical result
src/features/admin/attributes.ts:210:55 0 → 1 # option insert's sortOrder is a placeholder: the same transaction's append overwrites it before commit, and a failed append rolls the row back — no committed state can carry the inserted value
55 changes: 39 additions & 16 deletions src/features/admin/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ import {
listingAttributeOptions,
pruneInvalidAttributeOptionIds,
} from "#shared/db/attributes.ts";
import { type TxScope, writeRowInTransaction } from "#shared/db/client.ts";
import {
flatCollectionSwap,
insertScopedOrderedRow,
scopedCollectionSwap,
} from "#shared/db/ordered-collection.ts";
import { getFlash } from "#shared/flash-context.ts";
Expand Down Expand Up @@ -92,11 +94,23 @@ const handleAttributesPost = createAuthedFormRoute({
form: attributeNameForm,
onInvalid: ({ error }) => errorRedirect("/admin/attributes", error),
onValid: async ({ values: { name } }) => {
const attribute = await attributesTable.insert({ name });
await attributesOrder.append({ key: attribute.id });
await logActivity(`Attribute '${name}' created`);
// One transaction: an attribute must never exist without its order entry
// or its log line.
const attributeId = await writeRowInTransaction(
await attributesTable.insertStatement!({ name }),
null,
async (transaction, id) => {
await attributesOrder.append({ key: id, transaction });
await logActivity(
`Attribute '${name}' created`,
undefined,
undefined,
transaction,
);
},
);
return redirect(
`/admin/attributes/${attribute.id}`,
`/admin/attributes/${attributeId}`,
"Attribute created",
true,
);
Expand Down Expand Up @@ -148,11 +162,15 @@ const logAttributeOptionActivity = (
optionText: string,
action: string,
attribute: AttributeWithOptions,
transaction?: TxScope,
) =>
logActivity(
`Attribute option '${optionText}' ${action} ${attributeNameFlat(
attribute.name,
)}`,
undefined,
undefined,
transaction,
);

const handleAttributeEdit = createAuthedFormRoute<
Expand All @@ -174,6 +192,12 @@ const handleAttributeEdit = createAuthedFormRoute<
}),
});

/** Insert an option and place it in its attribute's order, atomically. */
const addOptionRow = insertScopedOrderedRow(
attributeOptionsTable,
attributeOptionsOrder,
);

const handleAddOption = createAuthedFormRoute<
{ text: string },
AttributeParams
Expand All @@ -183,16 +207,15 @@ const handleAddOption = createAuthedFormRoute<
onInvalid: redirectToAttribute,
onValid: ({ params, values: { text } }) =>
orNotFound(getAttributeWithOptions(params.id), async (attribute) => {
const option = await attributeOptionsTable.insert({
attributeId: params.id,
sortOrder: 0,
text,
});
await attributeOptionsOrder.append({
key: option.id,
scope: params.id,
});
await logAttributeOptionActivity(text, "added to", attribute);
// One transaction: an option must never exist without its place in the
// order or its log line. The inserted sortOrder is a placeholder the
// append overwrites before anything can read it.
await addOptionRow(
params.id,
{ attributeId: params.id, sortOrder: 0, text },
(transaction) =>
logAttributeOptionActivity(text, "added to", attribute, transaction),
);
return redirect(`/admin/attributes/${params.id}`, "Option added", true);
}),
});
Expand Down Expand Up @@ -334,10 +357,10 @@ const handleListingAttributesPost = createListingChoicePost({
fieldName: "option_ids",
label: "Attributes",
noun: "option",
readIds: async (form) =>
readIds: async (form, fieldName) =>
pruneInvalidAttributeOptionIds(
await getAllAttributeOptionIds(),
form.getNumberArray("option_ids"),
form.getNumberArray(fieldName),
),
saveIds: listingAttributeOptions.setIds,
tab: "attributes",
Expand Down
7 changes: 5 additions & 2 deletions src/features/admin/listing-choice-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ type ListingChoicePostConfig = {
fieldName: string;
label: string;
noun: string;
readIds?: (form: FormParams) => number[] | Promise<number[]>;
readIds?: (
form: FormParams,
fieldName: string,
) => number[] | Promise<number[]>;
saveIds: (listingId: number, ids: number[]) => Promise<void>;
tab: string;
};
Expand All @@ -35,7 +38,7 @@ export const createListingChoicePost = ({
async (listing, _session, form, _request, { id }) => {
if (!settings.features[feature]) return notFoundResponse();
const ids = readIds
? await readIds(form)
? await readIds(form, fieldName)
: form.getNumberArray(fieldName);
await saveIds(id, ids);
await logActivity(
Expand Down
50 changes: 33 additions & 17 deletions src/features/admin/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { getAllListings } from "#shared/db/listings/records.ts";
import { getAllModifiers } from "#shared/db/modifiers.ts";
import {
flatCollectionSwap,
insertScopedOrderedRow,
scopedCollectionSwap,
} from "#shared/db/ordered-collection.ts";
import {
Expand Down Expand Up @@ -174,17 +175,22 @@ const handleQuestionsPost = createAuthedFormRoute({
onInvalid: ({ error }) => errorRedirect("/admin/questions", error),
onValid: async ({ values: { display_type, text } }) => {
const displayType = requireQuestionDisplayType(display_type);
const question = await questionsTable.insert({
displayType,
text,
});
await questionsOrder.append({ key: question.id });
await logActivity(`Question '${text}' created`);
return redirect(
`/admin/questions/${question.id}`,
"Question created",
true,
// One transaction: a question must never exist without its order entry
// or its log line.
const questionId = await writeRowInTransaction(
Comment on lines +98 to +100

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Split the questions route module while refactoring it

This refactor grows src/features/admin/questions.ts from 567 to 583 lines, leaving the route module substantially above the repository's roughly 400-line target. The answer and question lifecycle handlers are already separable concerns, so extract a focused module instead of adding more transactional creation logic to the existing monolith.

AGENTS.md reference: AGENTS.md:L82-L82

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 52910d3 — the module is now three files: questions.ts (question lifecycle plus the route table, 250 lines), questions/answers.ts (the answer lifecycle handlers), and questions/forms.ts (the two form definitions, which also breaks the route→template init cycle). The mirror tests moved with the split in 596ce08.


Generated by Claude Code

await questionsTable.insertStatement!({ displayType, text }),
null,
async (transaction, id) => {
await questionsOrder.append({ key: id, transaction });
Comment on lines +100 to +104

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add a failed-append regression test for question creation

Fresh evidence beyond the resolved attribute review is that this later change also makes question and answer creation atomic, but the question suites never force questionsOrder.append() or answersOrder.append() to fail after the insert. Their existing feature-write and successful-order tests do not reproduce the half-created-row defect this code fixes, so a future loss of the transaction could pass unnoticed; add route-level failing-order tests that assert no question or answer remains.

AGENTS.md reference: AGENTS.md:L84-L84

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 52910d3 (and refined in 596ce08) — route-level failing-append tests now cover both creations: withFailingOrderTrigger forces the order write to fail after the insert, and the tests assert the POST rejects with "order write failed" and that no question (test/features/admin/questions/delete.test.ts) or answer (test/features/admin/questions/answers.test.ts) remains stored. Both fail against the pre-transaction code.


Generated by Claude Code

await logActivity(
`Question '${text}' created`,
undefined,
undefined,
transaction,
);
},
);
return redirect(`/admin/questions/${questionId}`, "Question created", true);
},
});

Expand Down Expand Up @@ -284,17 +290,27 @@ const handleAddAnswer = createAuthedFormRoute<
"Free-text questions don't have answer options",
);
}
const answer = await answersTable.insert({
questionId: params.id,
sortOrder: 0,
text,
});
await answersOrder.append({ key: answer.id, scope: params.id });
await logActivity(`Answer '${text}' added to question ${params.id}`);
// One transaction: an answer must never exist without its place in the
// order or its log line. The inserted sortOrder is a placeholder the
// append overwrites before anything can read it.
await addAnswerRow(
params.id,
{ questionId: params.id, sortOrder: 0, text },
(transaction) =>
logActivity(
`Answer '${text}' added to question ${params.id}`,
undefined,
undefined,
transaction,
),
);
return redirect(`/admin/questions/${params.id}`, "Answer added", true);
},
});

/** Insert an answer and place it in its question's order, atomically. */
const addAnswerRow = insertScopedOrderedRow(answersTable, answersOrder);

/** Confirmed-delete handlers for questions */
const questionDelete = createConfirmedHandlers<QuestionWithAnswers>({
// The confirmation page shows the flattened text (newlines → " / "), and a
Expand Down
37 changes: 37 additions & 0 deletions src/shared/db/ordered-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
resultRows,
type TxScope,
useTransaction,
writeRowInTransaction,
} from "#shared/db/client.ts";

type Columns = string | readonly [string, ...string[]];
Expand Down Expand Up @@ -194,3 +195,39 @@ export const defineOrderedCollection = <

return { append, next, nextMany, swap };
};

/**
* Insert a child row and give it the next place in its scoped order — one
* transaction, with any extra writes (like the log line) riding along. A
* failed order write or log rolls the insert back with it.
*/
export const insertScopedOrderedRow =
<Input>(
Comment on lines +211 to +212

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Annotate the exported helper's outer return type

The returned closure has a Promise<number> annotation, but the exported generic insertScopedOrderedRow function itself still relies on inference for its curried function type. Give the outer function an explicit, preferably named, return type so changes to its implementation fail at the definition instead of silently changing the public contract and forcing callers to re-infer the anonymous signature.

AGENTS.md reference: AGENTS.md:L97-L97

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 52910d3 — the curried type now has a name, ScopedOrderedRowInsert<Input>, and insertScopedOrderedRow declares it as its return type, so a drift in the implementation fails at the definition instead of reshaping the public contract.


Generated by Claude Code

table: {
insertStatement?: (input: Input) => Promise<{
args: InValue[];
sql: string;
}>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require an insert statement in the helper contract

If this shared helper is passed one of the façade tables that legitimately omits insertStatement, the optional property lets the call type-check and the non-null assertion then turns it into a runtime TypeError before the transaction starts. Make insertStatement required in this helper's table parameter so an unsupported table is rejected at compile time instead of pretending the method exists.

AGENTS.md reference: AGENTS.md:L128-L137

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 32c2aed — defineTable now returns the new CrudTable type, which guarantees insertStatement, updateStatement, and findByIdPrimary, and insertScopedOrderedRow requires insertStatement in its parameter type, so passing a façade table without it is a compile error. The now-redundant non-null assertions on defineTable-built tables were removed with it.


Generated by Claude Code

},
order: {
append: (operation: {
key: number;
scope: number;
transaction: TxScope;
}) => Promise<void>;
},
) =>
(
scope: number,
input: Input,
log: (transaction: TxScope) => Promise<unknown>,
): Promise<number> =>
(async () =>
writeRowInTransaction(
await table.insertStatement!(input),
null,
async (transaction, id) => {
await order.append({ key: id, scope, transaction });
await log(transaction);
},
))();
Loading