commit b829b189a46480f42a31073937cafb7950d30e99
parent 289320c7cf669cc0c3de1ca0c322fc2eb7662478
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 13 Oct 2026 13:39:26 -0400
common: an article may not be called `new` (umtool's /articles/new is a page)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/common/lib/report/iterations.test.ts b/common/lib/report/iterations.test.ts
@@ -274,3 +274,11 @@ test("parseIteration: filed under its own article and number; parent and origina
test("projectOf: <root>/<id>/i<n>/", () => {
assert.equal(projectOf("/projects", "my-article", 3), path.join("/projects", "my-article", "i3"));
});
+
+test("an article may not be called `new` (umtool's /articles/new is a page)", async () => {
+ const paths = store();
+ await assert.rejects(
+ createIteration("new", { kind: "sweep", model: "claude-sonnet-5-5" }, paths),
+ /reserved/,
+ );
+});
diff --git a/common/lib/report/iterations.ts b/common/lib/report/iterations.ts
@@ -43,6 +43,7 @@ import { parseReport } from "./validate";
import {
ARTICLE_ITERATIONS_DIRNAME,
ArticleRegistryError,
+ assertArticleId,
articleDir,
articleFile,
withArticleStoreLock,
@@ -219,11 +220,7 @@ export function projectOf(projectsRoot: string, id: string, n: number): string {
return path.join(projectsRoot, id, iterationLabel(n));
}
-function assertId(id: unknown): asserts id is string {
- if (!isReportId(id)) {
- throw new ArticleRegistryError(`"${String(id)}" is not an article id (a lowercase slug: [a-z0-9][a-z0-9-]*, at most 64)`);
- }
-}
+const assertId: (id: unknown) => asserts id is string = assertArticleId;
function assertN(n: unknown): asserts n is number {
if (typeof n !== "number" || !Number.isInteger(n) || n < 1) {
diff --git a/common/lib/report/registry.ts b/common/lib/report/registry.ts
@@ -346,11 +346,18 @@ export function withArticleStoreLock<T>(
const problemLines = (problems: readonly Problem[]) => problems.map((p) => `${p.path || "(root)"}: ${p.message}`);
const problemKey = (p: Problem) => `${p.path}\u0000${p.message}`;
-function assertId(id: unknown): asserts id is string {
+// Ids an article may not take: umtool's `/articles/new` is a page (release 27 S8).
+export const RESERVED_ARTICLE_IDS: readonly string[] = ["new"];
+
+export function assertArticleId(id: unknown): asserts id is string {
if (!isReportId(id)) {
throw new ArticleRegistryError(`"${String(id)}" is not an article id (a lowercase slug: [a-z0-9][a-z0-9-]*, at most 64)`);
}
+ if (RESERVED_ARTICLE_IDS.includes(id)) {
+ throw new ArticleRegistryError(`"${id}" is reserved (umtool's /articles/${id} is a page): pick another article id`);
+ }
}
+const assertId: (id: unknown) => asserts id is string = assertArticleId;
async function writeIndex(paths: Pick<Paths, "articlesDir">, index: ArticlesIndex): Promise<void> {
await writeJsonAtomic(articlesIndexFile(paths), { published: index.published }, { mkdir: true });