Skip to content

refactor(runtime-catalog): index catalog lookups YEF-947 - #476

Merged
Yevanchen merged 2 commits into
mainfrom
refactor/yef-947-complexity-hotspots
Aug 21, 2026
Merged

refactor(runtime-catalog): index catalog lookups YEF-947#476
Yevanchen merged 2 commits into
mainfrom
refactor/yef-947-complexity-hotspots

Conversation

@Yevanchen

Copy link
Copy Markdown
Collaborator

Summary

  • Precompute lookup indexes for runtime catalog entries, public runtime entries, vendors, and preset model identities.
  • Replace repeated catalog scans in exported getter APIs with map lookups while preserving first-match behavior and fresh array results from list APIs.
  • Add runtime-catalog tests for the indexed helper behavior.

Why

  • Closes YEF-947.
  • The complexity scan found repeated runtime catalog lookup patterns. This changes key catalog getters from repeated O(n) scans to O(1) map lookups, and changes public vendor derivation from nested O(vrrv) scans to O(r*rv + v) module initialization.

Verification

  • Commands:
    • python3 /Users/evanmore/multica_workspaces_desktop-api.multica.ai/baf2a510-889b-4b05-b7c8-c079f5c28938/12b40141/codex-home/skills/complexity-optimizer/scripts/analyze_complexity.py mosoo --format json
    • just fmt-check-path pkgs/runtime-catalog
    • just test-package @mosoo/runtime-catalog
    • just tc-package @mosoo/runtime-catalog
    • bun run --filter @mosoo/runtime-catalog lint
    • just commit-check
  • Manual steps: N/A
  • Not run:
    • just check was attempted. It passed formatting, docs, lint, typecheck, and most tests, then failed in apps/driver/tests/acp-file-system.test.ts on a local macOS temp-path mismatch (/tmp/... expected, /private/tmp/... received) plus an extra sourceEventId; this is outside the changed package.

Impact

  • User/API/contract changes: None.
  • Generated files / GraphQL / DB / lockfile: None.
  • Env or config changes: None.
  • Risk and rollback: Low; revert the single commit to restore the previous linear-scan implementation.

Review

  • Closest review areas: pkgs/runtime-catalog/src/runtime-catalog.ts, pkgs/runtime-catalog/tests/runtime-model-identity-admission.test.ts
  • Known trade-offs: The indexes are built once at module load; memory overhead is small and bounded by the static generated catalog size.

@Yevanchen Yevanchen changed the title refactor(runtime-catalog): index catalog lookups refactor(runtime-catalog): index catalog lookups YEF-947 Jul 31, 2026
@Yevanchen

Yevanchen commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Review verdict: no demonstrated performance need yet. The current catalog contains only 4 runtimes, 10 vendors, and 32 preset models, while this adds multiple indexes and about 80 source lines. A complexity scan proves asymptotics, not user or runtime impact. Please provide a trace or benchmark from a real hot caller; otherwise the smaller linear lookups should stay.

@Yevanchen
Yevanchen force-pushed the refactor/yef-947-complexity-hotspots branch 2 times, most recently from 3916b52 to 4d43e2b Compare August 19, 2026 16:11
@Yevanchen
Yevanchen force-pushed the refactor/yef-947-complexity-hotspots branch from 4d43e2b to 89a8dfc Compare August 20, 2026 16:14
@Yevanchen
Yevanchen merged commit 736d048 into main Aug 21, 2026
9 checks passed
@Yevanchen
Yevanchen deleted the refactor/yef-947-complexity-hotspots branch August 21, 2026 09:58
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