Repository navigation
feat(platform-objects): built-in sys_task and sys_note objects - #36965
Conversation
Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…r sys_task / sys_note Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 74 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 18 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 188 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 5ca028e3413e3533f0eec23389006fdd6b220896 && git checkout 5ca028e3413e3533f0eec23389006fdd6b220896
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9d707686ee33648063fc5a87b20b7e6376940d9c ef4fd2f76ee26ad8b8b09ba0fea38a6812db5917 && git checkout -B drift-repro 9d707686ee33648063fc5a87b20b7e6376940d9c && git merge --no-ff ef4fd2f76ee26ad8b8b09ba0fea38a6812db5917
node scripts/docs-audit/affected-docs.mjs --json 9d707686ee33648063fc5a87b20b7e6376940d9c
|
…atform-task-note-objects
…-provided and extract their labels Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…en platform locales Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…ration, completion stamp, who reads and edits Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…_task / sys_note Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…atform-task-note-objects
…latform object registry Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…d, create, edit, no delete (ruling 7131539862, A) Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…atform-task-note-objects
… task-note test names the boot-time rule-hook issue Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…atform-task-note-objects
…ect; platform packages declare rules of their own Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…loads at module top Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
…atform-task-note-objects
…ion created after it Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: Full record on PR #36965 (card #36942), net diff against merge base The rest of the diff is the lane seat's ACCEPT at ① Derived judgments
② Semver level
S3 (should-fix) — S4 (should-fix) — the changeset body ends "Members reach both through a permission set that grants the objects: the platform's member baseline grants neither." At this head
③ Boundary flags
④ Design judgment
S2 (should-fix) — the comment says the assignee's edit lands because "the The falsifiable-premise pin. One boot after #37012, organization and members inserted after Attempt to break the permission posture (could a member read or edit another member's task or note because of this diff). Read at this head, on the composition the runtime test boots and the stock served slate:
S1 (should-fix) — security finding, routed privately.
Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — REWORK · L1 · head
|
…atform-task-note-objects
…ngeset; the task-note test's members hold org_member Claude-Session: https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ Contract reviewServed-tier: Delta record on PR #36965 (card #36942), from the reviewed head
① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ 席位核对 — ACCEPT · L1 · head
|
…ed after boot, without a restart (objectstack-ai#37012) Fixes objectstack-ai#36982 Clause-②: no Metadata-protocol: none ## 维护者速读 - 新建的组织(例如新环境的第一次注册)里,应用自带的共享规则从创建那一刻就生效,被指派人立即能看到并编辑任务,不再需要重启服务器。 - 属于平台记录共享这条线,替任务与备忘那张卡(内置任务对象的被指派人授权)解决新组织里授权缺失的问题。 - 出错时表现为新组织里某条应用自带规则没有授权(只会少给,不会多给;每个组织的授权仍只落在本组织内);这次改动可以直接撤回,撤回后回到重启才生效的旧行为。 - 无 ## What changes `SharingServicePlugin` bound its per-record rule hooks once at boot, on the objects of the rules it served then. Under a walled posture a declared rule is served once per organization that exists (ADR-0131 D2), so a kernel that booted with no organization bound no hook on a declared rule's object. The organization-created middleware (`addDeclaredRuleScope`) added the new organization's scope and bound nothing, so a record written in that organization got no `sys_record_share` grant until the next restart. It under-granted; it never over-granted. - `SharingRuleService.listRuleHookObjects()` (new): the objects the record hooks bind on — every object an active `sys_sharing_rule` row names, plus every object an active DECLARATION names, whatever organizations serve it at that moment and whatever the activation ledger says of it. The binding is per object and organization-agnostic; the organization is resolved when a record is evaluated (`evaluateAllForRecord` lists the projections live, each sweeping inside its own organization at the driver), so isolation is unchanged. - `rule-hooks.ts`: new `rebindRuleHooks(engine, service, logger)` reads `listRuleHookObjects()`, then unbinds and calls `bindRuleHooks` with that object set; the read runs before the unbind, so a failed read keeps the previous bindings (as before). `bindRuleHooks`' `rules` parameter widens to the two fields it reads (`object_name`, `active`), a non-breaking widening; its hook bodies are unchanged and stay in that symbol (the system-context census row keys the `afterDelete` elevation read to it). - `sharing-plugin.ts`: boot and the `sys_sharing_rule` data-change rebind both go through one private `bindRuleHooks` method (the binding site ADR-0057 anchors as `sharing-plugin.ts#bindRuleHooks`), which calls `rebindRuleHooks`, so the two cannot derive different object sets. The organization-created middleware is unchanged: it still adds the scope, and the hooks already bound now serve it. - Same derivation closes the sibling shape: a declared rule switched off in the activation ledger at boot and on later keeps its object bound (the ledger reconcile never rebinds). Why per object rather than a rebind in the organization-created middleware: a rebind there would re-derive the hook set from the served projections each time, which is exactly the snapshot that drifted (and an unknown-scope boot, or a ledger switch, would still bind nothing). Binding from the declaration cannot drift with the organizations at all. A hook on an object no projection serves yet evaluates no rule and grants nothing. ## Tests - `packages/plugins/plugin-sharing/src/declared-rule-late-organization.test.ts` (new, real stack, ONE boot): `ObjectKernel` + `ObjectQLPlugin` over better-sqlite3 + `SharingServicePlugin`, `isolated` posture (the `tenancy` service plus the engine posture accessor the security plugin hands it), a package-declared `field` rule (`assignee_id`, edit) on a private object; every organization is inserted after `bootstrap()`. - Case 1: in the first organization created after boot, a task's assignee gets exactly one edit grant from the declared rule and reads the record; a member the rule does not name still reads nothing. RED on origin/main `57445a69981` (`expected [] to deeply equal [ ObjectContaining ]`), green with the fix. - Case 2 (isolation, both directions): organization A authors its own rule on the same object; control — it grants on A's record; B's record matching A's criteria gets exactly one grant, B's projection of the declared rule, stamped `organization_id` B; A's watcher does not read it. Green on origin/main and with the fix. - `sharing-rule.test.ts` (walled describe): `listRuleHookObjects()` names the declared rule's object with no scope, with unknown scopes, and with the rule switched off in the ledger (while `listRules` serves nothing in each); a stored row's object joins; an inactive declaration binds nothing. - `rule-rebind.test.ts`: mocks moved from `listRules` to `listRuleHookObjects`, the rebind seam's new read; assertions unchanged. - Ablation at head `e67a0507ced` (fix committed first; `scripts/ablation-replace.mjs`, anchor x1 to x0, blob `6558c83dc6c3` to `d440ba76857c`): the declaration loop in `listRuleHookObjects` removed, so only served projections bind. Over the three touched suites: `Tests 2 failed | 160 passed` — exactly the two new pins (the one-boot late-organization case and the `listRuleHookObjects` pin). Restored: blob `6558c83dc6c3` equals the HEAD blob, `git diff HEAD` empty. No dist rebuild needed: the suites import the subject from `src`. - At head `e67a0507ced`: `pnpm --filter @objectstack/plugin-sharing test` — Test Files 78 passed, Tests 1629 passed, 11 skipped; `pnpm --filter @objectstack/plugin-sharing typecheck` — exit 0, `check:test-typecheck: OK` (the new test is in the `tsconfig.test.json` program, `--listFilesOnly` 1 hit). <details><summary>Derived gates at e67a050</summary> `node scripts/pm/dispatch-gates.mjs --commands` (7 paths vs merge base `57445a699`): 73 families, all run after a full `pnpm build` (120 tasks, lock VERDICT command-exit 0), each exit captured before any pipe: 73 exit 0. `--ran`: 73 derived, 73 run, 0 NOT-MEASURED, 0 UNRUN (exit 0). On the first pass two families were red and are green now: `check:adr-symbol-anchors` (ADR-0057 anchors the plugin's binding site as `sharing-plugin.ts#bindRuleHooks`; kept as the private method) and `check:system-context-census` (row 31 keys the rule hooks' `afterDelete` elevation read to `bindRuleHooks`; the hook bodies stay in that symbol). `test:repo` is CI's (Test Core). </details> ## Acceptance notes - PR objectstack-ai#36965's runtime test boots twice because of this defect. With this fix on `main`, one boot should do: the declared `sys_task_assignee` object is bound at boot from the declaration, and the organization inserted afterwards is served by those hooks. Not measured here (that test lives in plugin-security on objectstack-ai#36965's branch, outside this card's surface); left to objectstack-ai#36942's follow-up. - A composition with `SharingServicePlugin` but no engine posture accessor (no security plugin) reads its sharing posture as walled while the engine applies no tenant scope, so an organization-authored rule's per-record pass matches records of other organizations there. Seen while building this fixture; the fixture now sets the posture as a deployment does. No tenant wall exists in that composition either, so nothing crosses one; noted, not filed. ## Verification Read first: `packages/plugins/plugin-sharing/src/sharing-rule-service.ts` (`listRuleHookObjects`, the derivation), `packages/plugins/plugin-sharing/src/rule-hooks.ts` (`rebindRuleHooks`), `packages/plugins/plugin-sharing/src/sharing-plugin.ts` (the private `bindRuleHooks` and its two callers). Two minutes: `pnpm --filter @objectstack/plugin-sharing exec vitest run src/declared-rule-late-organization.test.ts` — expect 2 passed; on `origin/main` the first case fails with no grant row. --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #36942
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
packages/platform-objects/src/work/(new):sys_taskandsys_note, ordinary customizable objects (noisSystem, attachments on, comment feed left on).sys_task:title(required),description(rich text),status(todo/in_progress/done, defaulttodo),due_at,assignee_id(user, defaultcurrent_user),completed_at(read-only), and a declaredowner_id.sys_note: optionaltitle, rich-textbody, a read-onlyheading(the title, or the body's first line when the title is empty) that is the object'snameField, and a declaredowner_id.assigned_to_me(assignee is me, status not done, by due time),created_by_me,all(kanban by status); notesmine,all.sharingModel: 'private'over the declaredowner_id(asys_*object never gets the injected one; the security plugin stamps it with the creator), plus one declared sharing rulesys_task_assignee(the existing record-relativefieldrecipient namingassignee_id, accessedit). Nothing links to, grants or derives access from another record.completed_atandheadingare kept by before-write hooks (work/hooks.ts). They assign the platform value over the writer's, because the engine's create-side read-only strip leaves asys_*object to its own guards.PlatformObjectsPluginregisters both objects and the sharing rule on a manifest of their own (com.objectstack.platform-objects.work, project database) and installs the hooks instart(). A refused registration is logged atwarn.member_default(packages/plugins/plugin-security/src/objects/default-permission-sets.ts) grantssys_taskandsys_noteread, create and edit, no delete, in thesys_commentshape, per maintainer ruling 7131539862 (option A, verbatim 「1. 平台内置任务、备忘对象(第一步:不挂关联) #36942 任务/备忘默认权限: A。」). It opens the objects; no row policy is added. The rider (a per-object update alternative forsys_task) is not added: measured below, theowner_only_writesfloor does not refuse the assignee's edit.packages/spec/src/system/constants/platform-object-names.ts:sys_noteandsys_taskjoinPLATFORM_OBJECTS_BY_PACKAGE['platform-objects'].packages/platform-objects/scripts/i18n-extract.config.tsimports both objects; the bundles are regenerated bynode scripts/check-i18n-bundles.mjs --writeand the ten translated locales hand-written (zh-CN 任务 / 备忘, zh-Hant 任務 / 備忘, ja-JP タスク / メモ, ko 작업 / 메모, es-ES Tarea / Nota, fr Tâche / Note, de Aufgabe / Notiz, pt-BR Tarefa / Nota, ru Задача / Заметка, ar مهمة / ملاحظة), all 33 leaves per locale. Five leaves equal the English word and stay source-hashed as such: de and pt-BRStatus, frDescription,Note,Notes.packages/cli/src/utils/organization-ownership-inventory.ts: ADR-0131 D10 fate rows forsys_taskandsys_note, besidesys_unit: fateattribution, censusPMAIN, no anchors (members write them, the organization column is stamped from the writing context, and no parent row anchors a task or a note). Without them everyos migrate organization-ownership/os devceremony refused with "sys_note carries organization_id but the ADR-0131 D10 inventory gives it no fate".packages/cli/src/commands/migrate/organization-ownership.declared-rule-mirrors.integration.test.ts: itsservedRuleshelper lists the rules served on the fixture's object (listRules({ object: 'crm_deal' }, …)), because platform packages declare sharing rules of their own that every boot serves (sys_task_assignee). Every rule the fixture declares or inserts is oncrm_deal, so bothtoEqualassertions still count each of them exactly; nothing is loosened. The edit put the file undercheck:test-source-alias's source-reach half, so it now also pays its two dynamic workspace loads (@objectstack/platform-objects/system,@objectstack/driver-sql) at module top, as that gate prescribes.scripts/platform-object-tenancy-census.jsonregenerated by its generator: registered 108 → 110, in reach 57 → 59 (bothorganization_id), out of reach unchanged at 51.@objectstack/platform-objects(the objects),@objectstack/spec(the registry names),@objectstack/plugin-security(themember_defaultgrant) and@objectstack/cli(the two inventory fate rows).Clause-②: yes (widening):defineStacknow accepts a top-level action whoseobjectNameissys_taskorsys_note, and the public surface grows; nothing narrows.Metadata-protocol: none, on thesys_unitroster-addition precedent: no metadata key, type or schema value is added, and a reference that already parsed now resolves.Tests
packages/plugins/plugin-security/src/task-note-objects-36942.test.ts(new, 6 cases, real runtime, one boot, the organization created afterbootstrap():ObjectKernel+ObjectQLPluginover in-memory better-sqlite3,PlatformObjectsPlugin,SecurityPluginwith the platform sets only,SharingServicePlugin; members holdmember_defaultand nothing else, with the positions an ordinary member holds:user,org_member,everyone):PlatformObjectsPluginwith no application declaring either;member_defaultcarries exactly read, create and edit, no delete and no widening bit, on both;completed_atthrough the engine's write path, and leaving done clears it;landed,completed_atwritten,updated_bythe assignee); the third member's edit answersRECORD_NOT_FOUND/ 404 and the row is unchanged.packages/platform-objects/src/work/work-objects.test.ts(23 cases): declarations, sharing, views, the completion stamp and the note heading as units, plugin registration and its loud refusal.packages/lint/src/validate-object-references.test.ts: the item-6 pin, an app that declares neither object puts both in its navigation withrequiresObjectbesideobjectName;defineStackaccepts it andvalidateObjectReferencesreports nothing.packages/platform-objects/src/apps/translations/bundle-ownership.test.ts: the bundle owns both objects, and the duplicate-label walk covers them in every locale.Acceptance notes
The ruling's premise holds with the grant in place. A second member holding the same baseline reads neither another member's task nor note, by id or by list (the runtime test above). Ablation of the two
member_defaultlines: 5 of the 6 cases go red (the creator's insert is refused without an object grant), and the file restores byte-identical to HEAD.Assignee edit under the ownership floor: allowed, measured with the floor in force. The runtime test's members carry the positions the auth layer gives an ordinary member (
user,org_member, theeveryoneanchor), andowner_only_writesis bound toorg_member. A one-off probe on this composition (not committed) read the update-row filtermember_defaultgives the assignee onsys_task:nullwith no positions,{"created_by":"usr_tn_assignee"}with the member's positions, so the floor applies. Under it, the assignee'supdateof a task another member created still goes through (landed,completed_atwritten), because thesys_task_assigneerule'seditshare replaces the floor as the floor's deferral to the sharing verdict says. The third member's edit is refused withRECORD_NOT_FOUND/ 404 and the row is unchanged. So the rider's per-object alternative is not added.Navigation entries need
requiresObject.defineStackrefuses{ type: 'object', objectName: 'sys_task' }in an app that does not declaresys_task, and accepts it withrequiresObject: 'sys_task'beside it (seat decision Q3 = A: the contract stays). The starter app (#36944) spells the gate.Found on the way, filed as #36982 and fixed there (#37012, merged into this branch): a declared sharing rule wrote no per-record grants in an organization created after boot until the next boot. The runtime test now runs on ONE boot with the organization inserted after
bootstrap(), as a fresh environment's first sign-up does, and thesys_task_assigneegrant is still written: the assignee reads and edits the task, and the second member still reads neither the task nor the note, by id or by list.Also noted, not changed:
sys_*objects get no recycle bin (ADR-0148), are not AI-readable unless they opt in withaiReadable, and are skipped by the user-deactivation "assigned work" census. The app-facing platform catalog for project authors (skills/objectstack-project/references/platform-catalog.md, built from a hand-kept subset) does not list either object yet; that is follow-up #37058.Verification
Read first:
packages/plugins/plugin-security/src/objects/default-permission-sets.ts: the twomember_defaultlines and their ruling comment, besidesys_comment.packages/platform-objects/src/work/hooks.ts›stampTaskCompletion: the insert branch assigns over the client value; the update branch acts only whenstatusis in the write.packages/platform-objects/src/work/sharing-rules.ts: the assignee rule (fieldrecipient,edit).Two minutes:
pnpm --filter @objectstack/plugin-security exec vitest run src/task-note-objects-36942.test.ts→ 6 passed.Local readings
Head
ab1bfc643c0unless a line names another. That head merges origin/main (719ef290776).pnpm --filter @objectstack/plugin-security exec vitest run src/task-note-objects-36942.test.ts: the members holduser,org_memberandeveryone; one boot, the organization inserted afterbootstrap(). Test Files 1 passed, Tests 6 passed.member_defaultgives the assignee onsys_taskisnullwith no positions and{"created_by":"usr_tn_assignee"}with the member's positions. Under that filter the assignee's update islandedand the third member's update is refusedRECORD_NOT_FOUND/ 404.member_defaultlines (headf55bc30d727): 5 failed, 1 passed; the restored blob equals HEAD.vitest run --project integration src/commands/migrate/organization-ownership.declared-rule-mirrors.integration.test.ts(head39ff0ba2a26): 2 passed. Neighbours (heada34239ba506): the platform-global column drop, theos devceremony and the sqlite-wasm integration files: Test Files 3 passed, Tests 15 passed. The inventory unit test: 26 passed.pnpm --filter @objectstack/plugin-security test(headf55bc30d727): Test Files 289 passed, Tests 7296 passed, 45 skipped.pnpm --filter @objectstack/platform-objects test: Test Files 126 passed, Tests 2161 passed.pnpm buildon this head: exit 0.node scripts/pm/dispatch-gates.mjs --commands: 106 families, all run with exit codes captured before any pipe, and all 106 exit 0.--ranwith the codes: 106 derived, 106 run, 0 NOT-MEASURED, 0 UNRUN. The derivation warned that the tree is 2 commits behind origin/main, and that 2 derivation files changed across that range; this round makes one push only, so I did not merge again.Generated by Claude Code