Skip to content

Catalog: residual objects-view members + mod-time staleness follow-ons (index completeness & large-project build done) #658

@ako

Description

@ako

Summary

The catalog (.mxcli/catalog.db) is a useful name→type/index substrate (it now backs describe type auto-detection, marketplace-style scans, code search, etc.). The original three limitations below have largely been resolved; what remains is a small residual follow-on plus one deliberately-deferred item.

1. The objects view is not a complete index — ✅ DONE

The objects view now indexes every describable top-level document type the catalog builds. Closed out across three increments:

  • v3 — associations folded in (ObjectType = ASSOCIATION); describe auto-detect drops its separate associations query.
  • v4 — image collections, JavaScript actions, data transformers cataloged (new tables + generic buildSimpleNamedDocs, no CatalogReader/backend change).
  • v5 — agent-editor docs cataloged (agent / model / knowledge base / consumed MCP service; Name is a top-level BSON field, so same raw-unit pattern, no backend change). Verified live against test3-app.

Also fixed SHOW CATALOG TABLES, whose hand-maintained list had drifted and never showed the new views — now complete and guarded by TestTables_CoversAllViews (every catalog VIEW must be listed).

1a. Residual: sub-document members (small follow-on, low priority)

A few describable things the issue originally listed are sub-document members, not top-level named documents, so they're intentionally not in objects yet: attributes (Module.Entity.Attribute), module/user roles, navigation, fragments. Folding these in (or exposing a superset view) is worth doing only if a consumer actually needs to resolve them by qualified name — describe handles them today via explicit type / live scan.

2. Staleness signal is mod-time only (deferred — acceptable for now)

isCacheValid invalidates purely on .mpr file mod-time. That catches edits saved to disk, but cannot see a project's unsaved in-memory changes — e.g. when working through the MCP/PED backend against a project open in Studio Pro. The cache can then disagree with the live model.

Deliberately deprioritized: users rarely have hundreds of unsaved documents, and MCP/PED save functionality is expected to land soon (which makes disk mod-time a sufficient signal again). Worth revisiting if that changes — options would be a content hash or backend-liveness awareness. (describe already gates its catalog read on mod-time freshness and falls back to a live scan otherwise.)

3. First build is slow on large projects — ✅ DONE

refresh catalog source was O(N²): it resolved each document by re-reading and re-bson.Unmarshaling every unit on every describe call (#651-scale: ~3.3k microflows / ~33k activities → ~6 hours). Now O(1) via a one-time $Type + qualified-name → unit name index (decoding only Name), with incremental progress reported every 2s instead of a silent multi-minute parse. Hours → minutes on cloud-portal-scale projects. (The generic 5-minute statement-guard timeout was the separately-fixed #651.)

Remaining scope

  • 1a — fold sub-document members (attributes / roles / navigation / fragments) into objects if/when a consumer needs qualified-name resolution for them.
  • 2 — revisit the mod-time-only staleness signal if MCP/PED save doesn't land or unsaved-change drift becomes a real problem.

Both are low-priority / conditional; the core ask (a complete unified index + a build that finishes in reasonable time) is delivered.

References

  • mdl/catalog/tables.go (objects view), mdl/catalog/catalog.go (Tables()), mdl/executor/cmd_catalog.go (isCacheValid)
  • cmd/mxcli/cmd_describe.go (resolveViaCatalog / catalogMatchesProject)
  • REFRESH CATALOG SOURCE leading to timeout (5mins) #651 (catalog build timeout on large projects — fixed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions