Skip to content

feat(security)!: reconcile SharingRule authoring with the enforced runtime — group→team, +business_unit, prune guest + owner-type (#1878) - #3557

Merged
os-zhuang merged 1 commit into
mainfrom
feat/sharing-rule-recipient-reconcile
Jul 27, 2026
Merged

feat(security)!: reconcile SharingRule authoring with the enforced runtime — group→team, +business_unit, prune guest + owner-type (#1878)#3557
os-zhuang merged 1 commit into
mainfrom
feat/sharing-rule-recipient-reconcile

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes the SharingRule loose end from the 2026-07 security-props recheck (#3503, umbrella #1878). Decision per owner directive: the system has team, not group; the rest judged against mainstream platforms, long-term surface honesty, and AI-authoring safety (ADR-0078).

Problem

The authoring ShareRecipientType enum drifted behind both the ADR-0090 D3 rename and the enforced runtime. expandRecipient already expands team (sys_team/sys_team_member via TeamGraphService) and business_unit (BusinessUnitGraphService) — but the authoring enum still offered the pre-rename group (silently skipped at seed time with a warn) and omitted both live recipients. guest had no runtime mapping at all, and owner-type rules (type: 'owner', ownedBy) validated and were then skipped wholesale. The spec's own JSDoc claimed team/business_unit support the enum didn't deliver.

What changed

Authoring surfaceBeforeAfter
groupparsed, silently skippedrenamed → team, wired to the live TeamGraphService expansion
business_unitnot authorable (runtime enforced it)added — one unit's members, no subtree
guestparsed, silently skippedremoved — anonymous access is the public-form grant / share-link surface
type: 'owner' (ownedBy)parsed, skipped wholesaleremoved — returns if membership-reactive re-materialisation is designed
queuenever authorableunchanged — runtime-reserved (no sys_queue yet)

Net invariant: every authorable recipient and rule type now enforces — nothing on this surface validates and then silently does nothing.

  • spec: enum surgery; OwnerSharingRuleSchema + type export deleted; SharingRuleSchema = the criteria form (SharingRuleType = ['criteria'], union slot documented for future enforced types); JSDoc rewritten.
  • plugin-sharing bootstrap: team mapped; retired shapes kept as defensive skips (stale pre-built packages) — never seeded as match-all (ADR-0049).
  • examples: both never-enforced owner rules migrated to enforced criteria rules (share_open_tasks_with_manager, share_active_leads_with_manager).
  • dogfood: the "owner rule honestly skipped" test flips to "criteria replacement seeds + enforces" — proven on a real boot: ruleCount 4→5, showcase_task now hook-bound, criteria_json compiles to exactly {done: false}. authz-conformance sharing-rules row updated.
  • docs: recipient table now all-enforced + a retired-shapes note; references regenerated; manifest key dropped; api-surface −2 exports.

Verification

  • spec 6882 + plugin-sharing 101 + crm 20 + showcase 58 + dogfood 17 tests green (incl. a real kernel boot seeding the migrated rules).
  • spec / downstream-contract / all-examples tsc --noEmit clean (the frozen third-party consumer uses none of the removed exports).
  • check:docs / check:api-surface / check:skill-refs / check:skill-examples in sync; skills contain no retired shapes.

Breaking → ships as minor per the launch-window breaking-as-minor policy; the changeset carries the FROM→TO migration (stale definitions fail parse with the valid options listed — loud at authoring time, exactly the ADR-0078 posture).

Refs #1878, #2077, #1887.

🤖 Generated with Claude Code

…ntime — group→team, +business_unit, prune guest + owner-type (#1878)
The authoring ShareRecipientType enum drifted behind the ADR-0090 D3 rename
and the enforced runtime: expandRecipient already expands `team` (sys_team /
sys_team_member via TeamGraphService) and `business_unit`, but the enum still
offered the pre-rename `group` (silently skipped at seed time with a warn)
and omitted both live recipients. Owner-type rules validated but were skipped
wholesale (live-membership-dependent). After this change every authorable
recipient and rule type is enforced — nothing on the SharingRule surface
validates and then silently does nothing (ADR-0078).
- spec: rename group→team, add business_unit, drop guest; delete
OwnerSharingRuleSchema + OwnerSharingRule (SharingRuleSchema = the criteria
form; SharingRuleType = ['criteria']); JSDoc rewritten; explain.zod comment.
- plugin-sharing bootstrap: map team→TeamGraphService expansion; retired
shapes kept as defensive skips (stale pre-built packages), never match-all.
- examples: migrate both never-enforced owner rules to enforced criteria
rules (showcase share_open_tasks_with_manager: done==false → manager;
crm share_active_leads_with_manager: status not converted/disqualified →
sales_manager); crm smoke test asserts criteria-only.
- dogfood: rbac-seeding test flips from "owner rule honestly skipped" to
"criteria replacement seeds + enforces" (criteria_json {done:false},
recipient position/manager — proven on a real boot: ruleCount 4→5,
showcase_task now hook-bound); authz-conformance sharing-rules row updated.
- docs: permissions/sharing-rules.mdx recipient table (all enforced) +
retired-shapes note; references regen; manifest key security/OwnerSharingRule
dropped; api-surface −2 exports.
Verified: spec 6882 + plugin-sharing 101 + crm 20 + showcase 58 + dogfood 17
tests green; spec/downstream-contract/examples tsc clean; check:docs /
api-surface / skill-refs / skill-examples in sync. Ships minor per the
launch-window breaking-as-minor policy; changeset carries the FROM→TO
migration.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercelBot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
objectstackIgnoredIgnoredJul 27, 2026 4:33am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/l labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/plugin-sharing, packages/qa, @objectstack/spec.

105 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/ai/agents.mdx(via @objectstack/spec)
  • content/docs/ai/skills-reference.mdx(via @objectstack/spec)
  • content/docs/ai/skills.mdx(via @objectstack/spec)
  • content/docs/api/client-sdk.mdx(via @objectstack/spec)
  • content/docs/api/environment-routing.mdx(via @objectstack/spec)
  • content/docs/api/error-catalog.mdx(via @objectstack/spec)
  • content/docs/api/error-handling-client.mdx(via @objectstack/spec)
  • content/docs/api/error-handling-server.mdx(via @objectstack/spec)
  • content/docs/api/index.mdx(via @objectstack/spec)
  • content/docs/automation/approvals.mdx(via packages/spec)
  • content/docs/automation/flows.mdx(via @objectstack/spec)
  • content/docs/automation/hook-bodies.mdx(via packages/spec)
  • content/docs/automation/hooks.mdx(via @objectstack/spec)
  • content/docs/automation/index.mdx(via @objectstack/spec)
  • content/docs/automation/webhooks.mdx(via @objectstack/spec)
  • content/docs/automation/workflows.mdx(via @objectstack/spec)
  • content/docs/concepts/architecture.mdx(via @objectstack/spec)
  • content/docs/concepts/design-principles.mdx(via packages/spec)
  • content/docs/concepts/index.mdx(via @objectstack/spec)
  • content/docs/concepts/metadata-driven.mdx(via @objectstack/spec)
  • content/docs/concepts/metadata-lifecycle.mdx(via packages/spec)
  • content/docs/concepts/north-star.mdx(via packages/spec)
  • content/docs/data-modeling/analytics.mdx(via @objectstack/spec)
  • content/docs/data-modeling/drivers.mdx(via @objectstack/spec)
  • content/docs/data-modeling/external-datasources.mdx(via @objectstack/spec)
  • content/docs/data-modeling/field-types.mdx(via @objectstack/spec)
  • content/docs/data-modeling/fields.mdx(via @objectstack/spec)
  • content/docs/data-modeling/formulas.mdx(via @objectstack/spec)
  • content/docs/data-modeling/index.mdx(via @objectstack/spec)
  • content/docs/data-modeling/objects.mdx(via @objectstack/spec)
  • content/docs/data-modeling/queries.mdx(via @objectstack/spec)
  • content/docs/data-modeling/schema-design.mdx(via @objectstack/spec)
  • content/docs/data-modeling/seed-data.mdx(via @objectstack/spec)
  • content/docs/data-modeling/validation-rules.mdx(via @objectstack/spec)
  • content/docs/data-modeling/validation.mdx(via @objectstack/spec)
  • content/docs/deployment/cli.mdx(via @objectstack/spec)
  • content/docs/deployment/troubleshooting.mdx(via @objectstack/spec)
  • content/docs/deployment/validating-metadata.mdx(via @objectstack/spec)
  • content/docs/getting-started/build-with-claude-code.mdx(via @objectstack/spec)
  • content/docs/getting-started/common-patterns.mdx(via @objectstack/spec)
  • content/docs/getting-started/examples.mdx(via @objectstack/spec)
  • content/docs/getting-started/quick-reference.mdx(via @objectstack/spec)
  • content/docs/getting-started/quick-start.mdx(via @objectstack/spec)
  • content/docs/getting-started/your-first-project.mdx(via @objectstack/spec)
  • content/docs/kernel/cluster.mdx(via @objectstack/spec)
  • content/docs/kernel/contracts/auth-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/cache-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/data-engine.mdx(via @objectstack/spec)
  • content/docs/kernel/contracts/index.mdx(via @objectstack/spec)
  • content/docs/kernel/contracts/metadata-service.mdx(via packages/spec)
  • content/docs/kernel/contracts/storage-service.mdx(via packages/spec)
  • content/docs/kernel/index.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/email-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/index.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/queue-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/sharing-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/sms-service.mdx(via packages/spec)
  • content/docs/kernel/runtime-services/storage-service.mdx(via packages/spec)
  • content/docs/kernel/services-checklist.mdx(via @objectstack/spec)
  • content/docs/permissions/authorization.mdx(via packages/plugins/plugin-sharing, packages/qa, @objectstack/spec)
  • content/docs/permissions/delegated-administration.mdx(via packages/qa)
  • content/docs/permissions/permission-sets.mdx(via @objectstack/spec)
  • content/docs/permissions/permissions-matrix.mdx(via packages/plugins/plugin-sharing, @objectstack/spec)
  • content/docs/permissions/positions.mdx(via @objectstack/spec)
  • content/docs/permissions/rls.mdx(via @objectstack/spec)
  • content/docs/permissions/sharing-rules.mdx(via @objectstack/spec)
  • content/docs/plugins/adding-a-metadata-type.mdx(via @objectstack/spec)
  • content/docs/plugins/development.mdx(via @objectstack/spec)
  • content/docs/plugins/index.mdx(via @objectstack/spec)
  • content/docs/plugins/packages.mdx(via @objectstack/plugin-sharing, @objectstack/spec)
  • content/docs/protocol/backward-compatibility.mdx(via @objectstack/spec)
  • content/docs/protocol/diagram.mdx(via packages/spec)
  • content/docs/protocol/kernel/config-resolution.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/i18n-standard.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/index.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/lifecycle.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/plugin-spec.mdx(via @objectstack/spec)
  • content/docs/protocol/kernel/runtime-capabilities.mdx(via @objectstack/spec)
  • content/docs/protocol/knowledge.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/index.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/query-syntax.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/schema.mdx(via @objectstack/spec)
  • content/docs/protocol/objectql/security.mdx(via packages/plugins/plugin-sharing, packages/spec)
  • content/docs/protocol/objectql/state-machine.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/actions.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/concept.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/index.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/layout-dsl.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/record-alert.mdx(via @objectstack/spec)
  • content/docs/protocol/objectui/widget-contract.mdx(via @objectstack/spec)
  • content/docs/releases/implementation-status.mdx(via @objectstack/spec)
  • content/docs/releases/index.mdx(via @objectstack/spec)
  • content/docs/releases/v12.mdx(via @objectstack/spec)
  • content/docs/releases/v13.mdx(via @objectstack/spec)
  • content/docs/releases/v16.mdx(via @objectstack/spec)
  • content/docs/releases/v9.mdx(via @objectstack/spec)
  • content/docs/ui/actions.mdx(via @objectstack/spec)
  • content/docs/ui/create-vs-edit-form.mdx(via @objectstack/spec)
  • content/docs/ui/dashboards.mdx(via @objectstack/spec)
  • content/docs/ui/forms.mdx(via @objectstack/spec)
  • content/docs/ui/index.mdx(via @objectstack/spec)
  • content/docs/ui/public-data-collection.mdx(via @objectstack/spec)
  • content/docs/ui/setup-app.mdx(via @objectstack/spec)
  • content/docs/ui/translations.mdx(via @objectstack/spec)
  • content/docs/ui/views.mdx(via @objectstack/spec)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang
os-zhuang merged commit 503be86 into mainJul 27, 2026
17 checks passed
@os-zhuang
os-zhuang deleted the feat/sharing-rule-recipient-reconcile branch July 27, 2026 04:43
os-zhuang added a commit that referenced this pull request Jul 27, 2026
…ec/system (#1878) (#3593)
The entire system/audit.zod.ts module — AuditConfigSchema, AuditStorageConfig,
AuditRetentionPolicy, AuditEventFilter, SuspiciousActivityRule,
DEFAULT_SUSPICIOUS_ACTIVITY_RULES, and the AuditEvent* shape schemas — had
ZERO consumers repo-wide. The live audit path (plugin-audit) imports none of
it: capture is unconditional via engine hooks (compliance ledger), the row
shape is owned by plugin-audit's sys_audit_log object, retention rides the
object lifecycle `audit` category with per-org settings overrides, and the
authoring surface is object/field trackHistory. AuditConfigSchema.enabled
even advertised turning the compliance ledger OFF — a semantic the platform
deliberately rejects. Same ADR-0056 D8 family as the compliance.zod /
masking.zod / RLSAuditConfig / PolicySchema removals.
- Delete system/audit.zod.ts + audit.test.ts; drop the export from
system/index.ts with a removal note (house pattern).
- Drop the 11 manifest ratchet keys; regenerate JSON schemas, reference docs
(references/system/audit.mdx removed by regen), and the API surface
(21 exports, pure removal).
- Fix the stale security-context.zod.ts module doc (audit joins the already
removed compliance/masking bullets) and drop the PROTOCOL_MAP.md row
(protocol-map gate caught the dangling link).
- Annotate the 2026-07 security recheck doc: loose-end #1 done (verified
scope = whole module, not just AuditRetentionPolicy); #2 done via #3557.
- Changeset (minor per launch-window policy) carries the dead-knob → live-
surface migration table.
Verified: 6679 spec tests green, tsc clean, check:docs/api-surface/skill-refs/
react-blocks in sync, downstream-contract typecheck clean (gate not pinning
any Audit export).
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/lteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@os-zhuang