Skip to content

server: add /api/v1/types endpoint + lazy bare-type fallback#9

Merged
kurtseifried merged 1 commit into
mainfrom
feat/discovery-endpoints
May 28, 2026
Merged

server: add /api/v1/types endpoint + lazy bare-type fallback#9
kurtseifried merged 1 commit into
mainfrom
feat/discovery-endpoints

Conversation

@kurtseifried

Copy link
Copy Markdown
Contributor

Summary

Phase 2.5(c) — closes two of the remaining three conformance failures by adding discovery-style endpoints + a lazy-mode fallback for bare-type queries.

What's fixed

`list-types` conformance fixture

New endpoint `GET /api/v1/types` returns the canonical type list with descriptions, mirroring SecID-Service's same endpoint. Type metadata sourced from `registry/.json` files in the configured registry directories.

Open question for the spec: subtype descriptions currently live in SecID-Service's `type-registry.ts` only — not in registry data. The Python endpoint returns `subtypes: []` for every type and notes the limitation in a docstring. Future work could centralize a `schemas/type-registry.json` in SecID so all implementations read from one canonical source.

`list-advisory-namespaces` conformance fixture

Bare-type queries (`secid:advisory`) now work in lazy mode. The bug: `bulk_load` builds the `secid:` index, but `load_single` doesn't — so lazy mode never had the data. The fix: lazy-load `registry/.json` from disk on demand, exactly like `load_single` does for namespace files.

Conformance progression

Stage Pass / Total
Before Phase 2.5(a) 3 / 10
After Phase 2.5(a) — URL templates + data block 7 / 10
After this PR — discovery endpoints 9 / 10
Remaining: `resolve-cve-cross-source` Phase 2.5(d)

New helpers in `registry_loader.py`

  • `load_type_info(registry_dirs, secid_type)` — reads `registry/.json` from the first directory that has it
  • `list_all_types(registry_dirs)` — returns metadata for all 10 types in canonical order

Tests

  • 4 new unit tests in `test_smoke.py`. 23/23 pass.
  • Conformance: 9/10 (up from 7).

Out of scope (Phase 2.5(d))

  • `resolve-cve-cross-source` — bare-namespace cross-source search (`secid:advisory/CVE-XXX` should scan all advisory namespaces). Independent code path; next PR.

🤖 Generated with Claude Code

Phase 2.5(c). Closes two of the remaining three conformance failures by
adding discovery-style endpoints + a lazy-mode fallback for bare-type
queries.

Changes:

1. registry_loader.py: new load_type_info(registry_dirs, secid_type)
   helper reads registry/<type>.json from the first directory that has it.
   Returns the parsed type-level metadata (description, purpose, format,
   examples) or None.

2. registry_loader.py: new list_all_types(registry_dirs) returns
   metadata for all 10 SecID types in canonical order. Used by the
   /api/v1/types endpoint and informs future centralization of subtype
   declarations.

3. resolver.py: bare-type queries (e.g., secid:advisory) now fall back
   to load_type_info() when the store doesn't have the index. Bulk-load
   builds the index at startup; lazy mode now lazily fills it in too.
   Closes the list-advisory-namespaces conformance failure.

4. secid_server.py: new GET /api/v1/types endpoint mirrors SecID-Service.
   Returns {types: [{type, description, long_description, subtypes}, ...]}.
   Subtypes are always [] today — those descriptions live in
   SecID-Service's type-registry.ts, not yet in registry data. Closes
   the list-types conformance failure.

Tests:
- 4 new unit tests in test_smoke.py covering:
    - /api/v1/types returns exactly 10 types
    - Each entry has the canonical shape
    - list_all_types() works without any registry data
    - load_type_info() returns None for missing files
- 23/23 tests pass locally.

Conformance progression:
  After Phase 2.5(a): 7/10
  After this PR:      9/10
  Remaining:          1/10 (resolve-cve-cross-source — needs bare-
                            namespace cross-source search, Phase 2.5d)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@kurtseifried kurtseifried merged commit f8b353a into main May 28, 2026
@kurtseifried kurtseifried deleted the feat/discovery-endpoints branch May 28, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant