Repository navigation
Description
Summary
SeedLoaderService orders datasets by buildDependencyGraph + topologicalSort (@objectstack/metadata-protocol 18.4.0, dist/chunk-SEQUEZLL.js ~L771 and ~L2124). An edge exists only when an object has a lookup / master_detail / user field pointing at another seeded object. Authored dataset order only breaks ties between datasets that are ready at the same moment (Kahn queue). A dataset whose lifecycle hook reads another seeded object at insert time has no way to say so: there is no dependsOn (or similar) on Seed, and the loader does not honour the authored order once lookup edges have reordered things.
Hooks do run over seed writes (isSystem, skipTriggers and seedReplay suppress automation and guards, not lifecycle hooks). So a hook-derived value on the seeded row is computed against whatever the dependency happens to hold at that moment. The result depends on unrelated datasets in the same load.
Concrete case (steedos-labs/os-project-blackcat-crm)
crm_rating_rule←crm_rating_item(master_detail) ←crm_rating_band(master_detail). Bands land in the third wave.crm_customer_ratinghas lookups tocrm_rating_ruleandcrm_accountonly. It lands in the second wave.- Its
beforeInserthook (customer_rating_compute) scores the rating fromcrm_rating_bandrows. With no bands present, every band-scored item scores 0. Every demo customer then falls tograde_dinstead of its workbook grade (e.g. 72.4 → 27.4, 95 → 45). - This only worked before because unrelated sample datasets made
crm_accountdepend on objects that were themselves late, which pushed ratings behind bands. Removing those unrelated sample datasets (steedos-labs/os-project-blackcat-crm#141) silently flips the order and breaks the demo book on every fresh install. The authored order (ratingBandslisted before the demo ratings in the stack'sdata) is ignored.
Expected
An app can make a seeded row land after the rows its hook reads, without inventing a lookup field that exists only to order seeds. Either of:
- a declared dependency on the dataset, e.g.
defineSeed(CustomerRating, { dependsOn: ['crm_rating_band'], … }), merged into the graph as edges; or - the authored order of
data[]is treated as an edge (each dataset after the ones listed before it) whenever no lookup edge contradicts it, rather than only as a tie-breaker inside one Kahn wave.
Option 1 is explicit and keeps the topological sort as the source of truth. Option 2 matches what authors read in their own data[].
Not wanted (workarounds an app should not need)
- Adding a meaningless
lookupfromcrm_customer_ratingtocrm_rating_bandpurely to create an edge. - Teaching the business hook to skip its computation on system writes, or seeding derived
total_score/gradevalues.
Repro sketch
Two seeded objects A and B with no lookup between them, plus an object C with a lookup to A. B's beforeInsert hook reads C. Author data: [A, C, B]. Since B has no edge to C, B lands in the first wave with A, before C; reordering data[] cannot fix it.
Activity
objectstack-fleet commentedon Nov 15, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
Path: none
Triage: first touch →
domain:server·lease:A4· p2 · 2026-11-15T11:48Z⛔ Not a claim.
The seed loader orders datasets by lookup edges only, so a seed whose hook reads another seeded object cannot be ordered after it, and that hook computes nothing for the seeded rows. p2. Honour an authored dependency or declared order, or explain the refusal. A4 (seed).
objectstack-fleet commentedon Nov 15, 2026
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
Maintainer ruling, recorded by area S2.
The maintainer tapped the decision card at 2026-11-15T21:54Z. 「裁定种子数据集的先后加载顺序由作者如何声明」 → 「新增 dependsOn 显式声明」.
What it binds (with the review edits E1 and E2):
dependsOn. It names objects, not datasets, because the load graph's node is the object (orderDatasetskeys ona.object). Each name adds an edge to the same graph the lookup fields feed.packages/spec/liveness/seed.json) and runtime proof (ADR-0054).Clause-②: yes (widening),Metadata-protocol: added, L2 contract review.dependsOnkeeps today's order exactly.The card is claimable.
objectstack-fleet commentedon Nov 16, 2026
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
Claim: PM loop (area S2, #33751 §2; maintainer ruling 「新增 dependsOn 显式声明」 recorded on this card; seat 21:54Z "the card is claimable now")
Session:
session_01QsR2jUg7BKfRBcTPyMxbLhAccount:
zhuangjianguoBranch:
claude/area-A4-33812Worktree:
/home/claude/wt/area-A4-33812Domain:
domain:serverSeat:
domain:server#5File surface:
packages/spec/src/data/seed.zod.ts(the newdependsOnkey) and its generated JSON schema, baselines and reference page ·packages/spec/liveness/seed.json·packages/metadata-protocol/src/seed-loader.ts(buildDependencyGraph,topologicalSortcycle refusal,orderDatasets) and the seed-loader zod/contract types it reads · authoring docs undercontent/docs/**that teach seeds · new test files named for this card ·.changeset/**(stop on breach; explain in the report)Container & model:
M,mode:subagent,model: TIER_DEFAULT,effort: highClause-②: yes (widening)
Metadata-protocol: added
Responsibility: objectstack (seed loader): a seeded dataset whose lifecycle hook reads another seeded object cannot be ordered after it · every app whose seed hook derives values from other seed data (blackcat-crm
crm_customer_rating←crm_rating_band)Premise: holds per card and Fable review E1–E3 (fable-review-batch-1115c.md); the dev re-measures it red-first
Serial constraints cleared: no open PR touches seed-loader.ts, seed.zod.ts or liveness/seed.json (file lists read at claim time); the dev runs git merge-tree before push
Pre-claim lane: domain:server (metadata-protocol seed loader) with a spec key; L2 contract review owed (new spec key)
Pre-claim deps: none
Prior rulings read: maintainer 21:54Z ruling and edits E1/E2 (
dependsOnnames objects; a declared edge that closes a cycle, or a name that is not a seeded object in the same load, refuses the load; ADR-0049, ADR-0054 liveness + runtime proof); ADR-0028 L218 (package load order, not this)objectstack-fleet commentedon Nov 16, 2026
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
os-dev-report
Report for PR #34276, posted 2026-11-16T03:30Z.
{ "issue": 33812, "status": "done", "branch": "claude/area-A4-33812", "pr": "https://github.com/objectstack-ai/objectstack/pull/34276", "session": "session_01QsR2jUg7BKfRBcTPyMxbLh", "premise_still_valid": true, "summary": "Added the authorable key Seed.dependsOn (object names, machine-name pattern, optional, no default) in packages/spec/src/data/seed.zod.ts. defineSeed refuses a dataset that names its own object. SeedLoaderService turns each name into an edge in the graph the lookup fields feed (buildDependencyGraph gains an optional declared map; the ISeedLoaderService contract signature is unchanged). Declarations are pooled per object. Objects left over behind a lookup cycle are appended in an order that keeps the declared edges, and with none declared the old order holds byte for byte. A load is refused, with nothing written, when a name is the dataset's own object, when no dataset of the load seeds the name (the message says when env or locale scoped it out), or when a declared edge closes a cycle (rule: the edge's target already depends on its declarer through any chain, lookup or declared). A cycle of lookup edges alone still uses deferred passes. The refusal is RETURNED as success:false with one errors[] entry per declaration (field 'dependsOn', recordIndex 0, targetField '(dataset)'), not thrown. A throw would send the single-tenant boot seed into AppPlugin's basic-insert fallback (packages/runtime/src/app-plugin.ts), which writes every row in authored order. Also done: the liveness row in packages/spec/liveness/seed.json (live; the runtime proof is named in the note), a docs section in content/docs/data-modeling/seed-data.mdx (which also stops claiming that array order is load order), regenerated reference pages, authorable-surface/data.json and liveness counts, a changeset (spec minor, metadata-protocol minor), and a dogfood runtime proof. Hypotheses: H1 held (base loader: rating at insert index 2, bands at 3, hook saw 0). H2 held. H3 held, with the rule above. H4: load time plus defineSeed at call time, because the 'same load' set exists only at load (env/locale filtering, multi-package replay, single-item draft publish). H5: Metadata-protocol added means minor on both moved published packages. SURFACE NOTES, three files outside the listed surface that the gates or the tests demanded. (1) scripts/engine-double-contract.pinned.json: 3 rows written by check-engine-double-contract --write for the new test's engine double, a mechanical ledger write the gate required. (2) packages/qa/dogfood/test/seed-depends-on-33812.dogfood.test.ts: a new test file named for this card, the ADR-0054 runtime proof. (3) The generated reference pages content/docs/references/api/package-api.mdx and kernel/manifest.mdx, regenerated by check:generated --fix because they embed SeedSchema. NOT touched: packages/spec/scripts/liveness/proof-registry.mts. So the ledger row carries no 'proof' field, and the open question below covers it.", "tests": "Final head 4575480d4e. Red first: with the base loader blob (aab8b3188a) swapped in, seed-loader-depends-on-33812.test.ts gave 'Tests 9 failed | 3 passed (12)'. The card case failed with 'expected 3 to be less than 2'; the 3 greens were the controls. The blob was restored to HEAD eb0ca78055f4 and the hash checked. Green: pnpm --filter @objectstack/metadata-protocol test 'Test Files 345 passed | 9 skipped (354)', 'Tests 22958 passed | 45 skipped'; typecheck exit 0. pnpm --filter @objectstack/spec test 'Test Files 845 passed (845)', 'Tests 27011 passed | 1 todo'; typecheck exit 0. Dogfood seed-depends-on-33812.dogfood.test.ts 3/3 on the final head. At 0d4aeb9798 it also passed with seed-external-id-refusal, showcase-verify-seed and meta-types-create-seed: 4 files, 15/15. Ablations, all via scripts/ablation-replace.mjs, each restored to the HEAD blob with git diff HEAD empty. Edges not joined: 4 red. The same at dist for the dogfood file (ablation-dist-preflight marker present, then --absent after restore and rebuild, tree clean): the card case red with 'expected +0 to be 2', the control green. Cycle refusal removed: 2 red. Unknown-name refusal removed: 3 red. Leftover ordering removed: 1 red. Own-object guard removed: stays GREEN, still refused as a one-object cycle (redundant guard, noted). defineSeed refusal removed: 1 red. Not run locally, declared to CI: spec test:repo, the full dogfood battery (no '!' and no narrowing arm), and the runtime and cloud-connection suites (the callers of the loader).", "gates": "Local: dispatch-gates --commands derived 116 at 94efc9de85, plus 7 more once the ledger commit landed. dispatch-gates --ran: '123 derived famil(ies) accounted for — 122 run, 1 NOT-MEASURED'. NOT MEASURED: check:dual-build-cjs-loads, reason: exit 3, it needs every package's dist from a full workspace build. check:engine-double-contract was exit 1 on the first pass (the new double was unledgered); after --write and a commit it reran on 4575480d4e with exit 0, 'OK — 1327 pinned'. check:generated was stale on check:docs and check:liveness; --fix regenerated both and they re-checked green. check:type-check-debt exit 0 (600s, under the lock). check:nul-bytes exit 0. Every other derived family exit 0, with exit codes captured to log files before any pipe. git merge-tree --write-tree HEAD origin/main exit 0, with origin/main 9 commits ahead and no overlap. CI on PR #34276 at 4575480d4e when this report was written: in_progress (Build Core, Lint and Type Check lanes running; Dogfood Regression Gate queued).", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm; the new dogfood proof file was run on its own (3/3 at 4575480d4e)", "mcp_calls": "0", "api_writes": "2 — fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls, draft, read back 12033 bytes identical); post-stamped report comment (POST /repos/objectstack-ai/objectstack/issues/33812/comments)", "open_questions": [ { "question": "A draft publish loads only the published bodies, so a published seed whose dependsOn names an object seeded by another, already-landed item is refused until both are published together. Keep that, or judge a publish against rows already present?", "options": [ "A keep the ruling's literal 'seeded in the same load' (built; docs and changeset say it)", "B on the draft-publish path, accept a name whose object already holds rows and refuse only names with no object or no rows (a semantic widening, needs a ruling)" ], "recommendation": "A, because it is what the maintainer ruled. B changes what 'same load' means and should only be adopted on a measured runtime-authored seed that needs it." }, { "question": "Register the dogfood file as an ADR-0054 proof (a @proof tag plus a proof-registry.mts entry), so the ledger row can carry 'proof'?", "options": [ "A leave as built: the runtime proof is named in the ledger note (seed ordering is not an ADR-0054 §2a high-risk class)", "B a follow-up adds a registry class and the tag (packages/spec/scripts/liveness/proof-registry.mts, outside this card's surface)" ], "recommendation": "A, because the registry lists the high-risk classes and seed order is not one of them. B only if the seat reads the card as a regression carrier under ADR-0054 §2b." } ], "security_findings": "none", "out_of_scope_findings": [ "carrier: seat (domain:server#5) · Skills-docs follow-up owed: skills/objectstack-data/references/seeds.md teaches array order as the seed order and does not teach dependsOn (governed skills/** surface, not in this diff) · noted, not filed" ] }objectstack-fleet commentedon Nov 16, 2026
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
Area S2 rules on the two open questions in report 6906493106. Both get option A, the report's recommendation.
dependsOnnames an object seeded only by an item already landed stays refused until both are published together. This is the maintainer ruling read literally ("a name that is not a seeded object in the same load refuses the load"). Option B would widen what "same load" means. It needs its own ruling, and only on a measured runtime-authored seed that needs it. The docs and changeset already say A.proof-registry.mtslists, and this card is not a §2b regression carrier. So the liveness row carries noprooffield, and the dogfood fileseed-depends-on-33812.dogfood.test.tsis named in its note.Out of scope: the
skills/objectstack-data/references/seeds.mdfollow-up named on the PR'sSkills-docs:line is #34277 (skills lane, after #34276 lands).objectstack-fleet commentedon Nov 16, 2026
domain:server#5 · zhuangjianguo · session_01QsR2jUg7BKfRBcTPyMxbLh
PR #34276 (
Fixes #33812) merged on 2026-11-16 at 09:02Z asd10f652f18.Seed.dependsOn: declared load-order edges; a refused load writes nothingskills/objectstack-data/references/seeds.mdstill teaches array orderrejectedfield comments say rows only)Lease A4 released. (The hand-off note on the PR crossed with the merge; it is superseded.)