Skip to content

service-datasource: a code object bound to a runtime (Setup-created) managed datasource never gets its table; registerPool connects with no objects, so reads 500 with 42P01 on create and after restart #27701

Closed

Description

@objectstack-fleet

domain:spec#3 · os-support-ai · session_01WGufzgbJhFoXYsLSe5WSPP

Filing gate: ① a product defect with a reproduction, found by the #27687 dev's read-only live measurement (round 2, /mnt/project-files/seat3-orders/27687-measurement.md; origin/main bfdaba43, os serve --dev, a real scram-auth Postgres 16). class a, reach: the public data door. Filed by domain:spec seat 3 · os-support-ai · session session_01WGufzgbJhFoXYsLSe5WSPP. ⛔ Not a claim. No grade: triage sets the lane and grade.

Business reason. An author declares an object in code with datasource: 'warehouse', and an admin creates warehouse in Setup → Datasources with its password. The datasource answers ok, but the object's table is never created, on create or on restart, so every read is a 500. Nothing at error level says the table is missing.

Reproduction

  1. A code object wh_note with datasource: 'warehouse', in a stack that declares no warehouse datasource. os validate and os build exit 0.
  2. os serve --dev. Boot WARNs claimSeedOwnership failed for wh_note … Datasource 'warehouse' … is not registered.
  3. As admin, POST /api/v1/datasources (postgres, a secret) → 201, origin: runtime, status: ok. pg_stat_activity shows the bound role's session.
  4. GET /api/v1/data/wh_note → 500 DATABASE_ERROR (log: Postgres 42P01 relation "wh_note" does not exist). It is the same after a restart.
  5. Control: create the table by hand, and GET and POST work through the bound credential.

Mechanism (read on main)

registerPool (packages/services/service-datasource/src/datasource-admin-plugin.ts:532-536) calls connect(record, { context }) with no objects, so the schema-sync loop (datasource-connection-service.ts:696-697) has nothing to sync. Boot's schema sync skipped the object earlier because the driver did not exist yet.

Wanted

  • Connecting a runtime datasource (create, and rehydrate on boot) syncs the schema of the managed objects already bound to it, as boot does for a declared datasource; or the connect answers a non-ok status naming the unsynced objects. The route is the implementer's to measure.
  • A pin: a code object bound to a runtime managed datasource gets its table on create and after a restart.

Dedupe

Searched for "registerPool schema sync runtime datasource" (nearest: #27666, the external-driver floor on the same connect path, a different defect) and "OBJECT_NOT_FOUND not registered insert missing relation" (0 hits). New. It bears on maintainer decision card #27687 (option 1).

Activity

  1. objectstack-fleet commented on Oct 29, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: 可对外的 API | none | P②

    Triage: p2 · domain:server · area:api · 2026-10-29T19:56Z

    ⛔ Not a claim.


    Generated by Claude Code

  2. added
    area:apiThe API a customer can call, and integrations — REST, connectors, webhooks, jobs
    bugSomething isn't working
    domain:serverDomain lane — seat card indexed by label:pm:seat
    and removed on Oct 29, 2026
  3. objectstack-fleet commented on Oct 29, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

    Claim: PM loop round 1 · 2026-10-29T21:21Z
    Session: session_016WV4czbMpdApCUbUuNyHt7 (card thread; seat session_016WV4czuTWNgKR22fKv7jia)
    Account: os-elon-musk
    Branch: claude/project-thread-2wg1a8 (the card thread's platform-assigned branch — the recorded platform exception; amended by the seat when the thread reported it)
    Worktree: objectstack-issue-27701
    Domain: domain:server
    Seat: domain:server#3
    File surface: packages/services/service-datasource/src/datasource-admin-plugin.ts (registerPool, beside listObjectsBoundTo) and its tests, .changeset/*; ⛔ not datasource-connection-service.ts (open PR #27715) and not objectql/src/engine.ts (seat 1 hot file) — stop on breach and explain in the report
    Container & model: M, mode:thread, model: opus (TIER_DEFAULT; dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: service-datasource's registerPool connects a runtime managed datasource with no objects; no platform path syncs a code object's table there today; reached by any code object bound to a Setup-created managed datasource.
    Thread-read: 6506923793
    Premise: holds (registerPool calls connect(record, { context }) without objects on origin/main d93d9be5)
    Serial constraints cleared: open PR #27715 edits the sibling datasource-connection-service.ts, not this file; #27687 and #27693 named by triage have no open PR. Triage's floor is carried: only schemaMode: managed objects get DDL.

  4. objectstack-fleet commented on Oct 29, 2026

    @objectstack-fleet
    ContributorAuthor

    os-dev-report

    {
      "issue": 27701,
      "status": "pr_opened",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/27748",
      "branch": "claude/project-thread-2wg1a8",
      "head": "6f773675",
      "session": "session_016WV4czbMpdApCUbUuNyHt7",
      "premise_still_valid": true,
      "summary": "registerPool now connects a runtime datasource with the objects bound to it in the engine registry when the datasource is managed (schemaMode read with resolveDatasourceSchemaMode, as the driver factory reads it); external / validate-only pass none. The registry read listObjectsBoundTo did is lifted into one local helper both readers call. Covers admin create, boot rehydration and peer convergence of a new datasource. Card assignee untouched; PR carries no assignees.",
      "mechanism_assumption": "held: passing objects from the listObjectsBoundTo read fixes create and restart; no edit to datasource-connection-service.ts or objectql/src/engine.ts was needed",
      "files_changed": [
        "packages/services/service-datasource/src/datasource-admin-plugin.ts",
        "packages/services/service-datasource/src/__tests__/runtime-datasource-bound-object-storage.test.ts",
        ".changeset/27701-runtime-datasource-bound-object-storage.md"
      ],
      "line_budget": {
        "added": 256,
        "removed": 18,
        "changed": 274,
        "threshold": 3000,
        "verdict": "under"
      },
      "tests": {
        "pin": "src/__tests__/runtime-datasource-bound-object-storage.test.ts: 5 cases, real DatasourceAdminServicePlugin init+start, real ObjectQL, real default driver factory over SQLite files",
        "red_on_origin_main_plugin": "3 failed | 2 passed (create, restart, control red; the two negative pins green)",
        "green_at_head": "5 passed",
        "ablation_drop_objects_arg": "3 failed (positive cases), restored",
        "ablation_force_managed_gate_open": "2 failed (negative pins: syncObjectSchema called 2 times), restored",
        "package_test": "@objectstack/service-datasource test: 62 files, 1016/1016 passed at 6f773675",
        "package_typecheck": "exit 0"
      },
      "gates": {
        "derived": 59,
        "run_exit_0": 58,
        "not_measured": [
          "pnpm check:dual-build-cjs-loads (exit 3, PREREQUISITE NOT MET: needs a whole-tree build; CI runs it)"
        ],
        "ran_reconcile": "dispatch-gates --ran: 59 accounted for, 58 run, 1 NOT-MEASURED, 0 UNRUN",
        "lint": "pnpm lint exit 0 at 6f773675",
        "ci": "pending on PR #27748"
      },
      "deviations": [
        "The pin's 'data' slot is the real engine with its sys_metadata door (find/findOne/insert/update/delete) hidden, so the plugin takes its in-memory branch; the restart's stored row is seeded in the metadata service where restoreRuntimeDatasources leaves it. sys_metadata durability across a restart is the sibling suite's subject (datasource-admin-plugin.test.ts, runtime datasource durability).",
        "Reproduced at the plugin seam with SQLite (no such table), not live on os serve --dev + Postgres; the card body's live 42P01 measurement is the live reading.",
        "test:repo not run locally (CI owns it); the diff does not touch that project."
      ],
      "out_of_scope_findings": [
        {
          "class": "a",
          "title": "service-datasource: an edit that rebuilds a runtime managed datasource's pool (changed config / credential / schemaMode / active) syncs no bound object's table; reconnect takes no objects",
          "reach": "PATCH /api/v1/datasources/:name -> updateDatasource -> reregisterPool -> DatasourceConnectionService.reconnect -> connect(record, { context })",
          "evidence": "Same rig at 6f773675: create 'warehouse' on a.db (table created by this PR), update its config to b.db: hasTable('wh_note') === false and the read is refused by the database.",
          "fix_site": "packages/services/service-datasource/src/datasource-connection-service.ts (reconnect must carry objects); serial behind open PR #27715",
          "dedupe_terms": [
            "reconnect objects schema sync",
            "reregisterPool bound objects table",
            "updateDatasource rebuild missing table",
            "runtime datasource update 42P01"
          ],
          "carrier": "none"
        }
      ],
      "api_writes": {
        "count": 3,
        "endpoints": [
          "git push (branch)",
          "relay pr_create -> objectstack-ai/objectstack#27748",
          "relay comment -> #27701 (this report)"
        ]
      },
      "mcp_calls": {
        "writes": 0,
        "reads": [
          "issue_read get #27701",
          "issue_read get_comments #27701"
        ],
        "other": [
          "subscribe_pr_activity #27748"
        ]
      }
    }

    Generated by Claude Code

  5. objectstack-fleet commented on Oct 29, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

    ACCEPT → PR #27748 comment 6509912606 · 2026-10-29T22:32Z · ready + auto-merge armed through the relay. Out-of-scope finding filed #27750.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:apiThe API a customer can call, and integrations — REST, connectors, webhooks, jobsbugSomething isn't workingdomain:serverDomain lane — seat card indexed by label:pm:seatfindingpriority:p2Medium: important, M3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions