Skip to content

metadata-protocol: $expand and a relation condition serve a disabled package's records through an enabled object's lookup, while the data route answers 404 OBJECT_PACKAGE_DISABLED #35427

Closed

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd

Filing gate ①: escalated by contract review 7003145171 on PR #35367 (③, "file a card if it serves"), measured by area pkg-2 on origin/main adcb9f8.

维护者速读

  • 用户能看到什么变化:某个应用包停用后,别的应用通过“关联字段展开”仍能读到它的记录全文;修好后只看到关联记录的编号,跟直接打开时一样被挡住。
  • 为什么做:停用包的数据本该在所有读取入口都看不到,全局搜索刚修好,这是同一类的另一扇门。
  • 出错会怎样:最坏情况是展开时仍带出停用包的记录,和现在一样;未停用任何包的环境不受影响。
  • 要你做什么:无。

Reach (measured)

Real kernel (MetadataPlugin + ObjectQLPlugin + SqlDriver, in-memory SQLite) via HttpDispatcher.dispatch. Package B owns beta_obj; package A's alpha_obj has lookup b_ref → beta_obj. engine.registry.disablePackage(B):

  • GET /data/beta_obj → 404 OBJECT_PACKAGE_DISABLED (as designed).
  • GET /data/alpha_obj?$expand=b_ref → 200, b_ref expanded to the full beta row (every field).
  • GET /data/alpha_obj/:id?expand=b_ref → 200, same.
  • $filter={"b_ref":{"secret_note":VALUE}} → 200 with 1 row for the true value, 0 for a false one: a yes/no oracle on a disabled object's fields.
  • CONTROLs: $select / dotted $filter across the lookup are refused for every target (400 INVALID_FIELD); without $expand the lookup stays the bare id.
    Caller was isSystem; the guards involved are object-level and caller-independent (non-system caller not measured).

Seam

packages/metadata-protocol/src/protocol-query-validation.ts: servesExpansionTarget and refuseUnservedRelationTarget ask only declared API exposure (canServeApiOperation / apiExposureDenialReason), never isObjectOfDisabledPackage (already imported there; assertObjectRegistered uses it). Route: a disabled target drops out of the expand map (bare id, as an apiEnabled:false target today); a relation condition on a disabled target is refused with objectPackageDisabledError. Engine serveReferenceNames titles ride the same expansion, so the same fix covers them.

Not measured (read only)

service-analytics: its object gate (isRegisteredObject = engine.getObject(name) != null, api-exposure-door.ts) has no disabled-package check for base objects or joins. Measure before filing.

Permissions: both paths read the related object AS THE CALLER through engine.find with the caller's context (engine-summaries-and-expansion.ts ~956-1024: the security middleware applies the referenced object's CRUD gate, requiredPermissions, RLS and FLS to the expansion, #7626; engine-query-lowering.ts lowerRelationConditions reads ids "as the caller"). So nothing reaches a reader who could not read those rows with the package enabled: a disable not honoured, the same class as #35195, not a permission breach.

Related: #35195 (search door, PR #35367), #34900 (in-process ctx.api, ruled served by 6545646924), #7557.
Suggested-grade: p2 · domain:server (same class as #35195, graded p2 by triage 6980431022).

Activity

  1. added
    priority:p2
    pm:queue
    domain:server
    on Nov 19, 2026
  2. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd

    Claim: PM loop round 3 · area pkg-2 (the maintainer, verbatim, 2026-11-19T05:04Z project chat: 「再开一个 area:package」; filing OK 2026-11-19T08:50Z 「同意」) · 2026-11-19T09:13Z
    Area: pkg-2
    Session: session_01Utp6CbP6iSEGkWb5fn8yqd
    Account: os-bill
    Branch: claude/issue-35427-expand-disabled-package
    Worktree: objectstack-issue-35427 (os-dev worktree in the pkg-2 container)
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: packages/metadata-protocol/src/protocol-query-validation.ts (servesExpansionTarget, refuseUnservedRelationTarget), a new test file named for this card, root .changeset/. ⛔ packages/objectql/**, packages/spec/**, packages/services/** (analytics is read-only in the card, not this PR). Stop on breach and report.
    Container & model: S, mode:subagent, model: default — no path-derived mandate, effort: medium
    Clause-②: yes (narrowing: $expand stops serving a disabled package's rows; a relation condition on one is refused)
    Metadata-protocol: none (a runtime door's answer narrows; same reading as #35195's L1-a and L2)
    Responsibility: platform — servesExpansionTarget and refuseUnservedRelationTarget ask only declared API exposure, so an enabled object's lookup into a disabled package's object serves that object's rows through $expand and answers a relation-condition $filter on its fields, while the direct data route answers 404 OBJECT_PACKAGE_DISABLED; every data-route caller on an environment that disables a package.
    Thread-read: none
    Premise: measured on origin/main adcb9f8e before filing (card body); isObjectOfDisabledPackage is already imported at protocol-query-validation.ts:49 and used at :331, not in the two functions (:1378, :1430).
    Serial constraints cleared: none — overlap-check.mjs on a probe branch touching protocol-query-validation.ts at ee40658d: 0 open PR heads share the file, base merges cleanly.
    Pre-claim lane: domain:server (packages/metadata-protocol/**)
    Pre-claim deps: parent #35195 merged (PR #35367, ee40658d0d).
    Prior rulings read: #7557 (a disabled package's object refused on the data plane); #34900's ruling 6545646924 (in-process access stays served: not this door, this is a public data route); L2 7003145171 ③ escalation; thread: none

  3. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 19, 2026
  4. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd
    os-dev-report

    {
      "issue": 35427,
      "status": "done",
      "branch": "claude/issue-35427-expand-disabled-package",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35444",
      "head": "1153f761",
      "session": "session_01Utp6CbP6iSEGkWb5fn8yqd",
      "premise_still_valid": true,
      "summary": "servesExpansionTarget now also asks isObjectOfDisabledPackage(registry, target): an $expand entry (list comma, POST map, by-id expand, any level) whose target belongs to a disabled package is withheld and the lookup keeps its bare id, as for an apiEnabled:false target. refuseUnservedRelationTarget first asks the same predicate and throws objectPackageDisabledError(target) (404 OBJECT_PACKAGE_DISABLED, object + param) for a nested-relation condition, before the query runs. Changeset metadata-protocol patch with the BREAKING banner and the ADR-0087 not-required marker. A1 RED and GREEN measured through the real door (area probe re-run, throwaway, not committed).",
      "readings": {
        "A1": "CONFIRMED at ee40658d through HttpDispatcher + MetadataPlugin + ObjectQLPlugin + SqlDriver: package of beta_obj disabled, GET /data/beta_obj 404 OBJECT_PACKAGE_DISABLED; GET /data/alpha_obj?$expand=b_ref 200 with the full beta row incl. secret_note; by-id ?expand=b_ref 200 same; relation $filter hit 1 row / miss 0 rows. At d18331a0 (metadata-protocol rebuilt): list $expand and by-id expand 200 with b_ref the bare id; relation $filter hit and miss both 404 OBJECT_PACKAGE_DISABLED; CONTROL enabled still expands the full row. The rig needs runtime (HttpDispatcher, objectql, driver-sql), so the committed test is a protocol-level fake-engine file in metadata-protocol; the probe ran from a scratch subdir in packages/runtime/src and was deleted before commit.",
        "A2": "CONFIRMED by read and real door: findData (protocol-data-crud.ts:391) and getData (:986) both call servedExpand -> servesExpansionTarget; one guard covers both (by-id bare id measured at the real door). Note: the by-id route answers 400 to the $expand spelling; its spelling is expand.",
        "A3": "CONFIRMED by read: serveReferenceNames runs inside expandRelatedRecords' loop over the handed expand map (engine-summaries-and-expansion.ts ~864 and ~1093), so a withheld entry gets no title."
      },
      "tests": "1153f761: pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.expand-disabled-package-35427.test.ts -> Tests 12 passed (12). RED at base ee40658d (13-test version): 7 failed | 6 passed (all pins red, all controls green). d18331a0: metadata-protocol test -> Test Files 360 passed | 9 skipped (369), Tests 23247 passed | 45 skipped; typecheck exit 0 (second commit touches only the test file). Ablation at d18331a0 via scripts/ablation-replace.mjs (src-resolved suite, no dist hop), each restored to HEAD blob 69c71bdf with git diff HEAD empty: expansion guard -> 4 failed | 9 passed; relation guard (if false) -> 3 failed | 10 passed. First expansion-guard attempt (replacement ';') was refused by ablation-replace as not provably landed (no run), redone with a distinctive marker.",
      "gates": "dispatch-gates --commands at 1153f761: 67 families; 66 exit 0, 1 exit 3 = NOT MEASURED: check:dual-build-cjs-loads, reason: PREREQUISITE NOT MET (no dist for ~41 packages outside the built closure); --ran with exit codes: 67 derived, 66 run, 1 NOT-MEASURED, 0 UNRUN, exit 0. At d18331a0 check:engine-double-contract and check:test-source-alias were red (new findOne double unpinned in ledger; lint not loaded at module top), fixed in 1153f761 in-fence. overlap-check --branch=HEAD: VERDICT clean exit 0 before each push. PR check-runs at 1153f761: 53 runs, 37 success, 16 skipped, 0 failed (incl. Test Core 1-10/10, TypeScript Type Check, Lint & Repo Gates, Dogfood Regression Gate, Build Core, Check Changeset, PR-body guards, Governed Surface Queue Guard).",
      "dogfood_battery": "1153f761 · os-verify-lock VERDICT command-exit 0 · Test Files 482 passed | 3 skipped (485) · Tests 4092 passed | 68 skipped (4160) · no failures",
      "line_budget": "n/a — no skills/** or ratcheted ledger touched",
      "files_changed": ["packages/metadata-protocol/src/protocol-query-validation.ts", "packages/metadata-protocol/src/protocol.expand-disabled-package-35427.test.ts", ".changeset/35427-expand-disabled-package.md"],
      "deviations": [
        "By-id expand unit pin dropped: a getData double needs a findOne double, which check:engine-double-contract requires pinned AND recorded in scripts/engine-double-contract.pinned.json (outside the fence). Kept in fence; by-id is measured at the real door (A1/A2) and shares servedExpand with the pinned list path.",
        "PR body (written once at pr_create on d18331a0) cites 7 pins + 6 controls, 13 tests and ablation counts 4/3 failed; at 1153f761 the file has 6 pins + 6 controls (12 tests). Body rewrite is the seat's.",
        "PR body maintainer brief follows the dispatch order (four lines) rather than os-dev.md's six-line form.",
        "Throwaway real-door probe ran from packages/runtime/src/zz-probe-35427/ (deleted, never committed).",
        "First dogfood run on d18331a0 was stopped by me after the test-only commit so the battery runs once on the final head."
      ],
      "mcp_calls": "0",
      "api_writes": "2 — relay pr_create (POST /repos/objectstack-ai/objectstack/pulls + POST /issues/35444/assignees, via one repository_dispatch); relay comment os-dev-report on #35427 via post-stamped.mjs. Plus git push x3 (not REST).",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": ["carrier: none · noted, not filed — service-analytics object gate (card's read-only note) not measured here"]
    }
  5. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd
    os-dev-report

    Delta for PR #35444 at head 88ea36c: dogfood battery re-run on the landing head. No code change, no push.

    {
      "issue": 35427,
      "status": "done",
      "branch": "claude/issue-35427-expand-disabled-package",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35444",
      "head": "88ea36c3b67886be3e0fca3c07db63be833dc896",
      "session": "session_01Utp6CbP6iSEGkWb5fn8yqd",
      "summary": "Delta: full dogfood battery on the landing head 88ea36c3 (single-parent changeset-declaration commit above 1153f761), run in a detached worktree at that sha after building the dogfood closure there.",
      "dogfood_battery": "88ea36c3b67886be3e0fca3c07db63be833dc896 · os-verify-lock VERDICT command-exit 0 (held 32m54s, shared box) · Test Files 482 passed | 3 skipped (485) · Tests 4092 passed | 68 skipped (4160) · no failures",
      "mcp_calls": "0",
      "api_writes": "1 — this comment via post-stamped.mjs (relay)",
      "security_findings": "none"
    }
  6. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-bill · session_01Utp6CbP6iSEGkWb5fn8yqd

    Closed-out · area pkg-2 · 2026-11-19T12:18Z

    reading value
    PR #35444 MERGED through the merge queue as 819c0679a8 (Fixes #35427; this card closed completed)
    contract record L1-a ACCEPT 7007008749 (+ correction 7007031119); contract review PASS 7007338672 at CONTRACT_REVIEW_TIER; dogfood battery at the landed head (7008229794)

    Delivered: an enabled object's lookup into a disabled package's object keeps the bare id under $expand (list, by-id, POST map, every level, titles included). A relation condition on such an object is refused with 404 OBJECT_PACKAGE_DISABLED before the query runs, for every caller, the same as the direct data route. Re-enabling the package restores both.
    Follow-ups, measured, with card drafts waiting for the maintainer's OK to file:

  7. removed
    pm:dispatched
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:packagedomain:serverpriority:p2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions