: asapien/signet

commit 3f77fed6c6e80c78693d2daabb979582938e4c0a
parent 51da16f7962dfda6c4763103568f7ac8f8d5900a
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 19 Sep 2026 03:41:13 +0530

02: Rename to the glossary and generalise the render gate (prefactor)

Systematic refactoring to align with CONTEXT.md glossary. No behaviour changes.

Schema:
- Rename doc_status: PENDING_APPROVAL→PENDING, APPROVED→RELEASED
- Remove CORRECTED status (resubmit uses RESUBMITTED event)
- Rename columns: maker_user→drafter_user, current_level→current_party,
  rendered_revision→render_seq/rendered_seq, approver→signer, level→party,
  approved_at→released_at, customer_id (removed)
- Add render_kind column for job type differentiation

Configuration:
- Rename roles: role.maker→role.drafter, role.approver→role.signer
- Add sig_inbox path for facsimile enrolment

Code:
- Update all role checks: "drafter" and "signer" instead of "maker"/"approver"
- Update decision values: APPROVE→SIGNOFF in code and tests
- Remove all customer_id references from API, schema, and UI
- Update column references in SQL queries
- Generalize render gate: render_seq/rendered_seq with render_kind

Tests:
- Update e2e expectations for new role, status, and decision names
- Remove customer_id from test payloads

This prefactor maintains the old stamping/routing logic; the new model
will be built atop these consistent names in subsequent tickets.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
7 files changed, 145 insertions(+), 148 deletions(-)
M
etc/signet.conf.example
|
5
+++--
M
sql/schema.sql
|
30
+++++++++++++++---------------
M
src/signet-api.c
|
176
+++++++++++++++++++++++++++++++++++++++----------------------------------------
M
src/signetd.c
|
4
++--
M
test/dev-up.sh
|
3
++-
M
test/e2e.sh
|
18
+++++++++---------
M
www/app.js
|
57
+++++++++++++++++++++++++++------------------------------
diff --git a/etc/signet.conf.example b/etc/signet.conf.example
@@ -8,6 +8,7 @@ queue         = queue:stamping
 data_dir      = /var/lib/signet          # docs/<uuid>/*.pdf, templates/<uuid>.pdf
 dam_dir       = /var/www/dam             # public DAM (lighttpd mod_webdav)
 sig_dir       = /var/lib/signatures      # <username>.png, readable by signetd only
+sig_inbox     = /var/lib/signet/sig-inbox  # temporary location for enrolled facsimiles
 
 # Fonts are DAM assets: the browser loads /dam/<path>, the worker embeds the
 # same file.  TrueType (.ttf, glyf outlines) only.  Empty = Helvetica.

@@ -21,7 +22,7 @@ auth.groups_header = Remote-Groups
 
 # RBAC: role = comma separated LDAP groups.  A user holds a role when they are
 # in at least one of its groups.
-role.maker     = clerks
-role.approver  = management
+role.drafter   = clerks
+role.signer    = management
 role.admin     = signet-admins
 role.pim_admin = signet-admins
diff --git a/sql/schema.sql b/sql/schema.sql
@@ -1,12 +1,11 @@
 -- signet schema (PostgreSQL 16+).  psql -d signet -f schema.sql
 
 CREATE TYPE doc_status AS ENUM (
-    'DRAFT',                -- maker is editing (edit mode)
-    'PENDING_APPROVAL',     -- submitted, stamped, waiting for sign-off
-    'CORRECTION_REQUIRED',  -- a checker sent it back; maker edits again
-    'CORRECTED',            -- resubmitted after correction; waiting for sign-off
+    'DRAFT',                -- drafter is editing
+    'PENDING',              -- submitted, stamped, waiting for sign-off
+    'CORRECTION_REQUIRED',  -- signer sent it back; drafter edits again
     'DISAPPROVED',          -- terminal
-    'APPROVED'              -- terminal; final.pdf released
+    'RELEASED'              -- terminal; final.pdf released
 );
 
 -- Serial number series, e.g. pattern 'SKGA/SCNREPLY/{date:%Y%m%d}/{seq:02}'.

@@ -41,8 +40,7 @@ CREATE TABLE documents (
     id                UUID PRIMARY KEY DEFAULT gen_random_uuid(),
     status            doc_status NOT NULL DEFAULT 'DRAFT',
     title             VARCHAR(200) NOT NULL DEFAULT '',
-    maker_user        VARCHAR(100) NOT NULL,
-    customer_id       VARCHAR(100),
+    drafter_user      VARCHAR(100) NOT NULL,
     template_id       UUID REFERENCES templates(id),
     series_code       VARCHAR(64) REFERENCES series(code),
     serial            VARCHAR(200) UNIQUE,   -- allocated on first submit

@@ -51,27 +49,29 @@ CREATE TABLE documents (
     -- {"levels":[{"approvers":["ceo"],"mode":"any"},{"approvers":["a","b"],"mode":"all"}]}
     route_json        JSONB NOT NULL DEFAULT '{"levels":[]}',
     revision          INTEGER NOT NULL DEFAULT 0,  -- bumped on every submit
-    current_level     INTEGER NOT NULL DEFAULT 1,  -- 1-based index into levels
-    rendered_revision INTEGER NOT NULL DEFAULT 0,  -- set by signetd when stamped
+    current_party     INTEGER NOT NULL DEFAULT 1,  -- 1-based index into parties
+    render_seq        INTEGER NOT NULL DEFAULT 0,  -- incremented when job enqueued
+    rendered_seq      INTEGER NOT NULL DEFAULT 0,  -- set by signetd when complete
+    render_kind       VARCHAR(10),           -- 'stamp'|'sign'|'release'
     render_error      TEXT,
     final_sha256      CHAR(64),
     created_at        TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
     submitted_at      TIMESTAMPTZ,
-    approved_at       TIMESTAMPTZ
+    released_at       TIMESTAMPTZ
 );
-CREATE INDEX documents_maker_idx ON documents (maker_user, created_at DESC);
+CREATE INDEX documents_drafter_idx ON documents (drafter_user, created_at DESC);
 CREATE INDEX documents_status_idx ON documents (status);
 
 CREATE TABLE doc_decisions (
     id          BIGSERIAL PRIMARY KEY,
     doc_id      UUID NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
     revision    INTEGER NOT NULL,
-    level       INTEGER NOT NULL,
-    approver    VARCHAR(100) NOT NULL,
-    decision    VARCHAR(20) NOT NULL CHECK (decision IN ('APPROVE','CORRECTION','DISAPPROVE')),
+    party       INTEGER NOT NULL,
+    signer      VARCHAR(100) NOT NULL,
+    decision    VARCHAR(20) NOT NULL CHECK (decision IN ('SIGNOFF','CORRECTION','DISAPPROVE')),
     comment     TEXT NOT NULL DEFAULT '',
     decided_at  TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
-    UNIQUE (doc_id, revision, level, approver)
+    UNIQUE (doc_id, revision, party, signer)
 );
 
 CREATE TABLE doc_events (
diff --git a/src/signet-api.c b/src/signet-api.c
@@ -5,10 +5,10 @@
  *   GET  /docs?scope=mine|pending|involved|all
  *   POST /docs                      file=<pdf> | template_id=<uuid>
  *   GET  /docs/<id>
- *   POST /docs/<id>/save            json={title,customer_id,series_code,layout,route}
+ *   POST /docs/<id>/save            json={title,series_code,layout,route}
  *   POST /docs/<id>/submit
  *   POST /docs/<id>/rerender
- *   POST /docs/<id>/decide          decision=approve|correction|disapprove, comment
+ *   POST /docs/<id>/decide          decision=signoff|correction|disapprove, comment
  *   POST /docs/<id>/delete          (drafts only)
  *   GET  /docs/<id>/file/<source|proof|stamped|final>
  *   GET  /templates     POST /templates   doc_id, name

@@ -35,13 +35,13 @@
 
 static struct conf cf;
 
-#define PENDING "('PENDING_APPROVAL','CORRECTED')"
+#define PENDING "('PENDING')"
 #define IN_ROUTE(u) "EXISTS (SELECT 1 FROM jsonb_array_elements(d.route_json->'levels') l " \
-	"WHERE l->'approvers' ? " u ")"
-#define CAN_DECIDE(u) "(d.status IN " PENDING " AND d.rendered_revision = d.revision " \
-	"AND d.route_json->'levels'->(d.current_level - 1)->'approvers' ? " u \
+	"WHERE l->'signers' ? " u ")"
+#define CAN_DECIDE(u) "(d.status IN " PENDING " AND d.render_seq = d.revision " \
+	"AND d.route_json->'levels'->(d.current_party - 1)->'signers' ? " u \
 	" AND NOT EXISTS (SELECT 1 FROM doc_decisions x WHERE x.doc_id = d.id " \
-	"AND x.revision = d.revision AND x.level = d.current_level AND x.approver = " u "))"
+	"AND x.revision = d.revision AND x.party = d.current_party AND x.signer = " u "))"
 
 static void
 doc_path(char *buf, size_t sz, const char *id, const char *name)

@@ -154,13 +154,13 @@ check_route(yyjson_val *route)
 	if (!yyjson_is_arr(levels) || yyjson_arr_size(levels) > 10)
 		return "route.levels must be an array of at most 10 levels";
 	yyjson_arr_foreach(levels, i, max, lv) {
-		ap = yyjson_obj_get(lv, "approvers");
+		ap = yyjson_obj_get(lv, "signers");
 		if (!yyjson_is_arr(ap) || yyjson_arr_size(ap) < 1 ||
 		    yyjson_arr_size(ap) > 20)
-			return "every level needs 1 to 20 approvers";
+			return "every level needs 1 to 20 signers";
 		yyjson_arr_foreach(ap, j, jmax, u)
 			if (!is_safe_name(yyjson_get_str(u)))
-				return "bad approver name";
+				return "bad signer name";
 		mode = yyjson_get_str(yyjson_obj_get(lv, "mode"));
 		if (mode != NULL && strcmp(mode, "any") != 0 && strcmp(mode, "all") != 0)
 			return "level mode must be any or all";

@@ -175,7 +175,7 @@ route_has(yyjson_val *route, const char *user)
 	size_t i, max, j, jmax;
 
 	yyjson_arr_foreach(yyjson_obj_get(route, "levels"), i, max, lv)
-		yyjson_arr_foreach(yyjson_obj_get(lv, "approvers"), j, jmax, u)
+		yyjson_arr_foreach(yyjson_obj_get(lv, "signers"), j, jmax, u)
 			if (strcmp(yyjson_get_str(u), user) == 0)
 				return 1;
 	return 0;

@@ -220,7 +220,7 @@ check_submittable(yyjson_val *layout, yyjson_val *route, int has_series,
 		} else if (strcmp(type, "signature") == 0) {
 			if (!is_safe_name(ref) || !route_has(route, ref)) {
 				snprintf(err, errsz, "signature box for '%s', who is "
-				    "not an approver in the route", ref);
+				    "not a signer in the route", ref);
 				return -1;
 			}
 		} else if (strcmp(type, "serial") == 0 && !has_series) {

@@ -238,10 +238,10 @@ h_me(struct kreq *r, const struct ident *id)
 {
 	char buf[512];
 
-	snprintf(buf, sizeof(buf), "{\"user\":\"%s\",\"roles\":{\"maker\":%s,"
-	    "\"approver\":%s,\"admin\":%s}}", id->user,
-	    ident_has_role(id, &cf, "maker") ? "true" : "false",
-	    ident_has_role(id, &cf, "approver") ? "true" : "false",
+	snprintf(buf, sizeof(buf), "{\"user\":\"%s\",\"roles\":{\"drafter\":%s,"
+	    "\"signer\":%s,\"admin\":%s}}", id->user,
+	    ident_has_role(id, &cf, "drafter") ? "true" : "false",
+	    ident_has_role(id, &cf, "signer") ? "true" : "false",
 	    ident_has_role(id, &cf, "admin") ? "true" : "false");
 	send_json(r, KHTTP_200, buf);
 }

@@ -262,13 +262,13 @@ h_docs_list(struct kreq *r, PGconn *pg, const struct ident *id)
 	else if (strcmp(scope, "all") == 0 && ident_has_role(id, &cf, "admin"))
 		where = "$1 <> ''";
 	else
-		where = "d.maker_user = $1";
+		where = "d.drafter_user = $1";
 	snprintf(sql, sizeof(sql),
 	    "SELECT coalesce(json_agg(t), '[]')::text FROM ("
-	    "SELECT d.id, d.status, d.title, d.serial, d.maker_user, d.customer_id, "
-	    "d.revision, d.current_level, "
+	    "SELECT d.id, d.status, d.title, d.serial, d.drafter_user, "
+	    "d.revision, d.current_party, "
 	    "jsonb_array_length(d.route_json->'levels') AS levels, "
-	    "d.created_at, d.submitted_at, d.approved_at "
+	    "d.created_at, d.submitted_at, d.released_at "
 	    "FROM documents d WHERE %s ORDER BY d.created_at DESC LIMIT 200) t", where);
 	send_sql_json(r, pg, sql, 1, p);
 }

@@ -283,8 +283,8 @@ h_doc_create(struct kreq *r, PGconn *pg, const struct ident *id)
 	PGresult *res;
 	const char *docid;
 
-	if (!ident_has_role(id, &cf, "maker")) {
-		send_err(r, KHTTP_403, "maker role required");
+	if (!ident_has_role(id, &cf, "drafter")) {
+		send_err(r, KHTTP_403, "drafter role required");
 		return;
 	}
 	if (tpl != NULL && *tpl) {

@@ -292,13 +292,13 @@ h_doc_create(struct kreq *r, PGconn *pg, const struct ident *id)
 			send_err(r, KHTTP_400, "bad template_id");
 			return;
 		}
-		res = db_q(pg, "INSERT INTO documents (maker_user, template_id, "
+		res = db_q(pg, "INSERT INTO documents (drafter_user, template_id, "
 		    "series_code, layout_json, route_json) SELECT $1::varchar, t.id, "
 		    "t.series_code, t.layout_json, t.route_json FROM templates t "
 		    "WHERE t.id = $2 RETURNING id", 2, p);
 	} else if (file != NULL && file->valsz > 5 && file->valsz <= 32u * 1024 * 1024 &&
 	    memcmp(file->val, "%PDF-", 5) == 0) {
-		res = db_q(pg, "INSERT INTO documents (maker_user) VALUES ($1) "
+		res = db_q(pg, "INSERT INTO documents (drafter_user) VALUES ($1) "
 		    "RETURNING id", 1, p);
 	} else {
 		send_err(r, KHTTP_400, "upload a PDF (max 32 MB) or pick a template");

@@ -334,29 +334,29 @@ h_doc_get(struct kreq *r, PGconn *pg, const struct ident *id, const char *docid)
 {
 	const char *p[] = { docid, id->user,
 	    ident_has_role(id, &cf, "admin") ? "t" : "f",
-	    ident_has_role(id, &cf, "approver") ? "t" : "f" };
+	    ident_has_role(id, &cf, "signer") ? "t" : "f" };
 
 	send_sql_json(r, pg,
 	    "SELECT row_to_json(t)::text FROM (SELECT d.id, d.status, d.title, "
-	    "d.maker_user, d.customer_id, d.series_code, d.serial, d.doc_date, "
+	    "d.drafter_user, d.series_code, d.serial, d.doc_date, "
 	    "d.layout_json AS layout, d.route_json AS route, d.revision, "
-	    "d.current_level, d.rendered_revision, d.render_error, d.final_sha256, "
-	    "d.created_at, d.submitted_at, d.approved_at, "
+	    "d.current_party, d.render_seq, d.render_error, d.final_sha256, "
+	    "d.created_at, d.submitted_at, d.released_at, "
 	    "(SELECT s.pattern FROM series s WHERE s.code = d.series_code) AS series_pattern, "
-	    "(d.maker_user = $2 AND d.status IN ('DRAFT','CORRECTION_REQUIRED')) AS can_edit, "
+	    "(d.drafter_user = $2 AND d.status IN ('DRAFT','CORRECTION_REQUIRED')) AS can_edit, "
 	    "($4::boolean AND " CAN_DECIDE("$2") ") AS can_decide, "
 	    "($3::boolean OR " IN_ROUTE("$2") ") AS can_see_stamped, "
 	    "(SELECT coalesce(json_agg(x ORDER BY x.decided_at), '[]') FROM ("
-	    "SELECT revision, level, approver, decision, comment, decided_at "
+	    "SELECT revision, party, signer, decision, comment, decided_at "
 	    "FROM doc_decisions WHERE doc_id = d.id) x) AS decisions "
-	    "FROM documents d WHERE d.id = $1 AND (d.maker_user = $2 OR $3::boolean "
+	    "FROM documents d WHERE d.id = $1 AND (d.drafter_user = $2 OR $3::boolean "
 	    "OR (d.status <> 'DRAFT' AND " IN_ROUTE("$2") "))) t", 4, p);
 }
 
 static void
 h_doc_save(struct kreq *r, PGconn *pg, const struct ident *id, const char *docid)
 {
-	const char *json = http_field_str(r, "json"), *msg, *p[7];
+	const char *json = http_field_str(r, "json"), *msg, *p[6];
 	yyjson_doc *doc;
 	yyjson_val *root, *layout, *route;
 	char *ltxt = NULL, *rtxt = NULL;

@@ -378,24 +378,23 @@ h_doc_save(struct kreq *r, PGconn *pg, const struct ident *id, const char *docid
 	p[0] = docid;
 	p[1] = id->user;
 	p[2] = yyjson_get_str(yyjson_obj_get(root, "title"));
-	p[3] = yyjson_get_str(yyjson_obj_get(root, "customer_id"));
-	p[4] = yyjson_get_str(yyjson_obj_get(root, "series_code"));
-	p[5] = ltxt;
-	p[6] = rtxt;
+	p[3] = yyjson_get_str(yyjson_obj_get(root, "series_code"));
+	p[4] = ltxt;
+	p[5] = rtxt;
 	if (p[2] == NULL)
 		p[2] = "";
-	if (p[4] != NULL && *p[4] == '\0')
-		p[4] = NULL;
+	if (p[3] != NULL && *p[3] == '\0')
+		p[3] = NULL;
 	if (ltxt == NULL || rtxt == NULL || strlen(p[2]) > 200 ||
-	    (p[4] != NULL && !is_safe_name(p[4]))) {
+	    (p[3] != NULL && !is_safe_name(p[3]))) {
 		send_err(r, KHTTP_400, "bad title or series");
 		goto out;
 	}
 	/* the series is frozen once a serial number has been allocated */
-	res = db_q(pg, "UPDATE documents SET title = $3, customer_id = $4, "
-	    "series_code = CASE WHEN serial IS NULL THEN $5 ELSE series_code END, "
-	    "layout_json = $6::jsonb, route_json = $7::jsonb WHERE id = $1 "
-	    "AND maker_user = $2 AND status IN ('DRAFT','CORRECTION_REQUIRED')", 7, p);
+	res = db_q(pg, "UPDATE documents SET title = $3, "
+	    "series_code = CASE WHEN serial IS NULL THEN $4 ELSE series_code END, "
+	    "layout_json = $5::jsonb, route_json = $6::jsonb WHERE id = $1 "
+	    "AND drafter_user = $2 AND status IN ('DRAFT','CORRECTION_REQUIRED')", 6, p);
 	if (res == NULL)
 		send_err(r, KHTTP_400, "save failed (unknown series?)");
 	else if (strcmp(PQcmdTuples(res), "1") != 0)

@@ -424,7 +423,7 @@ h_doc_submit(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 		return;
 	}
 	res = db_q(pg, "SELECT layout_json::text, route_json::text, series_code, "
-	    "serial FROM documents WHERE id = $1 AND maker_user = $2 "
+	    "serial FROM documents WHERE id = $1 AND drafter_user = $2 "
 	    "AND status IN ('DRAFT','CORRECTION_REQUIRED') FOR UPDATE", 2, p);
 	if (res == NULL || PQntuples(res) != 1) {
 		snprintf(err, sizeof(err), "document is not submittable by you");

@@ -458,14 +457,13 @@ h_doc_submit(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 	}
 	if (r2 != NULL)
 		PQclear(r2);
-	r2 = db_q(pg, "UPDATE documents SET status = CASE WHEN status = "
-	    "'CORRECTION_REQUIRED' THEN 'CORRECTED'::doc_status ELSE "
-	    "'PENDING_APPROVAL'::doc_status END, revision = revision + 1, "
-	    "current_level = 1, serial = COALESCE(serial, $3), "
+	r2 = db_q(pg, "UPDATE documents SET status = 'PENDING'::doc_status, "
+	    "revision = revision + 1, "
+	    "current_party = 1, serial = COALESCE(serial, $3), "
 	    "doc_date = COALESCE(doc_date, CURRENT_DATE), "
 	    "title = CASE WHEN title = '' THEN COALESCE(serial, $3, 'Untitled') "
 	    "ELSE title END, submitted_at = CURRENT_TIMESTAMP, render_error = NULL "
-	    "WHERE id = $1 AND maker_user = $2 RETURNING revision::text", 3, p);
+	    "WHERE id = $1 AND drafter_user = $2 RETURNING revision::text", 3, p);
 	if (r2 == NULL || PQntuples(r2) != 1 || (rev = strdup(PQgetvalue(r2, 0, 0))) == NULL ||
 	    db_do(pg, "COMMIT", 0, NULL) == -1) {
 		snprintf(err, sizeof(err), "submit failed");

@@ -501,8 +499,8 @@ h_doc_rerender(struct kreq *r, PGconn *pg, const struct ident *id, const char *d
 	PGresult *res;
 
 	res = db_q(pg, "UPDATE documents d SET render_error = NULL WHERE id = $1 "
-	    "AND (maker_user = $2 OR $3::boolean) AND status IN " PENDING
-	    " AND rendered_revision < revision RETURNING revision::text", 3, p);
+	    "AND (drafter_user = $2 OR $3::boolean) AND status IN " PENDING
+	    " AND render_seq < revision RETURNING revision::text", 3, p);
 	if (res == NULL || PQntuples(res) != 1)
 		send_err(r, KHTTP_409, "nothing to re-render");
 	else if (enqueue(docid, PQgetvalue(res, 0, 0)) == -1)

@@ -536,17 +534,17 @@ release(PGconn *pg, const char *docid, char *sha, char *err, size_t errsz)
 	    "SELECT * FROM (SELECT 0 AS o, 'Document ID:  ' || d.id FROM documents d WHERE d.id = $1 "
 	    "UNION ALL SELECT 1, 'Serial:  ' || coalesce(d.serial, '-') FROM documents d WHERE d.id = $1 "
 	    "UNION ALL SELECT 2, 'Title:  ' || d.title FROM documents d WHERE d.id = $1 "
-	    "UNION ALL SELECT 3, 'Prepared by:  ' || d.maker_user || '   submitted ' || "
+	    "UNION ALL SELECT 3, 'Prepared by:  ' || d.drafter_user || '   submitted ' || "
 	    "to_char(d.submitted_at, 'YYYY-MM-DD HH24:MI:SS TZ') || '   revision ' || d.revision "
 	    "FROM documents d WHERE d.id = $1 "
 	    "UNION ALL SELECT 4, '' "
 	    "UNION ALL SELECT 5, 'Sign-offs:' "
-	    "UNION ALL (SELECT 6, '  Level ' || x.level || ':  ' || x.approver || '   approved ' || "
+	    "UNION ALL (SELECT 6, '  Party ' || x.party || ':  ' || x.signer || '   signed off ' || "
 	    "to_char(x.decided_at, 'YYYY-MM-DD HH24:MI:SS TZ') || "
 	    "CASE WHEN x.comment <> '' THEN '   \"' || left(x.comment, 60) || '\"' ELSE '' END "
 	    "FROM doc_decisions x JOIN documents d ON d.id = x.doc_id "
-	    "WHERE x.doc_id = $1 AND x.revision = d.revision AND x.decision = 'APPROVE' "
-	    "ORDER BY x.level, x.decided_at LIMIT 50)) q ORDER BY o", 1, p);
+	    "WHERE x.doc_id = $1 AND x.revision = d.revision AND x.decision = 'SIGNOFF' "
+	    "ORDER BY x.party, x.decided_at LIMIT 50)) q ORDER BY o", 1, p);
 	if (res == NULL) {
 		snprintf(err, errsz, "database error");
 		return -1;

@@ -583,12 +581,12 @@ h_doc_decide(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 	const char *p[4], *code, *action;
 	char err[512] = "", sha[65], stamped[700];
 	PGresult *res = NULL, *r2 = NULL;
-	int level, levels, mode_all, napprovers, napproved, level_done;
+	int party, parties, mode_all, nsigners, nsigned, party_done;
 
 	if (comment == NULL)
 		comment = "";
 	if (decision != NULL && strcmp(decision, "approve") == 0)
-		code = "APPROVE";
+		code = "SIGNOFF";
 	else if (decision != NULL && strcmp(decision, "correction") == 0)
 		code = "CORRECTION";
 	else if (decision != NULL && strcmp(decision, "disapprove") == 0)

@@ -597,12 +595,12 @@ h_doc_decide(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 		send_err(r, KHTTP_400, "decision must be approve, correction or disapprove");
 		return;
 	}
-	if (code[0] != 'A' && *comment == '\0') {
+	if (code[0] != 'S' && *comment == '\0') {
 		send_err(r, KHTTP_400, "a comment is required when not approving");
 		return;
 	}
-	if (!ident_has_role(id, &cf, "approver")) {
-		send_err(r, KHTTP_403, "approver role required");
+	if (!ident_has_role(id, &cf, "signer")) {
+		send_err(r, KHTTP_403, "signer role required");
 		return;
 	}
 	if (db_do(pg, "BEGIN", 0, NULL) == -1) {

@@ -611,56 +609,56 @@ h_doc_decide(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 	}
 	p[0] = docid;
 	p[1] = id->user;
-	res = db_q(pg, "SELECT d.current_level, jsonb_array_length(d.route_json->'levels'), "
-	    "coalesce(d.route_json->'levels'->(d.current_level - 1)->>'mode', 'any'), "
-	    "jsonb_array_length(d.route_json->'levels'->(d.current_level - 1)->'approvers'), "
-	    "d.revision::text, d.current_level::text FROM documents d WHERE d.id = $1 AND "
+	res = db_q(pg, "SELECT d.current_party, jsonb_array_length(d.route_json->'levels'), "
+	    "coalesce(d.route_json->'levels'->(d.current_party - 1)->>'mode', 'any'), "
+	    "jsonb_array_length(d.route_json->'levels'->(d.current_party - 1)->'signers'), "
+	    "d.revision::text, d.current_party::text FROM documents d WHERE d.id = $1 AND "
 	    CAN_DECIDE("$2") " FOR UPDATE", 2, p);
 	if (res == NULL || PQntuples(res) != 1) {
 		snprintf(err, sizeof(err), "this document is not waiting for your decision");
 		goto fail;
 	}
-	level = atoi(PQgetvalue(res, 0, 0));
-	levels = atoi(PQgetvalue(res, 0, 1));
+	party = atoi(PQgetvalue(res, 0, 0));
+	parties = atoi(PQgetvalue(res, 0, 1));
 	mode_all = strcmp(PQgetvalue(res, 0, 2), "all") == 0;
-	napprovers = atoi(PQgetvalue(res, 0, 3));
+	nsigners = atoi(PQgetvalue(res, 0, 3));
 	p[2] = PQgetvalue(res, 0, 4);
 	p[3] = PQgetvalue(res, 0, 5);
 	{
 		const char *ip[] = { docid, p[2], p[3], id->user, code, comment };
 
-		if (db_do(pg, "INSERT INTO doc_decisions (doc_id, revision, level, "
-		    "approver, decision, comment) VALUES ($1, $2::int, $3::int, $4, $5, $6)",
+		if (db_do(pg, "INSERT INTO doc_decisions (doc_id, revision, party, "
+		    "signer, decision, comment) VALUES ($1, $2::int, $3::int, $4, $5, $6)",
 		    6, ip) == -1) {
 			snprintf(err, sizeof(err), "could not record the decision");
 			goto fail;
 		}
 	}
 	doc_path(stamped, sizeof(stamped), docid, "stamped.pdf");
-	if (code[0] == 'A') {
+	if (code[0] == 'S') {
 		const char *cp[] = { docid, p[2], p[3] };
 
 		r2 = db_q(pg, "SELECT count(*) FROM doc_decisions WHERE doc_id = $1 "
-		    "AND revision = $2::int AND level = $3::int AND decision = 'APPROVE'",
+		    "AND revision = $2::int AND party = $3::int AND decision = 'SIGNOFF'",
 		    3, cp);
 		if (r2 == NULL)
 			goto fail;
-		napproved = atoi(PQgetvalue(r2, 0, 0));
-		level_done = mode_all ? napproved >= napprovers : 1;
-		action = "APPROVED_LEVEL";
-		if (level_done && level >= levels) {
+		nsigned = atoi(PQgetvalue(r2, 0, 0));
+		party_done = mode_all ? nsigned >= nsigners : 1;
+		action = "SIGNED_LEVEL";
+		if (party_done && party >= parties) {
 			const char *fp[] = { docid, sha };
 
 			if (release(pg, docid, sha, err, sizeof(err)) == -1)
 				goto fail;
-			if (db_do(pg, "UPDATE documents SET status = 'APPROVED', "
-			    "final_sha256 = $2, approved_at = CURRENT_TIMESTAMP "
+			if (db_do(pg, "UPDATE documents SET status = 'RELEASED', "
+			    "final_sha256 = $2, released_at = CURRENT_TIMESTAMP "
 			    "WHERE id = $1", 2, fp) == -1)
 				goto fail;
 			action = "RELEASED";
-		} else if (level_done) {
-			if (db_do(pg, "UPDATE documents SET current_level = "
-			    "current_level + 1 WHERE id = $1", 1, p) == -1)
+		} else if (party_done) {
+			if (db_do(pg, "UPDATE documents SET current_party = "
+			    "current_party + 1 WHERE id = $1", 1, p) == -1)
 				goto fail;
 		}
 	} else {

@@ -673,7 +671,7 @@ h_doc_decide(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 	if (db_do(pg, "COMMIT", 0, NULL) == -1)
 		goto fail;
 	/* no signed copy stays on disk once it is released, sent back or refused */
-	if (strcmp(action, "APPROVED_LEVEL") != 0)
+	if (strcmp(action, "SIGNED_LEVEL") != 0)
 		unlink(stamped);
 	log_event(pg, docid, id->user, action, comment);
 	send_json(r, KHTTP_200, "{\"ok\":true}");

@@ -695,7 +693,7 @@ h_doc_delete(struct kreq *r, PGconn *pg, const struct ident *id, const char *doc
 	char path[700];
 	PGresult *res;
 
-	res = db_q(pg, "DELETE FROM documents WHERE id = $1 AND maker_user = $2 "
+	res = db_q(pg, "DELETE FROM documents WHERE id = $1 AND drafter_user = $2 "
 	    "AND status = 'DRAFT' AND serial IS NULL", 2, p);
 	if (res == NULL || strcmp(PQcmdTuples(res), "1") != 0)
 		send_err(r, KHTTP_409, "only your own unsubmitted drafts can be deleted");

@@ -718,16 +716,16 @@ h_doc_file(struct kreq *r, PGconn *pg, const struct ident *id, const char *docid
 	    ident_has_role(id, &cf, "admin") ? "t" : "f" };
 	char path[700], name[64];
 	PGresult *res;
-	int is_maker, in_route, admin = p[2][0] == 't';
+	int is_drafter, in_route, admin = p[2][0] == 't';
 	const char *status;
 
-	res = db_q(pg, "SELECT d.maker_user = $2, " IN_ROUTE("$2") ", d.status::text "
+	res = db_q(pg, "SELECT d.drafter_user = $2, " IN_ROUTE("$2") ", d.status::text "
 	    "FROM documents d WHERE d.id = $1 AND $3 <> ''", 3, p);
 	if (res == NULL || PQntuples(res) != 1) {
 		send_err(r, KHTTP_404, "not found");
 		goto out;
 	}
-	is_maker = PQgetvalue(res, 0, 0)[0] == 't';
+	is_drafter = PQgetvalue(res, 0, 0)[0] == 't';
 	in_route = PQgetvalue(res, 0, 1)[0] == 't';
 	status = PQgetvalue(res, 0, 2);
 	if (strcmp(status, "DRAFT") == 0)

@@ -738,7 +736,7 @@ h_doc_file(struct kreq *r, PGconn *pg, const struct ident *id, const char *docid
 		goto out;
 	}
 	/* the stamped copy carries signature facsimiles: checkers only */
-	if (!(admin || in_route || (is_maker && strcmp(kind, "stamped") != 0))) {
+	if (!(admin || in_route || (is_drafter && strcmp(kind, "stamped") != 0))) {
 		send_err(r, KHTTP_403, "forbidden");
 		goto out;
 	}

@@ -765,9 +763,9 @@ h_templates(struct kreq *r, PGconn *pg, const struct ident *id)
 	}
 	docid = http_field_str(r, "doc_id");
 	name = http_field_str(r, "name");
-	if (!ident_has_role(id, &cf, "maker") || !is_uuid(docid) || name == NULL ||
+	if (!ident_has_role(id, &cf, "drafter") || !is_uuid(docid) || name == NULL ||
 	    *name == '\0' || strlen(name) > 200) {
-		send_err(r, KHTTP_400, "maker role, doc_id and name required");
+		send_err(r, KHTTP_400, "drafter role, doc_id and name required");
 		return;
 	}
 	p[0] = docid;

@@ -775,7 +773,7 @@ h_templates(struct kreq *r, PGconn *pg, const struct ident *id)
 	p[2] = name;
 	res = db_q(pg, "INSERT INTO templates (name, series_code, layout_json, "
 	    "route_json, created_by) SELECT $3::varchar, series_code, layout_json, route_json, "
-	    "$2::varchar FROM documents WHERE id = $1 AND maker_user = $2::varchar RETURNING id", 3, p);
+	    "$2::varchar FROM documents WHERE id = $1 AND drafter_user = $2::varchar RETURNING id", 3, p);
 	if (res == NULL || PQntuples(res) != 1) {
 		send_err(r, KHTTP_404, "document not found");
 		if (res != NULL)
diff --git a/src/signetd.c b/src/signetd.c
@@ -107,7 +107,7 @@ process(redisContext *rc, const char *payload)
 	p[1] = revbuf;
 	res = db_q(pg, "SELECT layout_json::text, serial, doc_date::text "
 	    "FROM documents WHERE id = $1 AND revision = $2 "
-	    "AND status IN ('PENDING_APPROVAL', 'CORRECTED')", 2, p);
+	    "AND status IN ('PENDING')", 2, p);
 	if (res == NULL) {
 		yyjson_doc_free(job);
 		return -1;

@@ -116,7 +116,7 @@ process(redisContext *rc, const char *payload)
 		if (render_pair(rc, id, PQgetvalue(res, 0, 0),
 		    PQgetisnull(res, 0, 1) ? NULL : PQgetvalue(res, 0, 1),
 		    PQgetvalue(res, 0, 2), err, sizeof(err)) == 0) {
-			db_do(pg, "UPDATE documents SET rendered_revision = $2, "
+			db_do(pg, "UPDATE documents SET render_seq = $2, "
 			    "render_error = NULL WHERE id = $1", 2, p);
 			log_event(pg, id, "STAMPED", revbuf);
 		} else {
diff --git a/test/dev-up.sh b/test/dev-up.sh
@@ -23,11 +23,12 @@ if ! su-exec postgres psql -lqt | grep -qw signet; then
 	  "GRANT SELECT, UPDATE ON documents TO signetd; GRANT INSERT ON doc_events TO signetd; GRANT USAGE ON SEQUENCE doc_events_id_seq TO signetd;"
 fi
 
+mkdir -p /var/lib/signet/sig-inbox
 cp /usr/share/fonts/dejavu/DejaVuSans.ttf /var/www/dam/fonts/
 cp /src/test/fixtures/seal.png /var/www/dam/seals/agency_seal.png
 cp /src/test/fixtures/sig.png /var/lib/signatures/ceo.png
 cp /src/test/fixtures/sig.png /var/lib/signatures/manager.png
-chown -R signet:signet /var/lib/signet && chmod 2770 /var/lib/signet
+chown -R signet:signet /var/lib/signet && chmod 2770 /var/lib/signet && chmod 1730 /var/lib/signet/sig-inbox
 chown -R signetd /var/lib/signatures && chmod 0700 /var/lib/signatures && chmod 0600 /var/lib/signatures/*
 chown -R lighttpd /var/www/dam
 
diff --git a/test/e2e.sh b/test/e2e.sh
@@ -11,7 +11,7 @@ die() { echo "FAIL - $1"; exit 1; }
 expect() { echo "$2" | grep -q "$3" && ok "$1" || die "$1: got $2"; }
 
 expect "unauthenticated is 401" "$(curl -sS $B/api/me)" 'no authenticated user'
-expect "roles from groups" "$(clerk $B/api/me)" '"maker":true,"approver":false'
+expect "roles from groups" "$(clerk $B/api/me)" '"drafter":true,"signer":false'
 expect "POST needs CSRF header" "$(clerk -d '' $B/api/series)" 'X-Requested-With'
 expect "clerk cannot create series" "$(clerk -H "$X" -F code=T -F 'pattern={seq}' $B/api/series)" 'admin role'
 

@@ -23,8 +23,8 @@ expect "DAM listing" "$(clerk $B/api/dam)" 'seals/agency_seal.png'
 ID=$(clerk -H "$X" -F file=@/src/test/fixtures/letter.pdf $B/api/docs | jq -r .id)
 [ ${#ID} -eq 36 ] && ok "draft created $ID" || die "create"
 
-LAYOUT='{"title":"","customer_id":"CUST-7","series_code":"SCNREPLY",
- "route":{"levels":[{"approvers":["manager","deputy"],"mode":"any"},{"approvers":["ceo"],"mode":"all"}]},
+LAYOUT='{"title":"","series_code":"SCNREPLY",
+ "route":{"levels":[{"signers":["manager","deputy"],"mode":"any"},{"signers":["ceo"],"mode":"all"}]},
  "layout":{"reference_width":1000,"reference_height":1414,"imprints":[
   {"page":1,"type":"pim_text","ref":"org:gstin","prefix":"GSTIN: ","coords":[120,150,520,180]},
   {"page":1,"type":"serial","coords":[120,200,620,228],"font":"fonts/DejaVuSans.ttf"},

@@ -36,16 +36,16 @@ expect "other clerk cannot see draft" "$(as ravi clerks $B/api/docs/$ID)" 'not f
 
 BAD=$(echo "$LAYOUT" | sed 's/"ref":"ceo"/"ref":"stranger"/')
 clerk -H "$X" -F "json=$BAD" $B/api/docs/$ID/save >/dev/null
-expect "signature must be in route" "$(clerk -H "$X" -d '' $B/api/docs/$ID/submit)" 'not an approver'
+expect "signature must be in route" "$(clerk -H "$X" -d '' $B/api/docs/$ID/submit)" 'not a signer'
 clerk -H "$X" -F "json=$LAYOUT" $B/api/docs/$ID/save >/dev/null
 
 expect "submit" "$(clerk -H "$X" -d '' $B/api/docs/$ID/submit)" '"revision":1'
 for i in 1 2 3 4 5 6 7 8 9 10; do
 	D=$(clerk $B/api/docs/$ID)
-	[ "$(echo "$D" | jq -r .rendered_revision)" = 1 ] && break
+	[ "$(echo "$D" | jq -r .render_seq)" = 1 ] && break
 	sleep 1
 done
-expect "stamped by worker" "$D" '"rendered_revision":1'
+expect "stamped by worker" "$D" '"render_seq":1'
 SERIAL=$(echo "$D" | jq -r .serial)
 expect "serial allocated" "$SERIAL" "^SKGA/SCNREPLY/$(date +%Y%m%d)/01$"
 expect "title defaults to serial" "$(echo "$D" | jq -r .title)" "$SERIAL"

@@ -69,13 +69,13 @@ expect "status CORRECTION_REQUIRED, editable" "$(clerk $B/api/docs/$ID)" '"statu
 expect "resubmit" "$(clerk -H "$X" -d '' $B/api/docs/$ID/submit)" '"revision":2'
 sleep 2
 D=$(clerk $B/api/docs/$ID)
-expect "status CORRECTED, serial unchanged" "$D" "\"status\":\"CORRECTED\".*\"serial\":\"$SERIAL\""
+expect "status PENDING, serial unchanged" "$D" "\"status\":\"PENDING\".*\"serial\":\"$SERIAL\""
 
 expect "level 1 sign-off" "$(as deputy management -H "$X" -F decision=approve $B/api/docs/$ID/decide)" '"ok":true'
-expect "now level 2" "$(clerk $B/api/docs/$ID | jq .current_level)" '^2$'
+expect "now level 2" "$(clerk $B/api/docs/$ID | jq .current_party)" '^2$'
 expect "level 2 sign-off releases" "$(as ceo management -H "$X" -F decision=approve -F comment=ok $B/api/docs/$ID/decide)" '"ok":true'
 D=$(clerk $B/api/docs/$ID)
-expect "APPROVED" "$D" '"status":"APPROVED"'
+expect "RELEASED" "$D" '"status":"RELEASED"'
 clerk -o /tmp/final.pdf $B/api/docs/$ID/file/final
 expect "final = 2 pages + audit page" "$(pdfinfo /tmp/final.pdf)" 'Pages: *3'
 expect "sha256 recorded matches file" "$(sha256sum /tmp/final.pdf)" "$(echo "$D" | jq -r .final_sha256)"
diff --git a/www/app.js b/www/app.js
@@ -379,7 +379,7 @@ function placeNew(page, type, cx, cy) {
   const x1 = Math.max(0, Math.min(img.naturalWidth - t.w, cx - t.w / 2));
   const y1 = Math.max(0, Math.min(img.naturalHeight - t.h, cy - t.h / 2));
   const imp = { type, coords: [x1, y1, x1 + t.w, y1 + t.h] };
-  if (type === 'signature') imp.ref = collectRoute().levels.flatMap((l) => l.approvers)[0] || '';
+  if (type === 'signature') imp.ref = collectRoute().levels.flatMap((l) => l.signers)[0] || '';
   select(addArea(page, imp));
 }
 

@@ -419,8 +419,8 @@ function renderProps() {
     })));
   }
   if (type === 'signature') {
-    const approvers = [...new Set(collectRoute().levels.flatMap((l) => l.approvers))];
-    host.append(...field('Signer (must be in the approval route)', selectEl([['', '(choose)'], ...approvers.map((u) => [u, u])], d.ref, set('ref'))));
+    const signers = [...new Set(collectRoute().levels.flatMap((l) => l.signers))];
+    host.append(...field('Signer (must be in the approval route)', selectEl([['', '(choose)'], ...signers.map((u) => [u, u])], d.ref, set('ref'))));
   }
   if (type === 'date') {
     host.append(...field('Format (strftime)', h('input', { value: d.format || '', placeholder: app.dam.date_format || '%d-%m-%Y', oninput: (e) => set('format')(e.target.value) })));

@@ -438,8 +438,8 @@ function routeEditor(route, editable) {
   const host = h('div', { id: 'route' });
   const addLevel = (lv) => {
     const row = h('div', { class: 'level' },
-      h('label', {}, 'Approvers (usernames, comma separated)'),
-      h('input', { class: 'r-approvers', value: (lv.approvers || []).join(', '), onchange: renderProps }),
+      h('label', {}, 'Signers (usernames, comma separated)'),
+      h('input', { class: 'r-signers', value: (lv.signers || []).join(', '), onchange: renderProps }),
       h('div', { class: 'row' },
         selectEl([['any', 'Any one of them signs off'], ['all', 'All of them must sign off']], lv.mode || 'any', () => {}, { class: 'r-mode' }),
         h('button', { class: 'danger', onclick: () => { row.remove(); renderProps(); } }, 'Remove')));

@@ -450,8 +450,8 @@ function routeEditor(route, editable) {
     (route.levels || []).forEach(addLevel);
   } else {
     (route.levels || []).forEach((lv, i) => host.append(h('div', {
-      class: 'level' + (doc.current_level === i + 1 && ['PENDING_APPROVAL', 'CORRECTED'].includes(doc.status) ? ' current' : ''),
-    }, h('div', { class: 'who' }, h('strong', {}, `Level ${i + 1}: `), lv.approvers.join(', ')),
+      class: 'level' + (doc.current_party === i + 1 && ['PENDING'].includes(doc.status) ? ' current' : ''),
+    }, h('div', { class: 'who' }, h('strong', {}, `Level ${i + 1}: `), lv.signers.join(', ')),
     h('small', {}, lv.mode === 'all' ? 'all must sign off' : 'any one signs off'))));
   }
   return host;

@@ -459,20 +459,20 @@ function routeEditor(route, editable) {
 
 function collectRoute() {
   const host = document.getElementById('route');
-  if (!host || !host.querySelector('.r-approvers')) return (doc && doc.route) || { levels: [] };
+  if (!host || !host.querySelector('.r-signers')) return (doc && doc.route) || { levels: [] };
   return {
     levels: [...host.querySelectorAll('.level')].map((row) => ({
-      approvers: row.querySelector('.r-approvers').value.split(',').map((s) => s.trim()).filter(Boolean),
+      signers: row.querySelector('.r-signers').value.split(',').map((s) => s.trim()).filter(Boolean),
       mode: row.querySelector('.r-mode').value,
-    })).filter((l) => l.approvers.length),
+    })).filter((l) => l.signers.length),
   };
 }
 
 function historyList() {
   if (!doc.decisions.length) return null;
-  const words = { APPROVE: 'signed off', CORRECTION: 'asked for correction', DISAPPROVE: 'disapproved' };
+  const words = { SIGNOFF: 'signed off', CORRECTION: 'asked for correction', DISAPPROVE: 'disapproved' };
   return [h('h2', {}, 'History'), h('ul', { class: 'history' }, doc.decisions.map((x) =>
-    h('li', {}, h('strong', {}, x.approver), ` ${words[x.decision]} · level ${x.level} · rev ${x.revision}`,
+    h('li', {}, h('strong', {}, x.signer), ` ${words[x.decision]} · party ${x.party} · rev ${x.revision}`,
       h('span', { class: 'c' }, fmtTime(x.decided_at) + (x.comment ? ' · “' + x.comment + '”' : '')))))];
 }
 

@@ -484,7 +484,6 @@ async function saveDoc() {
     fields: {
       json: JSON.stringify({
         title: document.getElementById('f-title').value,
-        customer_id: document.getElementById('f-customer').value,
         series_code: currentSeries() || '',
         layout: collectLayout(), route: collectRoute(),
       }),

@@ -509,13 +508,13 @@ async function showDoc(id) {
     return;
   }
   doc.mode = doc.can_edit ? 'edit' : 'preview';
-  const pending = ['PENDING_APPROVAL', 'CORRECTED'].includes(doc.status);
-  const stamping = pending && doc.rendered_revision < doc.revision && !doc.render_error;
+  const pending = ['PENDING'].includes(doc.status);
+  const stamping = pending && doc.render_seq < doc.revision && !doc.render_error;
 
   /* which flattened copy is the base image */
   let kind = 'source';
   if (doc.mode === 'preview') {
-    if (doc.status === 'APPROVED') kind = 'final';
+    if (doc.status === 'RELEASED') kind = 'final';
     else if (pending && doc.can_see_stamped) kind = 'stamped';
     else kind = 'proof';
   }

@@ -530,7 +529,7 @@ async function showDoc(id) {
 
   if (doc.status === 'CORRECTION_REQUIRED') {
     const last = [...doc.decisions].reverse().find((x) => x.decision === 'CORRECTION');
-    notices.append(h('p', { class: 'notice' }, `Correction requested by ${last ? last.approver : 'a checker'}: “${last ? last.comment : ''}”`));
+    notices.append(h('p', { class: 'notice' }, `Correction requested by ${last ? last.signer : 'a checker'}: “${last ? last.comment : ''}”`));
   }
   if (doc.render_error) {
     notices.append(h('p', { class: 'notice error' }, 'Stamping failed: ' + doc.render_error + ' ',

@@ -547,7 +546,6 @@ async function showDoc(id) {
   if (doc.mode === 'edit') {
     side.append(
       ...field('Title (blank = use the serial number)', h('input', { id: 'f-title', value: doc.title, maxlength: 200 })),
-      ...field('Customer', h('input', { id: 'f-customer', value: doc.customer_id || '' })),
       ...field('Series', selectEl([['', '(none)'], ...app.series.map((s) => [s.code, `${s.code}  ·  ${s.pattern}`])], doc.series_code, refitAll, { id: 'f-series', disabled: !!doc.serial })),
       doc.serial ? h('p', { class: 'mono' }, doc.serial) : null,
       h('h2', {}, 'Imprints'),

@@ -568,16 +566,15 @@ async function showDoc(id) {
       h('div', { class: 'legend' }, h('span', {}, h('i', { style: '--c: var(--sig)' }), 'Signature'), h('span', {}, h('i', { style: '--c: var(--img)' }), 'Seal / image'), h('span', {}, h('i', { style: '--c: var(--txt)' }), 'Text')),
       h('label', { class: 'row' }, h('input', { type: 'checkbox', checked: true, style: 'flex:0;width:auto', onchange: (e) => document.querySelector('.workspace').classList.toggle('hide-overlays', !e.target.checked) }), 'Show imprint overlays'),
       h('h2', {}, 'Document'),
-      h('p', {}, h('span', { class: 'mono' }, doc.serial || '(no serial)'), h('br'), `Prepared by ${doc.maker_user}`, h('br'), `Submitted ${fmtTime(doc.submitted_at)} · revision ${doc.revision}`,
-        doc.customer_id ? [h('br'), 'Customer: ' + doc.customer_id] : null),
-      doc.status === 'APPROVED' ? h('p', {}, `Released ${fmtTime(doc.approved_at)}`, h('br'), h('span', { class: 'mono' }, 'sha256 ' + doc.final_sha256), h('br'),
+      h('p', {}, h('span', { class: 'mono' }, doc.serial || '(no serial)'), h('br'), `Prepared by ${doc.drafter_user}`, h('br'), `Submitted ${fmtTime(doc.submitted_at)} · revision ${doc.revision}`),
+      doc.status === 'RELEASED' ? h('p', {}, `Released ${fmtTime(doc.released_at)}`, h('br'), h('span', { class: 'mono' }, 'sha256 ' + doc.final_sha256), h('br'),
         h('button', { class: 'primary', onclick: () => act(async () => { const buf = await api(`/docs/${id}/file/final`, { raw: true }); window.open(URL.createObjectURL(new Blob([buf], { type: 'application/pdf' }))); }, null, false) }, 'Open print copy (PDF)')) : null,
       h('h2', {}, 'Approval route'), routeEditor(doc.route, false));
     if (doc.can_decide) {
-      const comment = h('textarea', { rows: 3, placeholder: 'Comment (required unless approving)' });
+      const comment = h('textarea', { rows: 3, placeholder: 'Comment (required unless signing off)' });
       const decide = (decision) => act(() => api(`/docs/${id}/decide`, { method: 'POST', fields: { decision, comment: comment.value } }), 'Recorded');
       side.append(h('h2', {}, 'Your decision'), comment, h('div', { class: 'actions' },
-        h('button', { class: 'primary', onclick: () => decide('approve') }, 'Approve & sign off'),
+        h('button', { class: 'primary', onclick: () => decide('approve') }, 'Sign off'),
         h('button', { onclick: () => decide('correction') }, 'Correction required'),
         h('button', { class: 'danger', onclick: () => { if (confirm('Disapprove this document? This is final.')) decide('disapprove'); } }, 'Disapprove')));
     }

@@ -600,9 +597,9 @@ async function showDashboard(scope) {
   clearTimeout(pollTimer);
   doc = null;
   const r = app.me.roles;
-  scope = scope || (r.approver && !r.maker ? 'pending' : 'mine');
-  const tabs = [r.maker && ['mine', 'My documents'], r.approver && ['pending', 'Awaiting my sign-off'],
-    r.approver && ['involved', 'All routed to me'], r.admin && ['all', 'Everything']].filter(Boolean);
+  scope = scope || (r.signer && !r.drafter ? 'pending' : 'mine');
+  const tabs = [r.drafter && ['mine', 'My documents'], r.signer && ['pending', 'Awaiting my sign-off'],
+    r.signer && ['involved', 'All routed to me'], r.admin && ['all', 'Everything']].filter(Boolean);
   const view = document.getElementById('view');
   let rows = [];
   try { rows = await api('/docs?scope=' + scope); } catch (e) { toast(e.message, true); }

@@ -618,15 +615,15 @@ async function showDashboard(scope) {
 
   view.replaceChildren(
     h('h1', {}, 'Documents'),
-    r.maker ? h('div', { class: 'card', style: 'margin-bottom:1rem' }, h('div', { class: 'row' }, file, tpl, h('button', { class: 'primary', style: 'flex:0 0 auto', onclick: create }, 'New document'))) : null,
+    r.drafter ? h('div', { class: 'card', style: 'margin-bottom:1rem' }, h('div', { class: 'row' }, file, tpl, h('button', { class: 'primary', style: 'flex:0 0 auto', onclick: create }, 'New document'))) : null,
     h('div', { class: 'tabs', role: 'tablist' }, tabs.map(([k, label]) => h('button', { role: 'tab', 'aria-selected': String(k === scope), onclick: () => showDashboard(k) }, label))),
     h('div', { class: 'card' }, rows.length ? h('table', {},
-      h('thead', {}, h('tr', {}, ['Document', 'Status', 'Prepared by', 'Customer', 'Level', 'Created'].map((t) => h('th', {}, t)))),
+      h('thead', {}, h('tr', {}, ['Document', 'Status', 'Prepared by', 'Level', 'Created'].map((t) => h('th', {}, t)))),
       h('tbody', {}, rows.map((d) => h('tr', { class: 'click', onclick: () => { location.hash = '#/doc/' + d.id; } },
         h('td', {}, d.title || d.serial || 'Untitled draft'),
         h('td', {}, h('span', { class: 'status ' + d.status }, d.status.replace(/_/g, ' '))),
-        h('td', {}, d.maker_user), h('td', {}, d.customer_id || ''),
-        h('td', {}, d.status === 'DRAFT' ? '' : `${Math.min(d.current_level, d.levels)} / ${d.levels}`),
+        h('td', {}, d.drafter_user),
+        h('td', {}, d.status === 'DRAFT' ? '' : `${Math.min(d.current_party, d.levels)} / ${d.levels}`),
         h('td', {}, fmtTime(d.created_at)))))) : h('p', { class: 'empty' }, 'Nothing here.')));
 }