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

@ -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,
};
}