Spec: specs/127-feedback-themes. User guide:
docs/guides/feedback.md.
tsp/domain/entities/feedback-key.tsp adds FeedbackKey (space, name, prefix, SHA-256 hash,
last used, revoked) and the IntakeRejection enum (Unauthorized, Invalid). Signal
gains externalId. Migration 160-create-feedback-keys creates feedback_keys and adds
signals.external_id with a unique (space_id, external_id) index for non-null ids.
IFeedbackKeyGenerator (ports/output/services/) generates keys and hashes presented ones;
FeedbackKeyGenerator (infrastructure/services/feedback/) uses 24 random bytes, base64url,
behind the shep_fb_ prefix. ManageFeedbackKeysUseCase returns the secret only from create;
every other view drops the hash (FeedbackKeyView).
POST /api/feedback (app/api/feedback/route.ts) is listed in EXTERNALLY_AUTHENTICATED_PATHS
(lib/request-guard.ts), so the session token and loopback Host checks skip this exact path.
The route hands the request to handleIntake (lib/intake-route.ts, shared with
POST /api/alerts from incidents), which rejects bodies over
MAX_INTAKE_BYTES before and after reading, parses a JSON object, calls the use case and maps
each IntakeRejection to 401 or 400. IngestFeedbackUseCase:
verifyIntakeKey in feedback/intake-key.ts); a
missing or revoked key is Unauthorized;ManageSignalsUseCase.record, which returns the existing
signal when the space already has one with the same externalId;lastUsedAt.domain/shared/text-terms.ts holds the term rules (letters and digits, plurals folded,
stopwords dropped) shared with knowledge ranking. domain/shared/feedback-themes.ts groups
signals into connected components of Jaccard similarity ≥ THEME_SIMILARITY over their title
and detail terms, keeps groups of at least two, labels each by its three most common terms and
keys it by its oldest signal.
GetFeedbackThemesUseCase runs it over a space’s unlinked signals; PromoteThemeUseCase
creates a proposed opportunity and links every signal of the theme.
| Surface | Entry point |
|---|---|
| HTTP | POST /api/feedback |
| CLI | shep feedback key …, shep feedback themes, shep feedback promote |
| Web | Themes and Feedback keys on /opportunities |
| DI | infrastructure/di/modules/register-feedback.ts |