R21.3: delete the unreachable registered-app resolution path

The runtime app-registration writer (POST /v1/apps) was deleted in an
earlier pass because it minted a client_secret nobody verified. This
pass kept resolveAppProfile's registered-app fallback and
listAppProfiles on the theory that AppSlug is an open string and
dynamic registration was a live extension point. Soul falsified that:
every HTTP route enumerates the four built-in slugs in its own JSON
schema (app.ts's `enum: [...appSlugs]` at every appSlug param/body
field), so a registered row could never be resolved from a request.
With the writer already gone, this was unreachable code behind a dead
writer -- delete it rather than keep authenticating a door nobody can
open.

Deleted: src/app-registry.ts entirely (resolveAppProfile,
listAppProfiles, isBuiltInApp, registeredAppToProfile,
returnOriginsFromRedirectUris); StoredRegisteredApp and the
findRegisteredApp/listRegisteredApps HeimdallStore methods
(store/types.ts); their InMemoryStore and PostgresStore
implementations, including seedRegisteredApp and mapRegisteredApp; the
registered_apps table (store/schema.ts now drops it on any store built
before this schema); tests/app-registry.test.ts.

Every call site (app.ts x5, claims.ts, private-command-plane.ts) now
calls the existing built-in-only getAppProfile (app-profiles.ts)
directly -- sync, no store needed. If dynamic app registration is
wanted later it returns as a designed, authenticated feature, not by
resurrecting this vestige.

Net -305 lines against the prior commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-08 14:51:23 +02:00
commit e21659cd31
11 changed files with 33 additions and 338 deletions

View file

@ -15,7 +15,6 @@ import {
type StoredAuthCompletion,
type StoredCapabilityGrant,
type StoredLinkedIdentity,
type StoredRegisteredApp,
type StoredSession,
type StoredPrivateCommandReceipt,
type UpsertLinkedIdentityInput,
@ -38,7 +37,6 @@ function isGrantActive(grant: StoredCapabilityGrant, appSlug: AppSlug, at: strin
}
export class InMemoryStore implements HeimdallStore {
private readonly registeredApps = new Map<string, StoredRegisteredApp>();
private readonly accounts = new Map<string, StoredAccount>();
private readonly linkedIdentities = new Map<string, StoredLinkedIdentity>();
private readonly grants = new Map<string, StoredCapabilityGrant>();
@ -50,27 +48,6 @@ export class InMemoryStore implements HeimdallStore {
private readonly entitlementSnapshots = new Map<string, CreateEntitlementSnapshotInput>();
private readonly auditEvents = new Map<string, CreateAuditEventInput>();
/**
* Test/ops seam only — not part of HeimdallStore. There is no production
* writer for `registered_apps` anymore; a real deployment provisions a row
* directly against Postgres. This lets fixtures exercise resolveAppProfile's
* non-built-in branch the same way.
*/
seedRegisteredApp(record: StoredRegisteredApp): void {
this.registeredApps.set(record.slug, structuredClone(record));
}
async findRegisteredApp(slug: string): Promise<StoredRegisteredApp | null> {
const record = this.registeredApps.get(slug);
return record ? structuredClone(record) : null;
}
async listRegisteredApps(): Promise<StoredRegisteredApp[]> {
return [...this.registeredApps.values()]
.sort((left, right) => left.slug.localeCompare(right.slug))
.map((record) => structuredClone(record));
}
async ensureSchema(): Promise<void> {
return;
}

View file

@ -1,6 +1,5 @@
import { randomUUID } from "node:crypto";
import { Pool, type PoolClient, type QueryResultRow } from "pg";
import { type CapabilityDefinition } from "../capability-rules.js";
import { type AppSlug, type HeimdallAuthAttemptStatus, type LinkedIdentityInput, type Provider } from "../contracts.js";
import { CREATE_SCHEMA_SQL } from "./schema.js";
import {
@ -18,7 +17,6 @@ import {
type StoredAuthCompletion,
type StoredCapabilityGrant,
type StoredLinkedIdentity,
type StoredRegisteredApp,
type StoredSession,
type StoredPrivateCommandReceipt,
type UpsertLinkedIdentityInput,
@ -63,19 +61,6 @@ interface GrantRow extends QueryResultRow {
updated_at: string;
}
interface RegisteredAppRow extends QueryResultRow {
slug: string;
display_name: string;
profile_version: string;
created_at: string;
updated_at: string;
identity_providers: Provider[];
entitlement_sources: Provider[];
managed_connection_providers: Provider[];
capabilities_json: CapabilityDefinition[];
redirect_uris: string[];
}
interface SessionRow extends QueryResultRow {
id: string;
account_id: string;
@ -302,28 +287,6 @@ function mapAuthAttemptRow(row: AuthAttemptRow): StoredAuthAttempt {
export class PostgresStore implements HeimdallStore {
constructor(private readonly pool: Pick<Pool, "query" | "end">) {}
// There is no production writer for registered_apps anymore (the
// caller-identity cut deleted the runtime registration surface that minted
// a client_secret nobody verified). A row can still be provisioned by
// direct SQL against this table; findRegisteredApp/listRegisteredApps below
// keep reading it as a profile source beneath the built-in profiles.
async findRegisteredApp(slug: string): Promise<StoredRegisteredApp | null> {
const result = await this.pool.query<RegisteredAppRow>(
`SELECT * FROM registered_apps WHERE slug = $1`,
[slug],
);
const row = result.rows[0];
return row ? mapRegisteredApp(row) : null;
}
async listRegisteredApps(): Promise<StoredRegisteredApp[]> {
const result = await this.pool.query<RegisteredAppRow>(
`SELECT * FROM registered_apps ORDER BY slug ASC`,
);
return result.rows.map(mapRegisteredApp);
}
async ensureSchema(): Promise<void> {
await this.pool.query(CREATE_SCHEMA_SQL);
}
@ -834,18 +797,3 @@ export function createPostgresStore(databaseUrl: string): HeimdallStore {
});
return new PostgresStore(pool);
}
function mapRegisteredApp(row: RegisteredAppRow): StoredRegisteredApp {
return {
slug: row.slug,
displayName: row.display_name,
profileVersion: row.profile_version,
createdAt: new Date(row.created_at).toISOString(),
updatedAt: new Date(row.updated_at).toISOString(),
identityProviders: row.identity_providers,
entitlementSources: row.entitlement_sources,
managedConnectionProviders: row.managed_connection_providers,
capabilities: row.capabilities_json,
redirectUris: row.redirect_uris,
};
}

View file

@ -1,21 +1,11 @@
export const CREATE_SCHEMA_SQL = `
CREATE TABLE IF NOT EXISTS registered_apps (
slug TEXT PRIMARY KEY,
display_name TEXT NOT NULL,
profile_version TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL,
identity_providers JSONB NOT NULL,
entitlement_sources JSONB NOT NULL,
managed_connection_providers JSONB NOT NULL,
capabilities_json JSONB NOT NULL,
redirect_uris JSONB NOT NULL
);
-- Runtime app registration (POST /v1/apps) minted a client_secret_hash that
-- nothing ever verified. Deleted with the caller-identity cut; drop the
-- column on any store built before this schema too.
ALTER TABLE registered_apps DROP COLUMN IF EXISTS client_secret_hash;
-- nothing ever verified, and the registered_apps table it fed was
-- unreachable dead code even after that writer was deleted: every HTTP route
-- already enumerates the four built-in app slugs in its own JSON schema, so a
-- registered row could never be resolved from a request (R21.3). Drop the
-- table on any store built before this schema too.
DROP TABLE IF EXISTS registered_apps;
CREATE TABLE IF NOT EXISTS accounts (
id TEXT PRIMARY KEY,

View file

@ -1,4 +1,3 @@
import { type CapabilityDefinition } from "../capability-rules.js";
import {
type AppSlug,
type HeimdallAuthAttemptStatus,
@ -7,27 +6,6 @@ import {
type Provider,
} from "../contracts.js";
/**
* An app registered at runtime.
*
* The built-in profiles are seed data of the same shape; nothing here is
* special-cased for them. There is no runtime registration authority anymore
* (deleted with the auth-hole cut: a minted client_secret nobody verified);
* this remains a profile store consulted by resolveAppProfile.
*/
export interface StoredRegisteredApp {
slug: string;
displayName: string;
profileVersion: string;
createdAt: string;
updatedAt: string;
identityProviders: Provider[];
entitlementSources: Provider[];
managedConnectionProviders: Provider[];
capabilities: CapabilityDefinition[];
redirectUris: string[];
}
export interface StoredAccount {
id: string;
createdAt: string;
@ -225,16 +203,6 @@ export interface StoredPrivateCommandReceipt {
export type CreatePrivateCommandReceiptInput = StoredPrivateCommandReceipt;
export interface HeimdallStore {
/**
* There is no runtime writer for this table anymore (the caller-identity
* cut deleted the registration surface that minted a client_secret nobody
* verified). A profile row can still be provisioned directly against the
* store outside the app, which is how the InMemoryStore test double and any
* future ops-side seeding populate it; `resolveAppProfile` keeps consulting
* it below the built-in profiles.
*/
findRegisteredApp(slug: string): Promise<StoredRegisteredApp | null>;
listRegisteredApps(): Promise<StoredRegisteredApp[]>;
ensureSchema(): Promise<void>;
close(): Promise<void>;
createAccount(input: CreateAccountInput): Promise<StoredAccount>;