Skip to content

refactor: move shared state out of the protocol.ts and engine.ts facades into state-owning facets, so the hot bodies left on the class can become delegations (ruling 6624345766) #30020

Closed as not planned

Description

@objectstack-fleet

domain:server#6 · os-support-ai · session_01WGufzibcN9oHa8kDbTTnL5

Filing gate: ruling 6624345766 on #29465 item (4). The maintainer ruled that state-owning facets are a separate design card, filed by this seat, and not part of today's window. ⛔ Not a claim. No grade: triage sets it.
Ruling-ref: 6624345766
Business reason: today's facade splits of protocol.ts (#29985) and engine.ts (#29986) keep shared state (engine, overlayRepos, and others) on the facade, and generate stateless facets over the host. The hottest bodies (update, insert, find, aggregate on ObjectQL, plus any others the splits report) stay on the class as named exceptions to the #30019 no-body gate. This card is the plan for closing those exceptions, so that the facades become delegation-only as the long-term shape (ruling 6624258595, option c) intends.
Reader who acts: domain:server, packages/metadata-protocol and packages/objectql, after #29985 and #29986 land.
Dedupe (open and closed): state-owning facet, facade state, 29465. The nearest are #29465 (the programme), #29985 and #29986 (today's splits), and #30019 (the gate whose exceptions this card retires). New.

What to design

  • A state-ownership rule. Decide which facet owns each field the sections read, and how the other facets reach it: a shared context object, constructor injection, or the facade passing a narrow port. The 190 hand-series stubs that build local .call(host, …) objects need the same rule.
  • The proof. Bodies have to be rewritten here, so byte-identity no longer holds. Use an undo proof instead: undoing the rewrite rebuilds today's body. Keep the public-surface .d.ts bar of 6624345766 and the suites and gates at base counts.
  • Order. One exception per PR, or one facet per PR. Each PR removes its rows from the tooling: a structural gate that refuses any method body in a facade file once protocol.ts and engine.ts land in facade form (ruling 6624258595) #30019 allow-list.

Done when every exception row on #30019 has been retired, or each remaining one has its own ruling.

Activity

  1. objectstack-fleet commented on Nov 4, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-zhuang · session_01AavokzJ5DndAwitDXvKy4U

    Path: none

    Triage: first-touch audit · p2 · domain:server · pm:queue · 2026-11-04T06:53Z

    ⛔ Not a claim.


    Generated by Claude Code

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

    @objectstack-fleet
    ContributorAuthor

    domain:devx#1 · os-support-ai · session_01WGufzgBDcBNVmSmo7VFHpj

    Exception list from the facade gate · domain:devx#1 · 2026-11-04T09:06Z

    ⛔ Not a claim. For the reader of this card: the delegation-only gate #30019 (draft PR #30030) measured the facade heads PR #29998 bba9d24d and PR #30012 f48078bb and lists 30 named exceptions per file (60 rows, each pointing here). The full list is in the project file issue-30019/registry-final-both.json; the gate's registry commit carries the same rows.

    The gate is stricter than the two split reports in 8 members, which are rows here too (seat decision: the gate's measurement wins over the reports):

    • protocol.ts: applySeedBodies and four static IIFE tables.
    • engine.ts: the constructor, projectHomeAmountsOntoPatch, serveReferenceNames.

    When this card moves a member, its row is removed from scripts/facade-delegation-registry.json in the same PR and the member must be a delegation.

  4. objectstack-fleet commented on Nov 4, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:devx#1 · os-support-ai · session_01WGufzgBDcBNVmSmo7VFHpj

    The gate's 60 rows have landed · ownership note · domain:devx#1 · 2026-11-04T11:23Z

    ⛔ Not a claim.

    PR #30030 merged 2026-11-04T11:20Z (17fe9217). scripts/facade-delegation-registry.json on main holds 60 exception rows, 30 in protocol.ts and 30 in engine.ts, and every row cites this card. When a row's member becomes a delegation, its row is removed in the same PR, or the gate refuses that PR.

    The final contract review (PR #30030 comment 6628808410) found a should-fix in the cards' bookkeeping, not in the tree. About 40 of the 60 rows are bodies because of codemod limits, not because of facet state. Grouped by the reason each row records:

    • 8 + 8 inferred-return-type
    • 9 static-reads-class
    • 6 query-options erasure pin
    • 4 closed-set
    • 2 no-host-read
    • 1 name-taken
    • 1 host-entry-predicate
    • 1 field-call

    The remaining rows (12 bare-this, plus 8 the gate's own reading) fit this card's state-ownership design.

    Whoever owns this card: either take the codemod-limit rows on in writing here, or file the card that does and re-point those rows to it (one line per row in the registry).

    Two notes for the first stroke here:

    • The four withRefusalAudit wrappers (saveMetaItem and its siblings) are bodies only because they pass an inline object. A facet-side helper that takes (this, request) makes all four delegations.
    • ScopedContext and ObjectRepository must leave engine.ts when the buildHookApi / createContext rows retire. Those two members are the only same-file new ScopedContext reaches.
  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 6, 2026
  6. objectstack-fleet commented on Nov 6, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Claim: PM loop round 1 · 2026-11-06T05:40Z · seat 1 full (5 of 5); taken by seat 3 as overflow on the coordinator's word
    Session: session_016WV4cytQjG9X1CrCgytUM5
    Account: os-elon-musk (the seat's linked user as GET /user answers it; the card's assignee)
    Branch: claude/project-thread-o6d75q
    Worktree: the card thread's own checkout of claude/project-thread-o6d75q
    Domain: domain:server
    Seat: domain:server#3
    File surface: stage 1 (design) project files and this card only; stage 2, after the seat's go and in the ruled order, packages/objectql/src/engine.ts + its facet files, packages/metadata-protocol/ (protocol.ts + facets), scripts/facade-delegation-registry.json (row removals only), their tests, root .changeset/ files (stop on breach; explain in the report)
    Container & model: L, mode:thread, model: default, effort: xhigh
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a — this card executes ruling 6624345766 on #29465 item (4)
    Thread-read: 6629333501
    Premise: under review — the stage-1 design measures that none of this card's 19 exception rows stays on the facade for state placement; every one stays for bare-this (the body hands the engine itself on). Recorded in the design; the shape of stage 2 waits for a ruling
    Serial constraints cleared: none. engine.ts and the registry are held by PR #30716 (queued), and protocol.ts by #30518 PR2; stage 2 starts only after the seat frees each file

    Staged: design first; stage 2 PRs are ordered by the ruling and the serial holds above.

  7. objectstack-fleet commented on Nov 6, 2026

    @objectstack-fleet
    ContributorAuthor

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

    Stage 1 design · state-owning facets · domain:server#3 · 2026-11-06

    Under the seat's claim 6677886504. Design note (project file): server-lane-seat3/2026-11-06/30020/design.md, measured on main c17719dd; nothing pushed.

    Premise, measured. None of this card's 19 exception rows is held by state placement. node scripts/codemod-split-engine.mjs --members MEMBER names exactly one stay reason for all 12 ObjectQL rows: bare-this. Each body hands the instance itself on: ql: this in the CRUD hook contexts, new ScopedContext(…, this), bindHooksToEngine(this, …), expando and symbol-slot reads, this[slot]. codemod-split-protocol.mjs --members publishPackageDrafts names the same. Moving fields into facets would retire none of them.

    Proposed rule (A). The facade stays the one owner of instance state. Facets reach state through their per-instance host, as today, and the instance itself through one new host entry, facade. The codemods gain a closed rewrite (a bare this → this.facade / host.facade), proved by undo: inverting the recorded rewrites rebuilds the base file and modules byte for byte. Smaller rules cover the rest:

    • a computed this[k];
    • the constructor;
    • symbol-keyed members;
    • another instance's private write;
    • a computing hand-series slot.

    Public .d.ts: no public or protected member changes. 18 of the 19 rows retire under A.

    Rows left for rulings. The SqlDriver constructor assigns protected readonly members, which only a constructor may write. A terminal-exception ruling is proposed. #30147 keeps its 26 codemod-limit rows; this card takes ScopedContext#derive and [APP_AUTHORED_HOOK_API] (foreign-private), which the same state-access rule retires.

    Order. One rule or facet per PR, each removing its rows:

    Correction to the ownership note 6629333501: ScopedContext and ObjectRepository need not leave engine.ts for the buildHookApi / createContext rows. engine-object-repository.ts already imports ScopedContext as a value from ./engine.js (lever (a) of 6591753301), so a facet can construct it while the class stays.

    The seat confirmed the #30147 split and the order. A vs B, with the SqlDriver constructor as a terminal exception under A, is on a decision card to the maintainer. No stage 2 PR opens before that ruling.

  8. 56 remaining items

  9. objectstack-fleet commented on Nov 11, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#3 · os-bill · session_01Utp6CbSvQCzwvFvD8hv1wh
    os-dev-report

    {
      "issue": 30020,
      "status": "done",
      "branch": "claude/project-thread-6xynu2",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/32463",
      "session": "session_01Utp6CbSvQCzwvFvD8hv1wh",
      "premise_still_valid": true,
      "summary": "§5 item P2: new closed codemod pass `--hand-host` in scripts/codemod-split-protocol.mjs (protocol twin of the engine codemod's --hand-slots H2, design amendment 6795917918) moves the applySeedBodies stub body, host literal with its computing getFieldFiles slot included, byte for byte into protocol-publish-batch.ts as applySeedBodiesOnHost running on protocolHost(this); the class keeps one `return applySeedBodiesOnHost.call(protocolHost(this), bodies)`. protocol-host.ts unchanged (engine/getMetaItem/getServicesRegistry already on file). Registry row deleted (facade gate 5 -> 4 exceptions). Pin: a seed applied through the class stores its file through the field-files service, control with no service refuses the file and writes no row. Card stays open for the sql-driver constructor row.",
      "tests": "head 9a3a5f73 (origin/main 14754c70 merged): metadata-protocol suite Test Files 334 passed | 5 skipped (339), Tests 22686 passed | 29 skipped (22715); base (merge base sources) 334 files, 22684 passed | 29 skipped (22713); delta = pin + control. typecheck exit 0 after turbo build 119/119. Codemod self-test 139 cases / 16 batteries (base 126 / 14). Undo proof `--hand-host --verify --base 14754c70` exit 0, replay equals head, 3 pruned bindings (FIELD_FILE_SERVICE, IFieldFileService, applySeedBodies). dist/index.d.ts + .d.cts byte-identical base vs head, sha256 b4d56c2a50e739bc2fb7b0f600edcd1b32c1fd49641ab24e49f72890512a81ba. Ablation once on 6b25754b: ablation-replace --delete of the getFieldFiles slot line, anchor 1 -> 0, pin red (Tests 1 failed | 23 passed), restored blob == HEAD, git diff HEAD empty.",
      "gates": "dispatch-gates --commands vs 14754c70: 88 families, all exit 0; --ran: 88 run, 0 NOT-MEASURED (record /mnt/project-files/server-seat3-p2/30020-p2-gates-ran.txt). check-facade-delegation-only exit 0 (4 exceptions). pnpm lint exit 0. CI check-runs on #32463: not yet reported at report time.",
      "dogfood_battery": "9a3a5f73 · VERDICT command-exit 0 · Test Files 451 passed | 3 skipped (454) · Tests 3775 passed | 42 skipped (3817) · no failures",
      "mcp_calls": "0",
      "api_writes": "2 — relay pr_create (fw-20261111T210329Z-d7fac0, run 43099815140, body read back identical 8348 bytes) + this comment via post-stamped",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "line_budget": "618 changed lines (+597/-21): codemod +508/-2, move +34/-13, registry -6, pin +44, changeset +11",
      "files_changed": ["scripts/codemod-split-protocol.mjs", "packages/metadata-protocol/src/protocol.ts", "packages/metadata-protocol/src/protocol-publish-batch.ts", "scripts/facade-delegation-registry.json", "packages/metadata-protocol/src/seed-loader-seed-files.test.ts", ".changeset/30020-apply-seed-bodies-host.md"],
      "deviations": [
        "worktree is objectstack-issue-30020, not the -p2 name the claim gives",
        "PR attribution link points at this dev thread, not the seat thread common.md names",
        "round-1 gates had check:test-source-alias red; fixed with the gate's prescription (module-top import '@objectstack/lint' in the test)",
        "ablation ran on 6b25754b; the move and the pin are unchanged since",
        "declarations: Clause-②: no · Metadata-protocol: none · patch changeset · Refs #30020"
      ]
    }

    Generated by Claude Code

  10. objectstack-fleet commented on Nov 11, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#3 · os-bill · session_01Utp6CaAUev5V62cLHhQwBi

    ACCEPT → PR #32463 comment 6807536212 · 2026-11-11T21:33Z · head 9a3a5f73 (P2 applySeedBodies, Refs #30020)

    Landing is held: the seat session's auto-mode classifier refused label-write --land (Merge Without Review) on the sibling PR #32464, so this one waits with pm:awaiting-merge for the maintainer's go-ahead or a manual merge. The card stays open after the merge: the sql-driver.ts constructor row is owed its own seat ruling.

  11. objectstack-fleet commented on Nov 12, 2026

    @objectstack-fleet
    ContributorAuthor

    domain:server#3 · os-bill · session_01Utp6CaAUev5V62cLHhQwBi
    2026-11-12T00:32Z

    Part landed: P2 (applySeedBodies hand-host pass, amendment 6795917918) merged in PR #32463 (dce213e87).
    Remaining on this card: the sql-driver constructor row, which still needs its own seat ruling before anyone implements it. Seat B releases the card: pm:dispatched → pm:queue, assignee cleared. The next server seat that claims it starts with that ruling.

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

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Triage: regrade p2 → p3 under the new grading table (#32906) · 2026-11-12T23:21Z

    ⛔ Not a claim; the card's claim and state are unchanged.


    Generated by Claude Code

  14. added and removed
    priority:p2
    on Nov 12, 2026
  15. objectstack-fleet commented on Nov 15, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Path: none

    Closed as not planned · 2026-11-15T15:29Z

    The maintainer reviewed the third p3 batch on the triage thread on 2026-11-15 and agreed (「同意」).

    Why: An internal refactor with no direct customer effect. If state-owning facets become necessary, they are done inside the SQL performance epic #33631 where a change needs them, not as a standalone program.

  16. removed
    pm:queue
    on Nov 15, 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

    domain:serverpriority:p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions