Specification

Discussion and endorsement for checked answers

Use this page to build one signed-in capability that lets workspace members discuss a checked answer, comment on it, endorse it, and mark it as checked by named staff. Comments and endorsements never create a sourced answer. Only an approved source supports an answer.

What exists today, as described in this pack

Read this audit before you add a new control. Each row names the page that already describes the capability.

Capability, where described, and status in this pack
CapabilityWhere describedStatus
Helpful or not helpful marking with an optional commentFeatures, helpful marking section, and Ask and check sourcesDescribed. One mark per person, ranking and safeguard rules are not stated, as Claims check states.
Follow-up clarification under an answer, with replies from another signed-in person in the same college workspaceDiscuss an answer guide, and My followed questionsDescribed as thread rules. No unified API, schema, empty state or test list is stated on a public page.
Checked label by named staff or faculty, with role and date and source namedMark an answer as checked guide, and My followed questions change logDescribed. Eligibility, recheck timing and removal rules are not stated in one place.
Request a source review from the owner office, and share a saved answer with its sourcesRequest a source review guide, Share an answer guide, and Answer libraryDescribed as separate actions. No link from Features or from the answer screen ties them to discussion and endorsement.
Staff reply in a handoff thread, and starred essentials on this deviceHand off to an office guide, Reports notification inventory, and Saved EssentialsDescribed. Device stars are personal only. They do not show peer discussion or peer endorsement.

What is missing, and the demand for it

Each gap below is evidenced by a page in this pack. Close every gap in the same change that ships the capability.

  • Endorsement rules are missing. Claims check corrects a detailed rating claim to a short form because no guide states one mark per person, no ranking and no reordering. A builder cannot ship endorsement without those rules.
  • Discussion, endorsement and verification are described in separate guides with no shared keys, no shared empty state and no shared test list. A person cannot see how a comment, an endorsement count and a checked label fit on one answer.
  • Unanswered themes in Reports are grouped by theme with an owner and a due date, but a reader cannot endorse a repeated question to show that more than one person asked it. Staff must guess priority from count alone.
  • Device pages tell a person to re-ask in the signed-in app when a saved copy is not enough. A person who saved an answer on this device cannot see whether a workspace member already discussed or checked it.
  • No rule states that a comment is never a sourced answer, that an endorsement never reorders answers, or that a checked label never widens the approved source list.

Principles that govern every rule below

Apply these rules to discussion, comment, endorsement and checked labels alike.

One college at a time

Every thread, comment, endorsement and checked label belongs to exactly one college workspace. Every query filters by tenant_id. System view shows counts by college only and never returns comment text.

Comments are not answers

A comment, an endorsement and a checked label never present a fact as a checked answer. Only an approved source supports an answer. A comment that needs a fact must use the handoff to the named office.

Endorsement does not rank or reorder

Endorsement counts are shown beside an answer for review. They never change answer order, search order or report rank. A changed endorsement replaces the earlier one for that person and that answer.

Checked means checked by a named person

A checked label names the person, the role, the date and the source record checked. It is added only by a role named in the checked-label guide, it is rechecked when the source changes, and it is removed when the source is suspended, expired or retired.

Tables and keys

Create these tables in a new migration file named 01NN_discussions.sql in the shipped build, after confirming the question and answer table names in migrations/0002_app.sql. Every table holds tenant_id TEXT NOT NULL. Every identifier is a string on the wire. A missing value is null. An empty list is an empty array.

CREATE TABLE IF NOT EXISTS discussion_threads (tenant_id TEXT NOT NULL, id TEXT NOT NULL, answer_id TEXT NOT NULL, question_record_id TEXT NOT NULL, assistant_id TEXT NOT NULL, created_by TEXT NOT NULL, created_at TEXT, updated_at TEXT, PRIMARY KEY (tenant_id, id)); CREATE TABLE IF NOT EXISTS discussion_comments (tenant_id TEXT NOT NULL, id TEXT NOT NULL, thread_id TEXT NOT NULL, answer_id TEXT NOT NULL, author_id TEXT NOT NULL, body TEXT NOT NULL, created_at TEXT, updated_at TEXT, PRIMARY KEY (tenant_id, id)); CREATE TABLE IF NOT EXISTS endorsements (tenant_id TEXT NOT NULL, answer_id TEXT NOT NULL, user_id TEXT NOT NULL, value TEXT NOT NULL, created_at TEXT, updated_at TEXT, PRIMARY KEY (tenant_id, answer_id, user_id)); CREATE TABLE IF NOT EXISTS checked_labels (tenant_id TEXT NOT NULL, answer_id TEXT NOT NULL, checker_id TEXT NOT NULL, checker_role TEXT NOT NULL, source_id TEXT NOT NULL, checked_at TEXT, PRIMARY KEY (tenant_id, answer_id, checker_id)); CREATE INDEX IF NOT EXISTS idx_threads_tenant_answer ON discussion_threads (tenant_id, answer_id, updated_at DESC, id ASC); CREATE INDEX IF NOT EXISTS idx_comments_tenant_thread ON discussion_comments (tenant_id, thread_id, created_at ASC, id ASC); CREATE INDEX IF NOT EXISTS idx_endorse_tenant_answer ON endorsements (tenant_id, answer_id, user_id);
  • One thread per answer per workspace. A second open for the same answer returns the existing thread and adds no second count.
  • One endorsement per person per answer per workspace. Value is helpful, not_helpful or cleared. A repeated save replaces the earlier value.
  • One checked label per checker per answer per workspace. A checker who checks again replaces the earlier date for that checker.
  • Delete of a comment keeps the thread with a removed mark. A removed comment is never counted as a sourced answer and never returns in reports.

API contract

Use the envelope and status table on API response standard for every route below. Success is ok true with values in data. Error is ok false with a plain error sentence and an optional code. Never return 200 with ok false. Keep existing statuses when a payload moves.

Route, purpose, and success shape
RoutePurposeSuccess shape
GET /api/answers/{id}/discussionRead the thread, comments, endorsement counts and checked labels for one answer in the signed-in workspacedata.item with thread, comments, endorsement counts and checked labels. A missing answer is 404, never data.item null with ok true.
POST /api/answers/{id}/discussion/commentsAdd one comment to the thread for that answerdata.item for the saved comment. A blank body is 400 before any SQL runs.
POST /api/answers/{id}/endorsementSave or replace one endorsement for that person and that answerdata.item with value and the new counts for that answer. A repeated save returns the existing record and adds no second count.
POST /api/answers/{id}/checked-labelAdd or replace a checked label by an eligible named checkerdata.item with checker role, checked date and source id. An ineligible role is 403 with code forbidden.
GET /api/discussionsList threads for one assistant or one workspace, for the Improve queue and for Reportsdata.items plus total, limit, offset, sort, filters and hasMore. Limit defaults to 50, falls back to 50 below 1, clamps to 200 above 200. Offset defaults to 0. Sort is allowlisted only and ends with id ascending.

List queries use one prepare with COUNT OVER for the total, the tenant filter first, and LIKE with an escaped pattern for search. The sort fragment comes only from the allowlist in parseListParams, never from request text. Every SQL statement is one plain string literal with ?1, ?2 placeholders and binds tenant_id from the session.

Pure functions and tests a builder must ship

Keep these helpers exported and pure so tests can call them with no network call.

  • parseListParams, likePattern, toIsoUtc and stringId, with the fallbacks and the one prepare shape stated in APPKIT.md.
  • buildDiscussionKey, which takes tenant_id, answer_id, assistant_id and the sorted comment ids and returns one string. A retry with the same key returns the existing thread and adds no second count.
  • canEndorse and canCheck, which take tenant_id, role and workspace and return true or false with no widening to another college.
  • normalizeCommentRow and normalizeThreadRow, which coerce identifiers to strings, timestamps to ISO 8601 in UTC or null, and counts to JSON numbers.
  • Tests for likePattern with percent, underscore and exclamation mark, for limit, offset and sort fallbacks, for one endorsement per person, for a repeated key returning the existing record, for a checked label from an ineligible role failing, for a source whose status changed between read and save producing no checked label, for a comment from another college never appearing, and for an endorsement that never changes answer order.

Screen layout and empty states

Use the emptyState helper and the empty CSS class on every list screen. Every empty state has four parts in order: icon with aria-hidden, one heading, one brief explanation, and one next action shown only when the signed-in role covers that step.

  • No discussion yet. Title: No discussion yet for this answer. Explanation: state the college, assistant and answer, and state that the first step is to add one comment. Next action: Add a comment, gated by the comment permission, or text naming the role that can comment and a link to Discuss an answer.
  • No endorsements yet. Title: No endorsements yet for this answer. Explanation: state the count shown and that endorsement does not change answer order. Next action: Mark helpful or not helpful on Ask.
  • No checked label yet. Title: No checked label yet for this answer. Explanation: state the source title, source link and last checked date from the source record, and state that a named checker adds the label. Next action: Request a source review, gated by the review permission.
  • No search results. Title: No entries match that wording. Explanation: state the count shown and the total, for example Showing 0 of 12 threads. Next action: Clear search, which restores the full list and clears the search words from the page address.

Show the empty state instead of table headers when the list is empty. Keep the page heading and filter controls visible. Announce a filtered empty result with a status region that states the count shown.

Ship discussion with endorsement and checking together

Add the thread, the endorsement and the checked label in one change, with the tests above, through the normal build.