Skip to content

core: activation ledger unique (metadata_type, package_id, name), backfilled (ADR-0150 child S1) #31682

Closed

Description

@objectstack-fleet

epic:#31527#1 · os-project-manager · session_01FEkQ5mLd7pR2PHjsPwiGkz

Filing gate: ④ coordination node: child S1 of the epic #31527 (parent and per-layer children), as ADR-0150 (docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md, merged in #31586 at 5d1382a)'s execution plan lists it. Hand-over card: filed undispatched as the epic seat signs off (maintainer 2026-11-08T16:34Z 「专题卡当前任务处理完,合并后就下班」). ⛔ Not a claim.
Ruling-ref: per-type table A (6723462584); epic A 「立专题」 (6723499113); division of labour A 「留核心,其余交车道」 (6723571682); ADR-0150 accepted by merge (#31586, 2026-11-08T21:16Z).
Business reason: inherited from the parent #31527. Behavioural metadata is addressed by (package, name), so two installed packages can each ship an item of the same name and every reader answers the right one, or refuses with the candidates, instead of silently taking the first match.
Reader: the next domain:server seat picks it from the queue (pm-dispatch selection) and accepts its PR against the red lines below.
Dedupe (open AND closed): activation ledger package_id (51; top hits #30806(open) #28411(closed) #23999(closed), none on point: they are this epic, its parent #30806, or unrelated cards).
class: d · type: Feature
Grade: p1, inherited from the parent (self-graded under 「定级你可以自己决定」).
Blocked-by: #31575

维护者速读

激活台账的唯一键加上软件包 id,并回填已有数据。可重复执行,不猜歧义。

What to build

The activation ledger's unique key becomes (metadata_type, package_id, name), the package column backfilled from the phase-1 holder (D8, R4). The migration is re-runnable and reports the ambiguous set, never guessing.

Surface

  • Expected file surface: platform-objects, core metadata-activation-store.ts.
  • Clause-②: no.
  • Narrowing: no.

Acceptance — the epic's three red lines (every child shares them)

  • Resolution never loosens. No first-registered fallback, no environment-wide guess for a caller with a package, no silent pick.
  • Ambiguity is reported, never guessed. Every refusal and every migration report names every candidate.
  • Independently releasable (red line 3). The PR proves it with ADR-0150's four readings: (a) the phase-1 one-holder tests stay green; (b) bare-name behaviour (URLs, MCP, SDK) is unchanged for every name with one holder, except this card's declared narrowing; (c) any migration is re-runnable and never guesses; (d) its Clause-②: declaration and, where it changes the protocol, its ADR-0087 migration entry.
  • The epic seat is off duty after hand-over: the accepting lane seat checks these lines itself, and a narrowing beyond the declared one goes to the maintainer before landing.

Parent: #31527.

Activity

  1. added
    enhancement
    priority:p1
    pm:blocked
    area:devpath
    domain:server
    on Nov 8, 2026
  2. objectstack-fleet commented on Nov 8, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: none

    Triage: confirmed · domain:server · p1 · pm:blocked · 2026-11-08T22:00Z

    ⛔ Not a claim.


    Generated by Claude Code

  3. added
    pm:blocking
    on Nov 8, 2026
  4. objectstack-fleet commented on Nov 8, 2026

    @objectstack-fleet
    ContributorAuthor

    epic:#31527#1 · os-steve · session_01ADHkmP7o3uDTti21wLTfPf

    Unblocked 2026-11-08T23:03Z: Blocked-by: #31575 is closed. R merged in #31637 as 0ebb080 (resolvePackageScopedName, packageResolutionClosure and the three read-only SchemaRegistry package-scoped methods in objectql; packageDependencyClosure in metadata-protocol). pm:blocked → pm:queue in this stroke. Read the resolver through those exports only, and never re-implement the rule. The epic seat reviews this card's PR against the three red lines before it lands.

  5. added
    pm:queue
    and removed
    pm:blocked
    on Nov 8, 2026
  6. objectstack-fleet commented on Nov 8, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim: PM loop round 1 · #31682 · 2026-11-08T23:06Z
    Session: session_01ADHkmP8JJo4zF2sjTBRwnX (seat); dev = card thread session_01ADHkmQYLwhv2dRdWVF3aU1
    Account: os-steve
    Branch: claude/project-thread-dldbug
    Worktree: the card thread's checkout of objectstack-ai/objectstack
    Domain: domain:server
    Seat: domain:server#4
    File surface: packages/platform-objects/src/** (the activation ledger object's unique key and package column), packages/core/src/** (metadata-activation-store.ts), the backfill/migration entry it needs, their tests, .changeset/31682-*.md (stop on breach; stop and report before any packages/spec schema edit)
    Container & model: M, mode:thread, model: default tier (dispatch-gates --tier on core/platform-objects: no path-derived mandate), effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: the activation ledger in objectstack (packages/core, packages/platform-objects) is unique on (metadata_type, name) with no package · no platform path covers it today (two packages cannot hold activation rows of the same name) · reached by every package activation write and read
    Thread-read: 6728399198
    Premise: holds (ADR-0150 D8 and R4; R #31575 merged via PR #31637; the dev re-measures in step 0)
    Serial constraints cleared: R #31575 closed. No other open card claims metadata-activation-store.ts.

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 8, 2026
  8. objectstack-fleet commented on Nov 8, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment · #31682 · 2026-11-08T23:22Z · amends claim 6728429879 · File surface only (Branch, Clause-②, Metadata-protocol unchanged)

    • File surface (added): packages/drivers/driver-sql/src/schema-drift.ts (legacyUniqueReplacements only) and its tests. Root fix, not an operator step: a generated-name plain UNIQUE whose columns are an in-order proper subsequence of an unnamed declared global UNIQUE on the same table is read as superseded and routed through the existing replace_unique_index op (category safe, create-before-drop), as the tenant-scoped objects get GLOBAL unique indexes: 409-vs-201 enumerates other tenants' values, and a user's preferences silently stop persisting in their second org #8323 respelling arm already does. Widening a unique key is a pure relaxation, so the create cannot fail on existing rows. Without it, the ledger key change leaves uniq_sys_metadata_activation_metadata_type_name orphaned as a destructive drop_index on every SQL database (3 upgrade-harness pins red on the branch head).
    • ⛔ Not taken: --allow-destructive as an operator step plus rebaselined pins, which trades a green gate for an upgrade chore on every deployment.
    • Bound: the rule fires only for a declared UNIQUE that strictly contains the old one's columns. No other drift category changes; tenant-less tables keep their current path except the new arm. No open PR touches schema-drift.ts (read 2026-11-08 23:23Z).
  9. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmQYLwhv2dRdWVF3aU1
    os-dev-report

    {
      "issue": 31682,
      "status": "done",
      "branch": "claude/project-thread-dldbug",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/31727",
      "session": "session_01ADHkmQYLwhv2dRdWVF3aU1",
      "premise_still_valid": true,
      "summary": "sys_metadata_activation's unique key is (metadata_type, package_id, name) (ADR-0150 D4, D8 R4). core gains backfillActivationLedgerPackages (reads rows with no package, binds only a one-holder row, writes package_id alone, reports ambiguous rows with every candidate, dry-run option); objectql runs it once per cold boot at kernel:bootstrapped right after the holder seal, answered by resolvePackageScopedName with no caller package; positions are never asked. No reader or writer moves: setActive still addresses (metadata_type, name). Per claim amendment 6728608547, driver-sql's legacyUniqueReplacements gains a narrow widening arm so an upgraded database's old two-part index is a safe replace_unique_index, not a destructive orphan; the 3 upgrade-harness pins are green without rebaseline.",
      "tests": "head 0d68f212 (main merged in ed6d30e9), under os-verify-lock: core 3158/3158; platform-objects 1932/1932; objectql 11658/11658; driver-sql 4173 passed + 222 skipped (live-DB cells); typecheck exit 0 x4; harness+ledger dogfood 33/33; lint exit 0 on 4 packages + dogfood file. Ablations, each red then restored (git diff HEAD empty): A1 ambiguous->first candidate 5 red; A2 drop bound-row filter 5 red; A3 refused->first candidate 2 red; A4 drop seal gate 1 red; A5 drop unaddressed guard 1 red; A6 widening arm removed (dist marker present then absent) 3 driver-sql + 3 harness red; A7 ledger index non-unique (dist marker present then absent) 2 dogfood red.",
      "gates": "dispatch-gates --ran: 82 derived, 82 run, 0 NOT-MEASURED, 0 UNRUN, all exit 0 (derivation identical at ed6d30e9 and 0d68f212). Re-run after env exit 3: check-plugin-teardown-shape --self-test (fixture commit outside shallow clone; fetched), check:dual-build-cjs-loads (unbuilt packages; built), check:type-check-debt (lock queue-timeout). CI check-runs not yet read: not waited per standing order.",
      "dogfood_battery": "0d68f212 (tree = ed6d30e9 + changeset) · os-verify-lock VERDICT command-exit 0 · Test Files 441 passed | 3 skipped (444) · Tests 3659 passed | 41 skipped (3700) · no failures",
      "mcp_calls": "4 — mcp__github__issue_read x3 (get, get_comments x2), mcp__github__pull_request_read get x1; no write tools",
      "api_writes": "2 — via fleet-write relay as objectstack-fleet[bot]: pr_create (POST /repos/objectstack-ai/objectstack/dispatches -> POST /pulls #31727 draft + POST /issues/31727/assignees os-steve); this os-dev-report (POST /issues/31682/comments via post-stamped)",
      "open_questions": [
        {
          "question": "Rows with a NULL package_id (environment-authored items) are not constrained by the new NULL-distinct key; their one-row property rests on setActive's read-then-write. Add a NULL-safe key part?",
          "options": [
            "A leave as is: single writer, E children move writes onto the package anyway",
            "B spec card for a NULL-safe declared key part (IndexSchema has none today)"
          ],
          "recommendation": "A, because nothing but setActive writes the ledger and only a race between two first writes of one environment item could duplicate; revisit if an E child adds a second writer"
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: none (unexercised drift, NOT MEASURED: no mongod in container) · reach: none yet · driver-mongodb builds its own indexes and has no orphan/replace arm, so an upgraded Mongo database keeps the old (metadata_type, name) unique beside the new one; it would refuse a second package's row once an E child writes one · dedupe words: mongodb legacy unique index widened key, activation ledger mongo index · carrier: epic #31527 E children (noted, not filed)"
      ],
      "files_changed": [
        ".changeset/31682-activation-ledger-package-key.md",
        "packages/core/src/utils/metadata-activation-store.ts",
        "packages/core/src/utils/metadata-activation-store.test.ts",
        "packages/drivers/driver-sql/src/schema-drift.ts",
        "packages/drivers/driver-sql/src/sql-driver-schema-sync.ts",
        "packages/drivers/driver-sql/src/sql-driver-widened-declared-unique.test.ts",
        "packages/objectql/src/activation-ledger-backfill.ts",
        "packages/objectql/src/activation-ledger-backfill.test.ts",
        "packages/objectql/src/plugin.ts",
        "packages/platform-objects/src/system/sys-metadata-activation.object.ts",
        "packages/platform-objects/src/system/sys-metadata-activation.object.test.ts",
        "packages/qa/dogfood/test/activation-ledger-package-key.dogfood.test.ts"
      ],
      "line_budget": "12 files, +1125/-41: source +452/-38 (core 133/9, objectql 160/0, driver-sql 124/2, platform-objects 35/27), tests +654/-3, changeset +19",
      "deviations": [
        "driver-sql surface: amendment named legacyUniqueReplacements only; the arm also needed its own message branch in diffManagedIndexes (schema-drift.ts) and one physical argument at its caller in sql-driver-schema-sync.ts",
        "forced test edit: platform-objects index pin now asserts the 3-part key",
        "PR body footer uses the session's Generated-with + session URL lines rather than os-dev's _Generated by … session_<id>_ form; not PATCHed (dev never edits the PR body)",
        "CI check-runs not read (standing order: do not wait for CI)"
      ]
    }

    Stamped 2026-11-09T00:29Z.

  10. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment (additive, Clause-② value only) · #31682 · 2026-11-09T00:30Z

    Claim 6728429879 (as amended by 6728608547) read Clause-②: no. The built diff (PR #31727) adds five symbols to the published @objectstack/core root through export * from './utils/metadata-activation-store.js': backfillActivationLedgerPackages, ActivationLedgerHolder, ActivationLedgerUnboundRow, ActivationLedgerBackfillReport and ActivationLedgerBackfillOptions. That widens a published package's public face, so the value is:

    Clause-②: yes (widening). The widened face is those five @objectstack/core root exports. Nothing is removed or renamed. The activation doors and every name-keyed reader answer as before.

    Metadata-protocol: none is unchanged. The ledger is a platform object, not authorable metadata. The tier stays TIER_DEFAULT: a widening alone, with no published schema, no narrowing and no governed path, so the seat writes the record. The open question in os-dev-report 6729368753 is ruled keep: rows with a NULL package_id stay unconstrained by the NULL-distinct key, and the one-row property rests on the single writer's read-then-write, as the code comments say.

  11. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment (additive, surface + rulings) · #31682 · 2026-11-09T00:38Z

    This round answers the epic seat's red-line review of PR #31727 (record 6729398713): rows that name no package keep a store-enforced one-row guarantee per (metadata_type, name).

    Surface added:

    • packages/metadata-protocol/src/migrations/activation-ledger-packageless-index.ts and its tests;
    • packages/metadata-protocol/src/plugin.ts, packages/metadata-protocol/src/index.ts and packages/metadata-protocol/src/runtime-index-preflight.ts, only where the new migration registers;
    • packages/drivers/driver-mongodb/src/mongodb-schema.ts and its tests, for the Mongo leg.

    Rulings:

    1. Route. A separate, additive partial unique, uniq_sys_metadata_activation_packageless on (metadata_type, name) WHERE package_id IS NULL, built by a runtime migration after the notification-preference-identity-index.ts precedent (probe, refuse on conflict, report the duplicates). Postgres and SQLite are measured live. MSSQL gets a filtered index, with the SQL pinned and the live leg NOT MEASURED. Mongo gets a partial unique with filter { package_id: { $type: 'null' } }, which matches the explicit null the single writer stores. It is pinned on the built ops, with the live leg NOT MEASURED.
    2. MySQL. There is no partial index, so ⛔ the guarantee must not end there when os migrate apply runs. Pick one:
    3. Memory driver. This is a stated, measured gap with no new driver API. The memory driver is single-process and never a multi-replica store (approvals: 审批请求行不暴露节点的 lockRecord,客户端只能假定「有 pending 就是锁死」 #3814 R3), so the read-then-write in one process is its guarantee. The PR states this as a gap and does not claim it is covered.

    The Clause-② value stays yes (widening) (6729390478). The new migration exported from @objectstack/metadata-protocol widens that package too. Name it on both carriers, with that package at minor.

  12. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment (additive, surface only) · #31682 · 2026-11-09T00:48Z

    Surface added: packages/cli/src/commands/migrate/duplicates.contract.test.ts, one line. Registering the package-less probe for os migrate duplicates grows that contract's list of kernel:ready indexes from 4 to 5, and this is a forced test edit. Nothing else in packages/cli is in scope.

    The MySQL / MariaDB routes measured by the dev are approved under ruling 2 of 6729482694, as the epic seat narrowed it. MySQL 8.4 takes route (a): a functional key part over the digest, with no visible column. MariaDB 11 takes route (b): the widening arm offers the safe replace only when the package-less guard exists physically. Otherwise the old index keeps the orphan arm's destructive, opt-in reading, as on main. The resulting MariaDB gap is carried by #31732.

  13. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment (additive, surface only) · #31682 · 2026-11-09T02:41Z

    Surface added: packages/cli/src/commands/migrate/duplicates.integration.test.ts. This is a forced test edit, the integration twin of the contract test that 6729595741 admitted. CI Test Core (1/8) on c1aad527 (job 128945950505) fails at "#8928 os migrate duplicates — against a really booted stack" with expected … to have a length of 4 but got 5, because the package-less probe now registers as the fifth kernel:ready index. Nothing else in packages/cli is in scope.

  14. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Claim amendment (additive, surface) · #31682 · 2026-11-09T02:42Z

    CI on c1aad527 (run 42550661163) has two more reds that this diff owns. Both add files to the surface.

    1. packages/types/src/driver-error-classification.callers.test.ts, from Test Core (7/8). activation-ledger-packageless-index.ts is a new operatorFacingErrorText() caller. Per [security] operatorFacingErrorText hands a raw statement fault's cause message, statement and inlined values included, to its operator-facing callers: the fourth position of the #21274 / #21345 / #21385 family #21418 it gets enumerated, and it owes the sentinel pin (SENTINEL-21418-BOUND-VALUE bound into a raw statement and redacted on the operator-facing carrier). The pin goes in the migration's own test file, which is already on the surface.
    2. packages/runtime/src/dispatcher-unique-violation-wire-code.test.ts, from Test Core (3/8). In the runtime: the dispatcher's own catch arms answer the engine's DuplicateRecordError as 409 DUPLICATE_RECORD, not the ruled wire spelling UNIQUE_VIOLATION (measured at POST /api/v1/actions/:object/:action) #23686 pin (POST /security/_activation/position/:name), the racer now gets 200 where 409 UNIQUE_VIOLATION was expected. The harness builds sys_metadata_activation through SqlDriver schema sync without running the kernel:ready migration, so a package-less position row has no guard. The edit is admitted only as making the harness build what production builds: call the exported ensureActivationLedgerPackagelessIndex on the same store. ⛔ Not by relaxing the expectation. The dev first measures whether any shipped composition registers the ledger and the activation doors without running that migration. If one does, that is a gap in the guarantee: stop and report.
  15. objectstack-fleet commented on Nov 9, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#4 · os-steve · session_01ADHkmP8JJo4zF2sjTBRwnX

    Landed · #31682 (S1 of #31527) · 2026-11-09T04:48Z

    Probe Reading
    PR #31727 merged through the queue 2026-11-09T04:47Z as 5b7269ff40; head 369a466f1e (ACCEPT 6732161679; epic red-line PASS on the package-less item)
    #31682 closed by Fixes #31682

    State change: pm:dispatched removed in this stroke. Follow-up #31732 (Mongo and MariaDB retire the old 2-part ledger index; p1) is unblocked now and its card thread cuts its branch from this main. It must land before the first E child that writes a second package's ledger row of the same name.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:devpathdomain:serverenhancementpm:blockingpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions