: asapien/signet

commit c69ed96160b32fc7d7ebb591a51ed5ab053c3f3b
parent 847eac9620cbff7d42c334dfa5a4f87bea598a95
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 19 Sep 2026 03:29:07 +0530

Fix code review findings: extract http_method_str, remove unused code

- Extract http_method_str() from signet-api.c and pim-api.c to http.c
  (eliminates duplicated code; identical implementations in both files)
- Remove unused http_status_code() function from http.c
- Remove log_request_error() pass-through wrapper; callers now invoke
  log_request() directly (cleaner, no indirection)

Addresses Standards axis violations (duplicated code, speculative generality,
middle-man wrapper) and simplifies the codebase.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
14 files changed, 243 insertions(+), 67 deletions(-)
A
.scratch/rebuild/issues/01-syslog-logging.md
|
16
++++++++++++++++
A
.scratch/rebuild/issues/02-rename-and-render-gate.md
|
22
++++++++++++++++++++++
A
.scratch/rebuild/issues/03-organisation-pim-imprints.md
|
24
++++++++++++++++++++++++
A
.scratch/rebuild/issues/04-parties-zones-decisions.md
|
34
++++++++++++++++++++++++++++++++++
A
.scratch/rebuild/issues/05-facsimile-enrolment.md
|
27
+++++++++++++++++++++++++++
A
.scratch/rebuild/issues/06-overlay-and-release.md
|
30
++++++++++++++++++++++++++++++
A
.scratch/rebuild/issues/07-template-series-lifecycle.md
|
24
++++++++++++++++++++++++
A
.scratch/rebuild/issues/08-clip-circular-seals.md
|
15
+++++++++++++++
A
.scratch/rebuild/issues/09-docs-and-acceptance.md
|
21
+++++++++++++++++++++
M
pim/pim-api.c
|
24
+++++-------------------
M
src/http.c
|
36
++++++++++--------------------------
M
src/http.h
|
4
+---
M
src/signet-api.c
|
24
+++++-------------------
A
todo.txt
|
9
+++++++++
diff --git a/.scratch/rebuild/issues/01-syslog-logging.md b/.scratch/rebuild/issues/01-syslog-logging.md
@@ -0,0 +1,16 @@
+# 01: syslog logging in signet-api and pim-api
+
+**What to build:** When a request fails inside either FastCGI program — a SQL
+error, a Redis error, a validation failure that returns 4xx/5xx — the reason
+appears in the container's log (and in production, in syslog) with the request
+path and the acting user. Today `kfcgi` detaches and stderr goes nowhere, so
+these failures are invisible. Every later ticket is debugged through this.
+
+**Blocked by:** None (can start immediately).
+
+**Status:** ready-for-agent
+
+- [ ] Both programs open syslog at startup (identity `signet-api` / `pim-api`) and log every `db_q`/`db_do` failure with the PostgreSQL error text
+- [ ] Every non-2xx response is logged once, with method, path, user and the error string sent to the client
+- [ ] In the dev container the messages are readable (`syslogd` or an equivalent log sink runs in `dev-up.sh`), and `AGENTS.md`'s build/run/test section says where to look
+- [ ] `e2e.sh` still ends with "all passed"; RSS unchanged within noise
diff --git a/.scratch/rebuild/issues/02-rename-and-render-gate.md b/.scratch/rebuild/issues/02-rename-and-render-gate.md
@@ -0,0 +1,22 @@
+# 02: Rename to the glossary and generalise the render gate, no behaviour change
+
+**What to build:** A prefactor. The code, config, schema, client and tests use
+the glossary's words (`CONTEXT.md`) and the new status names, and the
+"worker is busy" gate can carry more than one kind of render job — while the
+old stamping and routing logic keeps working exactly as before. After this
+ticket a fresh session can implement the new model without fighting names.
+
+See `docs/REBUILD.md` §2 (schema), §3 (roles) for the target shapes.
+
+**Blocked by:** None (can start immediately; ticket 01 is recommended first
+because it makes SQL errors visible).
+
+**Status:** ready-for-agent
+
+- [ ] Roles are `drafter`, `signer`, `admin`, `pim_admin` in config, `GET /me`, dev groups and tests; no `maker`/`approver` remains anywhere
+- [ ] Statuses are `DRAFT, PENDING, CORRECTION_REQUIRED, DISAPPROVED, RELEASED`; a resubmit logs a `RESUBMITTED` event instead of entering a `CORRECTED` status
+- [ ] `customer` is gone from schema, API, save payload, side panel, dashboard and e2e
+- [ ] `drafter_user`, `current_party`, `released_at` replace the old column names; `render_seq`/`rendered_seq`/`render_kind` replace `rendered_revision`, with submit and retry setting `render_kind = 'stamp'` and the worker completing by `seq`
+- [ ] Decision values are `SIGNOFF / CORRECTION / DISAPPROVE`; the UI says "Sign off", "Request correction", "Disapprove"
+- [ ] The old route (`levels`, `any`/`all`) and stamp-at-submit behaviour are untouched; `e2e.sh` (renamed where needed) ends with "all passed"
+- [ ] `grep -rn 'maker\|approver\|customer\|current_level\|rendered_revision\|PENDING_APPROVAL\|CORRECTED\b\|APPROVED' src www sql test etc pim` returns nothing
diff --git a/.scratch/rebuild/issues/03-organisation-pim-imprints.md b/.scratch/rebuild/issues/03-organisation-pim-imprints.md
@@ -0,0 +1,24 @@
+# 03: Organisation-bound PIM imprints, image attributes, mandatory title
+
+**What to build:** A `pim_admin` maintains organisations in the PIM editor,
+each with text attributes (`gstin`, `bank_account`, …) and image attributes
+(`seal`, `logo`, … — a picture on the DAM). A drafter picks the organisation a
+document is about, places imprints that reference a bare key, and the proof
+shows that organisation's values and seal. The same template serves every
+organisation. A document cannot be submitted without a title or an
+organisation, or when the organisation lacks a key the layout uses.
+
+See `docs/REBUILD.md` §2 (`org_code`, `attr_type`, Redis hashes), §4 (imprint
+types), §5 (`/save`, `/submit`, `/pim`), §6 (`stamp` resolution), §7, §8.
+
+**Blocked by:** 02 (rename and render gate).
+
+**Status:** ready-for-agent
+
+- [ ] PIM editor: organisation list with "new", per-attribute type toggle, image picker fed by the DAM listing; writes need `pim_admin`, reads are open (D24)
+- [ ] `GET /api/pim` returns organisations and, per organisation, text and image attributes; the Redis mirror carries both plus the organisation set
+- [ ] Side panel: title input (submit disabled while empty), organisation selector; `pim_text`/`pim_image` props offer that organisation's keys; edit mode shows the resolved value, or the key in brackets when no organisation is chosen
+- [ ] `dam_image` and `poly` are rejected by save; `pim_image` supports `rect` and `circle`
+- [ ] Submit fails with a clear message for: empty title, no organisation, a text key or image key the organisation lacks, an image whose DAM file is missing
+- [ ] Worker resolves text and image keys against the document's organisation; proof text contains the organisation's GSTIN and the seal image
+- [ ] e2e covers two organisations (one lacking a key), all rejection cases, and a successful proof; ends with "all passed"
diff --git a/.scratch/rebuild/issues/04-parties-zones-decisions.md b/.scratch/rebuild/issues/04-parties-zones-decisions.md
@@ -0,0 +1,34 @@
+# 04: Parties, signature zones, sequential decisions
+
+**What to build:** The route is an ordered list of parties (*Manager*,
+*Partner*), each with exactly one signer chosen by the drafter. The drafter
+reserves at most one signature zone per party, with a minimum size; a party
+with no zone is check-only. Parties act strictly one after another: only the
+current party's signer can see the pending document or decide, and the next
+party cannot until the one before has signed off. A sign-off on a zone party
+carries a placement that must lie inside the zone and meet the minimum size;
+it is recorded with the decision (drawing it is ticket 06). Correction requests
+restart the route from the first party; disapproval is terminal; a user may
+draft and sign their own document. The old `levels`/`any`/`all` route,
+username-referenced signature boxes and stamp-at-submit facsimiles are gone.
+
+Release still runs through the existing synchronous path at the last sign-off
+(audit page listing the released revision's sign-offs); ticket 06 moves it.
+
+See `docs/REBUILD.md` §2 (`doc_decisions`, `current_party`), §4 (route and
+zone JSON), §5 (`/save`, `/decide`, `/docs`, `GET /docs/<id>`), §8 (parties
+editor, zone props, decision bar).
+
+**Blocked by:** 02 (rename and render gate).
+
+**Status:** ready-for-agent
+
+- [ ] Save validates: 1–20 parties with unique safe names and safe signer names; every zone names a party in the route; at most one zone per party; `min_w × min_h` fits inside the zone
+- [ ] Submit rejects a party without a signer; sets `current_party = 1`
+- [ ] Only the current party's signer can decide (409 otherwise); a signer at a later party gets 404 on the document
+- [ ] Check-only sign-off advances `current_party` with no render job; zone sign-off requires a placement on the zone's page, inside the zone, at least the minimum size, and stores it with the decision
+- [ ] Correction request → `CORRECTION_REQUIRED`, resubmit → revision+1, `current_party = 1`, `RESUBMITTED` event, same serial and document date; disapproval → `DISAPPROVED`, comment required, delete refused
+- [ ] Last party's sign-off releases through the existing path; `RELEASED` with `final_sha256`
+- [ ] Client: parties editor (name + signer, add/remove/reorder), zone palette item with party dropdown and min size, decision bar with the three decisions, placement box for zone parties constrained to the zone (an `<area>` like any imprint), dashboard "Waiting on" column
+- [ ] Templates created from a document carry parties and zones
+- [ ] e2e covers validation cases, the two-party happy path, the correction round, the disapproval, and a self-service one-party document; ends with "all passed"
diff --git a/.scratch/rebuild/issues/05-facsimile-enrolment.md b/.scratch/rebuild/issues/05-facsimile-enrolment.md
@@ -0,0 +1,27 @@
+# 05: Facsimile enrolment
+
+**What to build:** A signer who has never signed before is asked, at their
+first zone sign-off, to sign in the browser — draw on a signature pad or
+upload a PNG. The image becomes their enrolled facsimile and is reused on
+every later document. An admin can enrol a facsimile on someone's behalf. The
+API handles the image only in that one request and hands it to the worker
+through an inbox; only the worker ever writes to or reads the facsimile store.
+Until a signer is enrolled, their zone sign-off is refused with a message that
+says so.
+
+See `docs/REBUILD.md` §2 (`facsimiles`), §3 (`sig_inbox`), §5 (`/me`,
+`/me/facsimile`, `/facsimiles`, the enrolment check in `/decide`), §6 (`enrol`
+job), §8 (enrolment dialog).
+
+**Blocked by:** 04 (parties, zones, decisions).
+
+**Status:** ready-for-agent
+
+- [ ] `facsimiles` table with `enrolled_at`, `enrolled_by`, `width`, `height`; dev seeding enrols `ceo` and `manager` to match the seeded files
+- [ ] Inbox directory owned by the worker's user, creatable-but-not-listable by the API user, created by install and by the dev entrypoint
+- [ ] Self and admin enrolment endpoints accept one PNG (≤ 1 MB, signature bytes checked), write it to the inbox, upsert the row with `enrolled_at = NULL`, enqueue an `enrol` job
+- [ ] Worker validates the PNG with libpng, copies it into the facsimile store (worker-owned, 0600), removes the inbox file, sets `enrolled_at`, `width`, `height`, logs `ENROLLED`; a bad file is discarded and the row stays un-enrolled
+- [ ] `GET /me` reports `enrolled` and the image size; `GET /docs/<id>` reports `needs_enrolment`
+- [ ] Zone sign-off by an un-enrolled signer → 409 "enrol your signature first"
+- [ ] Client: enrolment dialog (canvas pad with pointer events exporting a transparent PNG, or file input), posts, polls `/me` until enrolled, then continues to the placement step
+- [ ] e2e: decide before enrolment → 409; enrol with the fixture PNG; poll; decide succeeds; admin enrolment for another user; ends with "all passed"
diff --git a/.scratch/rebuild/issues/06-overlay-and-release.md b/.scratch/rebuild/issues/06-overlay-and-release.md
@@ -0,0 +1,30 @@
+# 06: Facsimile overlay at sign-off, release in the worker with the full audit page
+
+**What to build:** When a zone party signs off, the worker draws that
+signer's enrolled facsimile at the recorded placement onto the stamped copy,
+so the next party sees every signature given so far. When the last party
+signs off, the worker overlays the final facsimile, appends the audit page —
+the document's whole event log across all revisions, plus the SHA-256 of the
+pages before it — and writes the release; only then does the document become
+`RELEASED`. Imprints are never re-rendered after submit, so a seal or font
+replaced on the DAM mid-route cannot change a pending or released document.
+Retry works for stamping, signing and release. The client auto-fits the
+placement box to the signer's facsimile proportions and shows "rendering…"
+while any render job is outstanding.
+
+See `docs/REBUILD.md` §5 (`/decide` job enqueueing, `/rerender`, `render()`
+deletion), §6 (`sign`, `release` jobs, audit lines), §8 (auto-fit, polling),
+§9 steps 5–6, §12.
+
+**Blocked by:** 04 (parties, zones, decisions), 05 (facsimile enrolment).
+
+**Status:** ready-for-agent
+
+- [ ] Zone sign-off enqueues a `sign` job; the worker overlays one PNG at the placement (fit inside it, proportions kept, centred) onto the stamped copy atomically and logs `SIGNED`
+- [ ] Last sign-off enqueues a `release` job; the worker overlays if needed, builds the audit lines from the document and every event (all revisions, with comments), renders the release, sets `RELEASED`, `final_sha256`, `released_at` in one statement, removes the stamped copy, logs `RELEASED`; the API's synchronous release path is deleted
+- [ ] The next party can decide only once the previous sign job has rendered; the stamped copy fetched by a later signer contains the earlier facsimile
+- [ ] Failure of a sign or release job sets `render_error`; retry re-enqueues the stored kind and is allowed for the drafter (stamp), the current/last signer or admin (sign/release), 403 otherwise
+- [ ] Client: placement box starts at the auto fit from `GET /me` size, adjustable within the zone and minimum; polling while `rendering`; retry button shown to whoever may retry
+- [ ] Replacing the seal file on the DAM after submit leaves the stamped copy and the release byte-identical
+- [ ] e2e: image count grows on the stamped copy after the zone sign-off; release text contains `SUBMITTED`, `SIGNED`, `RELEASED` and, on the corrected document, the correction comment; ends with "all passed"
+- [ ] Visual check: placement box and rendered facsimile coincide; earlier facsimile visible to the next party
diff --git a/.scratch/rebuild/issues/07-template-series-lifecycle.md b/.scratch/rebuild/issues/07-template-series-lifecycle.md
@@ -0,0 +1,24 @@
+# 07: Template and series lifecycle: retire, unlink, delete
+
+**What to build:** An admin can retire a template or a series so drafters no
+longer see it, while everything already made from it keeps working. A
+retired series keeps its pattern and counters forever and can never be
+deleted or re-patterned once a serial has been issued. A template can be
+deleted only after an admin has unlinked every document made from it;
+documents are self-contained copies, so unlinking loses nothing but the
+back-reference. Templates carry their parties (with default signers) and
+zones into new documents.
+
+See `docs/REBUILD.md` §2 (`retired_at`), §5 (templates and series endpoints,
+`/docs/<id>/unlink`), §8 (admin views), §9 step 9.
+
+**Blocked by:** 04 (parties, zones, decisions).
+
+**Status:** ready-for-agent
+
+- [ ] Retire endpoints for templates and series (admin); retired items are hidden from drafters and cannot be used to create or submit; admin listings show them with the retired date
+- [ ] There is no series delete or re-pattern endpoint at all; submit against a retired series is refused; a retired series' counters keep counting for already-submitted documents' resubmits (serial unchanged)
+- [ ] Template listing includes the count of linked documents; delete is refused with 409 while any document links; unlink (admin) clears the back-reference and logs `UNLINKED`; delete then removes the template row and PDF
+- [ ] A new document from a template carries parties, default signers and zones
+- [ ] Client: retire buttons in the templates and series views, delete with the linked count and the 409 message, unlink from the document side panel (admin)
+- [ ] e2e step 9 passes; suite ends with "all passed"
diff --git a/.scratch/rebuild/issues/08-clip-circular-seals.md b/.scratch/rebuild/issues/08-clip-circular-seals.md
@@ -0,0 +1,15 @@
+# 08: Clip circular seals
+
+**What to build:** A `circle` image imprint is actually clipped to the circle
+in the proof, matching what the editor shows, instead of being drawn as its
+full bounding box. Optional polish (HANDOFF §4.5); do it only if it is cheap
+in the PDF writer with a clip path and does not change the RSS or the
+edit-vs-proof geometry contract.
+
+**Blocked by:** 03 (organisation-bound PIM imprints).
+
+**Status:** ready-for-agent
+
+- [ ] A square seal image placed as a circle renders with its corners clipped; a rectangle imprint is unchanged
+- [ ] Edit mode and proof agree visually on both fixture pages
+- [ ] If the clip path is not cheap, the ticket is closed with a note in the handoff saying why the bounding-box behaviour stays
diff --git a/.scratch/rebuild/issues/09-docs-and-acceptance.md b/.scratch/rebuild/issues/09-docs-and-acceptance.md
@@ -0,0 +1,21 @@
+# 09: Docs, invariants and acceptance sweep
+
+**What to build:** The repository's own description of itself matches the
+rebuilt code, and the rebuild's acceptance list is verified end to end. A new
+session reading `AGENTS.md`, `HANDOFF.md` and `README.md` learns the party
+model, not the 2026-09-18 one.
+
+See `docs/REBUILD.md` §10 (what to update, with the new invariant wording)
+and §12 (acceptance).
+
+**Blocked by:** 03, 06, 07, 08.
+
+**Status:** ready-for-agent
+
+- [ ] `AGENTS.md` invariants 4, 5, 6 rewritten as specified; role wording, dev groups and build/test notes current; the "invariants describe the 2026-09-18 code" note removed
+- [ ] `HANDOFF.md` §1 status and e2e count current; §3 map, disk layout, request flow and JSON shapes describe the new code; §4 items settled by the rebuild moved to done; the stale "nothing is committed" lines removed
+- [ ] `README.md` describes the drafter → parties → release flow, enrolment and PIM organisations
+- [ ] `CONTEXT.md` untouched unless a term changed meaning during the build; any such change is called out in the summary
+- [ ] `grep -rn 'customer\|current_level\|PENDING_APPROVAL\|"any"\|maker' src www sql test etc` returns nothing
+- [ ] RSS of all processes with two API workers measured and recorded in `HANDOFF.md` §1, ≤ 60 MB
+- [ ] Full `e2e.sh` ends with "all passed"; the visual check from `AGENTS.md` done on both pages
diff --git a/pim/pim-api.c b/pim/pim-api.c
@@ -88,20 +88,6 @@ h_upsert(struct kreq *r, PGconn *pg)
 		send_json(r, KHTTP_200, "{\"ok\":true}");
 }
 
-static const char *
-http_method_str(enum kmethod m)
-{
-	switch (m) {
-	case KMETHOD_GET: return "GET";
-	case KMETHOD_POST: return "POST";
-	case KMETHOD_HEAD: return "HEAD";
-	case KMETHOD_PUT: return "PUT";
-	case KMETHOD_DELETE: return "DELETE";
-	case KMETHOD_OPTIONS: return "OPTIONS";
-	default: return "?";
-	}
-}
-
 static void
 dispatch(struct kreq *r)
 {

@@ -115,12 +101,12 @@ dispatch(struct kreq *r)
 	ident_read(r, &cf, &id);
 	if (id.user == NULL) {
 		send_err(r, KHTTP_401, "no authenticated user");
-		log_request_error(method, r->fullpath, id.user, 401, "no authenticated user");
+		log_request(method, r->fullpath, id.user, 401, "no authenticated user");
 		return;
 	}
 	if ((pg = db_get(&cf)) == NULL) {
 		send_err(r, KHTTP_503, "database unavailable");
-		log_request_error(method, r->fullpath, id.user, 503, "database unavailable");
+		log_request(method, r->fullpath, id.user, 503, "database unavailable");
 		return;
 	}
 	n = http_path(r, buf, sizeof(buf), seg, 2);

@@ -130,7 +116,7 @@ dispatch(struct kreq *r)
 		    "ORDER BY entity_code, attr_key) t", 0, NULL);
 		if (res == NULL) {
 			send_err(r, KHTTP_500, "database error");
-			log_request_error(method, r->fullpath, id.user, 500, "database error");
+			log_request(method, r->fullpath, id.user, 500, "database error");
 		} else {
 			send_json(r, KHTTP_200, PQgetvalue(res, 0, 0));
 			PQclear(res);

@@ -139,7 +125,7 @@ dispatch(struct kreq *r)
 	}
 	if (!http_post_ok(r) || !ident_has_role(&id, &cf, "pim_admin")) {
 		send_err(r, KHTTP_403, "pim_admin role required");
-		log_request_error(method, r->fullpath, id.user, 403, "pim_admin role required");
+		log_request(method, r->fullpath, id.user, 403, "pim_admin role required");
 		return;
 	}
 	if (n == 1 && strcmp(seg[0], "attrs") == 0)

@@ -148,7 +134,7 @@ dispatch(struct kreq *r)
 		h_resync(r, pg);
 	else {
 		send_err(r, KHTTP_404, "not found");
-		log_request_error(method, r->fullpath, id.user, 404, "not found");
+		log_request(method, r->fullpath, id.user, 404, "not found");
 	}
 }
 
diff --git a/src/http.c b/src/http.c
@@ -133,32 +133,16 @@ send_file(struct kreq *r, const char *path, const char *mime, const char *name)
 	fclose(f);
 }
 
-static int
-http_status_code(enum khttp code)
+const char *
+http_method_str(enum kmethod m)
 {
-	switch (code) {
-	case KHTTP_200: return 200;
-	case KHTTP_201: return 201;
-	case KHTTP_204: return 204;
-	case KHTTP_301: return 301;
-	case KHTTP_302: return 302;
-	case KHTTP_304: return 304;
-	case KHTTP_400: return 400;
-	case KHTTP_401: return 401;
-	case KHTTP_403: return 403;
-	case KHTTP_404: return 404;
-	case KHTTP_405: return 405;
-	case KHTTP_409: return 409;
-	case KHTTP_500: return 500;
-	case KHTTP_501: return 501;
-	case KHTTP_503: return 503;
-	default: return 500;
+	switch (m) {
+	case KMETHOD_GET: return "GET";
+	case KMETHOD_POST: return "POST";
+	case KMETHOD_HEAD: return "HEAD";
+	case KMETHOD_PUT: return "PUT";
+	case KMETHOD_DELETE: return "DELETE";
+	case KMETHOD_OPTIONS: return "OPTIONS";
+	default: return "?";
 	}
 }
-
-void
-log_request_error(const char *method, const char *path,
-    const char *user, int status, const char *msg)
-{
-	log_request(method, path, user, status, msg);
-}
diff --git a/src/http.h b/src/http.h
@@ -31,8 +31,6 @@ void send_json(struct kreq *, enum khttp, const char *body);
 void send_err(struct kreq *, enum khttp, const char *msg);
 void send_file(struct kreq *, const char *path, const char *mime,
     const char *download_name);
-/* log a request response; call after send_err for errors */
-void log_request_error(const char *method, const char *path,
-    const char *user, int status, const char *msg);
+const char *http_method_str(enum kmethod);
 
 #endif
diff --git a/src/signet-api.c b/src/signet-api.c
@@ -933,20 +933,6 @@ h_dam(struct kreq *r)
 
 /* --- dispatch -------------------------------------------------------------- */
 
-static const char *
-http_method_str(enum kmethod m)
-{
-	switch (m) {
-	case KMETHOD_GET: return "GET";
-	case KMETHOD_POST: return "POST";
-	case KMETHOD_HEAD: return "HEAD";
-	case KMETHOD_PUT: return "PUT";
-	case KMETHOD_DELETE: return "DELETE";
-	case KMETHOD_OPTIONS: return "OPTIONS";
-	default: return "?";
-	}
-}
-
 static void
 dispatch(struct kreq *r)
 {

@@ -959,17 +945,17 @@ dispatch(struct kreq *r)
 	ident_read(r, &cf, &id);
 	if (id.user == NULL) {
 		send_err(r, KHTTP_401, "no authenticated user");
-		log_request_error(method, r->fullpath, id.user, 401, "no authenticated user");
+		log_request(method, r->fullpath, id.user, 401, "no authenticated user");
 		return;
 	}
 	if (!get && !http_post_ok(r)) {
 		send_err(r, KHTTP_403, "POST with X-Requested-With: signet required");
-		log_request_error(method, r->fullpath, id.user, 403, "POST with X-Requested-With: signet required");
+		log_request(method, r->fullpath, id.user, 403, "POST with X-Requested-With: signet required");
 		return;
 	}
 	if ((pg = db_get(&cf)) == NULL) {
 		send_err(r, KHTTP_503, "database unavailable");
-		log_request_error(method, r->fullpath, id.user, 503, "database unavailable");
+		log_request(method, r->fullpath, id.user, 503, "database unavailable");
 		return;
 	}
 	n = http_path(r, buf, sizeof(buf), seg, 5);

@@ -1003,11 +989,11 @@ dispatch(struct kreq *r)
 			h_doc_delete(r, pg, &id, seg[1]);
 		else {
 			send_err(r, KHTTP_404, "not found");
-			log_request_error(method, r->fullpath, id.user, 404, "not found");
+			log_request(method, r->fullpath, id.user, 404, "not found");
 		}
 	} else {
 		send_err(r, KHTTP_404, "not found");
-		log_request_error(method, r->fullpath, id.user, 404, "not found");
+		log_request(method, r->fullpath, id.user, 404, "not found");
 	}
 }
 
diff --git a/todo.txt b/todo.txt
@@ -0,0 +1,9 @@
+(A) 2026-09-19 syslog logging in signet-api and pim-api +api +pim +ops status:ready-for-agent id:1 spec:docs/REBUILD.md note:.scratch/rebuild/issues/01-syslog-logging.md
+(A) 2026-09-19 Rename to the glossary and generalise the render gate, no behaviour change +api +worker +client +schema +test +ops status:ready-for-agent id:2 spec:docs/REBUILD.md note:.scratch/rebuild/issues/02-rename-and-render-gate.md
+(B) 2026-09-19 Organisation-bound PIM imprints, image attributes, mandatory title +api +worker +render +client +pim +schema +test status:ready-for-agent id:3 blockedby:2 spec:docs/REBUILD.md note:.scratch/rebuild/issues/03-organisation-pim-imprints.md
+(B) 2026-09-19 Parties, signature zones, sequential decisions +api +worker +client +schema +test status:ready-for-agent id:4 blockedby:2 spec:docs/REBUILD.md note:.scratch/rebuild/issues/04-parties-zones-decisions.md
+(B) 2026-09-19 Facsimile enrolment +api +worker +client +schema +ops +test status:ready-for-agent id:5 blockedby:4 spec:docs/REBUILD.md note:.scratch/rebuild/issues/05-facsimile-enrolment.md
+(B) 2026-09-19 Facsimile overlay at sign-off, release in the worker with the full audit page +api +worker +render +client +test status:ready-for-agent id:6 blockedby:4,5 spec:docs/REBUILD.md note:.scratch/rebuild/issues/06-overlay-and-release.md
+(B) 2026-09-19 Template and series lifecycle: retire, unlink, delete +api +client +schema +test status:ready-for-agent id:7 blockedby:4 spec:docs/REBUILD.md note:.scratch/rebuild/issues/07-template-series-lifecycle.md
+(C) 2026-09-19 Clip circular seals +render +test status:ready-for-agent id:8 blockedby:3 spec:docs/REBUILD.md note:.scratch/rebuild/issues/08-clip-circular-seals.md
+(B) 2026-09-19 Docs, invariants and acceptance sweep +docs +test +ops status:ready-for-agent id:9 blockedby:3,6,7,8 spec:docs/REBUILD.md note:.scratch/rebuild/issues/09-docs-and-acceptance.md