Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
56da980
Stop the runaway pending-work test from outliving its own assertion
claude Aug 18, 2026
652d230
Bound the superuser password draw so starved randomness fails loudly
claude Aug 18, 2026
4be75e5
Close the crypto and redirect survivors
claude Aug 18, 2026
6914c9d
Pin what the attendees browser offers and what it ignores
claude Aug 18, 2026
2de7390
Pin the flush round cap and the single-listing price sync
claude Aug 18, 2026
8532039
Pin the route tie-break against declaration order
claude Aug 18, 2026
8cf4045
Close the superuser survivors, and fix an off-by-one in the draw cap
claude Aug 18, 2026
7ee684c
Move the missing-member test to the file it belongs to
claude Aug 18, 2026
e5c1011
Name every word a page may not take
claude Aug 18, 2026
fbf7de5
Cover the listing-attendee reads nobody was checking
claude Aug 18, 2026
c15cafb
Refuse a malformed round count instead of throwing, and tighten two t…
claude Aug 18, 2026
570e08c
Settle the flush boundary test on ports instead of timers
claude Aug 18, 2026
16568a5
Invalidate on what a write assigns, not on which word it starts with
claude Aug 18, 2026
3c2761c
Check an imported listing's parent links in one place, not two
claude Aug 18, 2026
adc2419
Say the new words in the edge guard's own test too
claude Aug 18, 2026
52b6d50
Pin what happens when Logistics is turned off under pressure
claude Aug 18, 2026
f66171b
Read the import refusals from the message catalog in the wider tests too
claude Aug 18, 2026
94c354f
Write down the parent-link survivors this branch surfaced but does no…
claude Aug 18, 2026
45f4ee6
Keep one copy of the two import refusals, not two
claude Aug 18, 2026
22e8c2e
Merge remote-tracking branch 'origin/main' into followup/sweep-survivors
claude Aug 18, 2026
53dd996
Write the new comments and notes in Simplified Technical English
claude Aug 18, 2026
ec38167
Test the counting edges of the pricing engine
claude Aug 18, 2026
0309729
Record the early drop of an untriggered modifier as unkillable
claude Aug 18, 2026
9864661
Name the three shapes the parent-link survivors take
claude Aug 18, 2026
ce66899
Merge branch 'main' into followup/sweep-survivors
stefan-burke Aug 18, 2026
1f801e4
Merge remote-tracking branch 'origin/main' into followup/sweep-survivors
claude Aug 19, 2026
56848c0
Ask again when a released port is taken before the test can use it
claude Aug 19, 2026
9e592cf
Merge remote-tracking branch 'origin/main' into followup/sweep-survivors
claude Aug 20, 2026
31c25a3
Merge remote-tracking branch 'origin/main' into followup/sweep-survivors
claude Aug 20, 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
6 changes: 6 additions & 0 deletions scripts/mutation/equivalent-mutants/features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,9 @@ src/features/admin/listings-form.ts::extractCommonFields.unitPrice~0fxriin ??
src/features/admin/listings-form.ts::extractCommonFields.closesAt~1ox85dk closes_at → "" # the label only appears in normalizeDatetime's throw, and the field's validateDatetime already refused every value localToUtc would reject
src/features/admin/listings-form.ts::extractCommonFields.date~1ogjyd0 date → "" # same: the date field is validated by the same parser before toInput runs, so the throw naming it is unreachable
src/features/admin/listings-form.ts::listingValidate~19dmftv ?? → || # validateDayPricesFromForm returns null or one fixed non-empty message, so it is never falsy-but-present

# Route ordering (router.ts) — two array fallbacks, and a replacement string
# whose length cancels out of the only comparison that reads it.
src/features/router.ts::routeSpecificity.paramCount~1806jrr ?? → || # String.match returns an array or null, and an array is always truthy
src/features/router.ts::compileRoutes.methodRoutes~02urywu ?? → || # Map.get returns an array or undefined, and an array is always truthy
src/features/router.ts::routeSpecificity.literalLength~0au8fma → "mutated" # literal length is only ever compared between two routes with the SAME parameter count, so replacing each parameter with a fixed word adds the same amount to both sides and the comparison is unchanged
15 changes: 15 additions & 0 deletions scripts/mutation/equivalent-mutants/shared-a-l.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ src/shared/site-assignment.ts::renewalDeadlineBaseMs~00cywnq ?? → || # pars
src/shared/site-assignment.ts::assignSitesForEntries.site~0c03jq6 ?? → || # available.pop(): BuiltSite|undefined, and a BuiltSite object is always truthy
src/shared/site-assignment.ts::sendSiteAssignmentEmail.config~11vz7t9 ?? → || # getEmailConfig(): EmailConfig|null
src/shared/site-assignment.ts::sendSiteAssignmentEmail.replyTo~195nl86 ?? → || # parseEmail(): ValidEmail|null, always truthy or null
src/shared/db/listing-prices.ts::sourceRowStatements~0fyy4cr ?? → || # unit_price is number|null, so the only falsy-non-null value is 0 and 0 ?? 0 === 0 || 0
src/shared/ledger/project.ts::allBalances.add~0gr4ng6 ?? → || # allBalances: Map<string,number>.get; the only falsy-non-null number is 0, and 0 ?? 0 === 0 || 0
src/shared/ledger/project.ts::balanceOf~128hnl9 ?? → || # balanceOf: same Map<string,number>.get fallback; 0 ?? 0 === 0 || 0
src/shared/ledger/reconcile.ts::IDENTITY_FIELDS~0rfpt43 ?? → || # IDENTITY_FIELDS kind: string|undefined, only falsy-non-null is "" and "" ?? "" === "" || ""
Expand Down Expand Up @@ -178,6 +179,14 @@ src/shared/band-name-generator.ts::fixArticles~1rw9fca A $1 → "A $1 mutated"
# parsePositiveIntId's strict decimal-digit schema.
src/shared/logistics-filter.ts::parseAgentFilter.n~03f157n → "mutated" # parsePositiveIntId's schema rejects any non-digit string identically; the "" fallback and any mutated string both parse to null

# crypto/utils.ts — the out-of-range code readers. constantTimeCodesEqual seeds
# its XOR fold with lengthA ^ lengthB and walks the longer sequence, so a reader
# is only asked past the end of one string when the lengths differ — and that
# seed already forces "not equal". Whatever the short side reads there cannot
# change the answer.
src/shared/crypto/utils.ts::constantTimeEqual~1sr6g7q 0 → 1 # only read past the end of the shorter string, where the length XOR has already decided the result
src/shared/crypto/utils.ts::constantTimeEqual~0nflsgj 0 → 1 # same reader for the other side, reached only when the lengths already differ

# crypto/der.ts — this value is written into a Uint8Array element. Adding or
# subtracting 128 produces the same low eight bits, and Uint8Array discards all
# higher bits.
Expand Down Expand Up @@ -216,3 +225,9 @@ src/shared/listings-actions.ts::dayPriceFieldsFromInput.duration_days~1ugulhp 1
src/shared/listings-actions.ts::listingInputToEdge.listing_type~1lqe3go ?? → || # input.listingType is a non-empty picklist word when present, so the empty string never occurs
src/shared/listings-actions.ts::listingInputToEdge.months_per_unit~0ruet3x ?? → || # input.monthsPerUnit is a validated whole number or absent; its only falsy value 0 equals the fallback
src/shared/listings-actions.ts::validateListingEdges.orphanError~1juqee2 ?? → || # input.groupIds is an array when present, and arrays are always truthy

# db/listings/attendees.ts — fallbacks whose left side can never be a
# falsy-but-present value that differs from the fallback itself.
src/shared/db/listings/attendees.ts::listingAttendeeFilter.activeOnly~1bv0ikc ?? → || # activeOnly is boolean|undefined and the fallback is false, so false ?? false === false || false
src/shared/db/listings/attendees.ts::listingAttendeeFilter.kindScope~0taxexu ?? → || # kindScope is one of two non-empty words or undefined, so it is never falsy-but-present
src/shared/db/listings/attendees.ts::getListingWithAttendeeRaw.attendeeRaw~0x3k1f1 ?? → || # the row is an Attendee object or undefined, and an object is always truthy
6 changes: 6 additions & 0 deletions scripts/mutation/equivalent-mutants/shared-m-z.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,9 @@ src/shared/payment/row-state.ts::SortedAttendeeIdsSchema~1d17kt9 Refund claim a
# seeds.ts — two thresholds no seeded value can fall between.
src/shared/seeds.ts::prepareAttendee.paymentId~01ncynu 0 → 1 # a seeded listing's unit price is 0 or one of the demo prices (500 and up), so no listing sits between the two thresholds
src/shared/seeds.ts::createSeeds~0ghuowu 0 → 1 # the customisable listing always yields a delete plus one multi-row insert, so the list holds 0 or 2 statements, never 1

# superuser.ts — the cache generation's starting number. Only a CHANGE in the
# generation matters: a lookup snapshots it before its await and compares that
# snapshot with the current value, so every comparison is between two readings
# of the same counter. Starting the count anywhere gives the same answers.
src/shared/superuser.ts::%3cfile%3e~0ljtci5 0 → 1 # the generation is only ever compared against itself across an await, never against a fixed number
2 changes: 1 addition & 1 deletion src/shared/db/listings/attendees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type ListingAttendeeFilter = {
};

const listingAttendeeFilter = (
filter: boolean | ListingAttendeeFilter = false,
filter: boolean | ListingAttendeeFilter,
): Required<ListingAttendeeFilter> =>
typeof filter === "boolean"
? { activeOnly: filter, kindScope: "attendees" }
Expand Down
12 changes: 9 additions & 3 deletions src/shared/superuser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lazyRef, ttlCache } from "#fp";
import { lazyRef, range, ttlCache } from "#fp";
import { getEffectiveDomain } from "#shared/config.ts";
import { hashPassword } from "#shared/crypto/hashing.ts";
import { wrapDataKeyForPassword } from "#shared/crypto/keys.ts";
Expand Down Expand Up @@ -136,12 +136,17 @@ export const getSuperuserState = async (): Promise<SuperuserState> => {
const PASSWORD_ALPHABET =
"ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";

/** Each draw asks for twice the characters still needed, so one is almost
* always enough and even a dozen would be a freak run. Needing this many means
* the randomness source is handing back nothing usable. */
const MAX_PASSWORD_DRAWS = 100;

export const generateSuperuserPassword = (length = 12): string => {
const alphabetLength = PASSWORD_ALPHABET.length;
const maxValidByte = 256 - (256 % alphabetLength);
let result = "";

while (result.length < length) {
for (const _draw of range(0, MAX_PASSWORD_DRAWS)) {
// Rejection sampling: bytes past the last whole multiple of the alphabet
// are dropped so every character stays equally likely.
const bytes = crypto.getRandomValues(new Uint8Array(length * 2));
Expand All @@ -150,9 +155,10 @@ export const generateSuperuserPassword = (length = 12): string => {
.slice(0, length - result.length)
.map((byte) => PASSWORD_ALPHABET[byte % alphabetLength])
.join("");
if (result.length >= length) return result;
}

return result;
throw new Error("Could not draw enough random characters for a password");
};

export const createActivatedSuperuser = async (opts: {
Expand Down
25 changes: 25 additions & 0 deletions test/features/admin/attendees-list/page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,31 @@ describeWithEnv("the attendees browser page", { db: true }, () => {
describe("GET /admin/attendees", () => {
testRequiresAuth("/admin/attendees");

test("offers the export at its own address", async () => {
await seedRegistrationPair();
const html = await (await adminGet("/admin/attendees")).text();
expect(html).toContain("/admin/attendees/csv");
});

test("offers no check-in filter, which this page does not do", async () => {
await seedRegistrationPair();
const html = await (await adminGet("/admin/attendees")).text();
// The check-in bar links carry filter=in / filter=out when offered.
expect(html).not.toContain("filter=in");
expect(html).not.toContain("filter=out");
});

test("drops a date from the address, which this page does not use", async () => {
await seedRegistrationPair();
const html = await (
await adminGet("/admin/attendees?date=2026-01-01")
).text();
// A page that took dates would carry the chosen one through its own
// links and form fields; this one has no date control, so it forgets it.
expect(html).toContain("Alice");
expect(html).not.toContain("2026-01-01");
});

test("renders the attendees page with the registration", async () => {
const listing = await makeListing("Gala Night");
await createTestAttendeeDirect(listing.id, "Alice", "alice@example.com");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Spotting a member that vanished between resolving names and the
* transaction's own read.
*/

import { expect } from "@std/expect";
import { it as test } from "@std/testing/bdd";
import { missingMemberId } from "#routes/admin/catalog-transfer/import-listing.ts";

const found = new Map([
[1, {}],
[3, {}],
]);

test("reports nothing when every member was found", () => {
expect(missingMemberId([1, 3], found)).toBeNull();
expect(missingMemberId([], found)).toBeNull();
});

test("reports the first member that is missing, not one that is present", () => {
expect(missingMemberId([1, 2, 3], found)).toBe(2);
// Two gaps: the earlier one is the one reported.
expect(missingMemberId([2, 4], found)).toBe(2);
expect(missingMemberId([4, 2], found)).toBe(4);
});
11 changes: 0 additions & 11 deletions test/features/admin/catalog-transfer/import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect } from "@std/expect";
import { it as test } from "@std/testing/bdd";
import { t } from "#i18n";
import { importCatalog } from "#routes/admin/catalog-transfer/import.ts";
import { missingMemberId } from "#routes/admin/catalog-transfer/import-listing.ts";
import { execute } from "#shared/db/client.ts";
import {
getGroupPackagePrices,
Expand Down Expand Up @@ -97,16 +96,6 @@ describeWithEnv("catalog group import", { db: true }, () => {
});
});

test("missingMemberId finds the first gap", () => {
const found = new Map([
[1, {}],
[3, {}],
]);
expect(missingMemberId([1, 3], found)).toBeNull();
expect(missingMemberId([1, 2, 3], found)).toBe(2);
expect(missingMemberId([], found)).toBeNull();
});

describeWithEnv("in-tx member validation", { db: true }, () => {
test("rejects an import when a resolved member vanishes inside its transaction", async () => {
const member = await createTestListing({
Expand Down
26 changes: 26 additions & 0 deletions test/features/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ describe("route matching", () => {
expect(await response?.text()).toBe("complete");
});

test("prefers the route with more literal text, whichever order they are declared in", async () => {
// Both patterns match "/x/end" and both take one parameter, so the tie is
// broken by how much of the path is spelled out. Declaration order must
// not matter — that is the promise that lets tooling sort route files.
const headEnd: [string, () => Response] = [
"GET /:head/end",
() => new Response("head-end"),
];
const xTail: [string, () => Response] = [
"GET /x/:tail",
() => new Response("x-tail"),
];
for (const entries of [
[headEnd, xTail],
[xTail, headEnd],
]) {
const router = createRouter(Object.fromEntries(entries));
const response = await router(
new Request("http://localhost/x/end"),
"/x/end",
"GET",
);
expect(await response?.text()).toBe("head-end");
}
});

test("returns null when the method or path does not match", async () => {
const router = createRouter({ "GET /known": () => new Response("ok") });
const request = new Request("http://localhost/unknown");
Expand Down
18 changes: 18 additions & 0 deletions test/shared/crypto/hashing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ describe("password hashing", () => {
expect(iterations).toBe(getPbkdf2Iterations());
});

it("names the scheme it used, so a reader knows how to check it", async () => {
const hash = await hashPassword("password");
expect(hash.startsWith("pbkdf2:")).toBe(true);
});

it("reads the iteration count as decimal, so a hex count never passes", async () => {
const [prefix, iterations, salt, digest] = (
await hashPassword("password")
).split(":");
// The same count written as hex. Read as decimal it is 0, which PBKDF2
// refuses outright; read as hex it would be the real count and this
// stored digest would match, letting a hand-edited hash through.
const asHex = `0x${Number(iterations).toString(16)}`;
await expect(
verifyPassword("password", `${prefix}:${asHex}:${salt}:${digest}`),
).rejects.toThrow();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
});

it("uses the OWASP production iteration count when the test override is off", () => {
setFastPbkdf2ForTest(null);
try {
Expand Down
9 changes: 9 additions & 0 deletions test/shared/db/listing-prices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ describeWithEnv("listing_prices persistence", { db: true }, () => {
]);
});

test("syncListingPricesForIds rebuilds a single listing too", async () => {
const only = await createTestListing({ unitPrice: 450 });
await queryAll("DELETE FROM listing_prices WHERE price_type = 'base'");
await syncListingPricesForIds([only.id]);
expect(await priceRows(only.id)).toEqual([
{ price_id: "", price_type: "base", unit_price: 450 },
]);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

test("syncListingPricesForIds is a no-op for an empty id list", async () => {
await syncListingPricesForIds([]);
expect(await priceRows(987656)).toEqual([]);
Expand Down
Loading