Skip to content

fix(primitives): check source access for shared reads - #1363

Closed
vsrikar08 wants to merge 15 commits into
feat/1361-team-membershipfrom
fix/1290-shared-source-access
Closed

vsrikar08 wants to merge 15 commits into
feat/1361-team-membershipfrom
fix/1290-shared-source-access

Conversation

@vsrikar08

@vsrikar08 vsrikar08 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Review reconciliation — 2026-11-11

SDK generation now uses findForViewer for an explicit patchId, closing the separate restricted-ID existence probe. Existing viewer-required shared table/store schema checks are preserved; a focused case covers restricted, missing and entitled IDs.

Included in assembled #1379 at 0e01b1c3. All 24 workspace typecheck tasks and 74 focused tests pass on its code parent 19e603f; the final head adds only documentation wording. Broad verification is non-green; Srikar owns the complete Brightline journey. This does not establish full-feature readiness.

What changed

Shared reads and SDK schema generation now require the initiating viewer to be entitled to the source patch. Dependency guards still count every consumer, but disclose names and owners only for patches the actor can open, plus a count of the others.

The Share warning appears only when selected teams narrow access. Acknowledgement is explicit and checked against the dependency summary at save time. Rendering uses the existing read-only management check and omits the warning if access disappears. Publish keeps its existing single force option for both dependency refusals.

Closes #1290. Part of #1192. Stacked on #1362. This update incorporates the current parent without changing any other PR branch.

Look at

  • Audiences.test.ts: membership removal denies the same viewer's protected runtime lookup and table/store schemas; an entitled viewer continues and membership restoration recovers. Hidden consumers still block retirement, metadata stays filtered, warning reads take no row locks, and a new consumer invalidates an old acknowledgement.
  • Shared table/file contracts cover get/getMany/list, metadata and bytes. Existing live-query recovery and authority fences remain intact.
  • Browser check exercised unchanged teams, widening, narrowing, and clearing acknowledgement when switching back to Company.

How it was verified

Affected API/SDK/portal/render suites: 208 tests passed. Final viewer-required source/table/file suites: 57 passed. Focused CLI refusal suite: 14 passed. Workspace typecheck: 24 tasks passed; lint, formatting and whitespace pass. Browser warning checks passed. Commit: be0af044.

The broad CLI run retains three macOS PTY failures in tests using Linux script flags. Full pnpm verify and independent acceptance are not claimed. No merge-ready claim.

Surface audit: source schemas, runtime shared reads and file redemption, live authority tracing, dependency refusals, management cards and sharing warning, API schema/docs, CLI refusal details and docs, product copy boundary, and existing release-bound shared-resource skills apply. No new migrations or packages. Copied data follows its destination's permissions; revocation does not retract prior copies.

CI follow-up: 630c5d4f fixes the obsolete audience_revision reference in live-read fencing after the parent consolidated authority into lifecycle_revision; its test now exercises actual sharing and retirement. Two stale Teams-markup assertions were aligned with the current page. ee34bbbe restricts the public-confirmation CSS selector to scope controls, fixing the review finding without treating team-checkbox markers as scope selection.

Verification: the previously failing browser case was reproduced, then all five subscription browser journeys passed; packed tier-2 smoke passed end to end. Local query subscriptions (3), patch audience/lifecycle suites (13), hosted member/guest suites (14), and Teams suite (27) passed. The rendered Share-dialog browser check covers hidden-team preservation, widening/narrowing, acknowledgement reset, and public confirmation; that confirmation check failed before the selector fix and passed after it. Workspace typecheck (24 tasks), lint, formatting and whitespace passed. Latest-head GitHub checks are being verified.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Internal viewer-required APIs and additive refusal metadata protect the unmerged team-access stack. Company-wide reads retain their behavior.

  • What does a revert leave behind? This PR adds no migrations or persistent state.
  • Does the release before it still work with that? Yes; reverting removes these protections. The access stack must land together.

Model and harness: GPT-6 through Codex.

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area area:primitives Patch tables and files area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines labels Nov 9, 2026
@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area labels Nov 9, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T07:59:58.903964Z 95dd4cc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@allisonmahmood

Copy link
Copy Markdown
Owner

Review of #1363 (shared-source access). Allison's review, posted by Fermy (his agent). Line numbers are at ab64ad68. It's a static review; nothing was run. Stack-wide points are explained in the stack review on #1192.

Small and sound:

The gaps are the other paths that list dependants.

This PR

  • Should-fix: dependants are still listed company-wide.
    • refuseDependants (Patches.ts:2046) serves publish-time table and store removal, delete and retire. It returns every dependant's name and owner, and so does managementCard.dependants (:2711).
    • Example: Ana retires her source patch "Accounts". The has_dependants refusal names "Payroll recon", which only Finance can open, along with its owner.
    • Fix: keep counting every dependant for the guard, but show only the ones the actor can open, plus "N others".
  • Should-fix (fix(access): protect patch metadata and simplify agent checks #1367): SDK generation ignores the viewer.
  • Nit: the Share dialog warns and forces whenever any visible dependant exists.
    • It shows "Some people may lose shared reads" and posts force=true (share.ts:174-180) on widening, on guest-only edits, and even with teams off.
    • So the portal never reaches the server's refusal, and a dependant published between render and Save is forced through unseen.
    • Warn, and force, only when the selected teams narrow the audience.
  • Nit: rendering the dialog locks rows on a GET and can 500.
    • It calls sharingDependants, then manageable(), which takes the patch FOR UPDATE and the company FOR SHARE.
    • It maps PatchUnavailable and NotOwner to Effect.die (PortalPages.ts:315-319, 416-420). Lose access between the list and the render, and you get a 500.
    • Map both to "no warning", and don't lock rows to render.
  • Nit: the viewer is an optional positional parameter (runtime/src/LoadedVersions.ts:32; Patches.find(patchId, versionNumber?, versionId?, viewer?)).
    • A caller that leaves it out gets the company-wide answer this PR exists to fix.
    • A method that requires the viewer, or an options object, makes forgetting it a type error.
  • Nit: one --force covers two refusals. Narrowing reuses HasDependants and publish's single --force, so forcing a table removal also forces a narrowing.

Tests

  • Keep: Audiences.test "rechecks source access…".

@vsrikar08 vsrikar08 added the one-way Rolling production back past this PR would break the release before it label Nov 10, 2026
@github-actions github-actions Bot added area:core Touches the core area area:integrations Company connections and integration implementations labels Nov 10, 2026
@github-actions github-actions Bot added size:l 501-1,000 changed lines and removed size:m 100-500 changed lines labels Nov 10, 2026
@github-actions github-actions Bot removed the area:core Touches the core area label Nov 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46ad3c348e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

.map(
(team) =>
`<label class="field-choice"><input class="field-checkbox" type="checkbox" name="teamIds" value="${escapeAttribute(team.id)}"${selectedTeams.has(team.id) ? " checked" : ""}>${escapeHtml(team.name)}</label>`
`<label class="field-choice"><input class="field-checkbox" type="checkbox" name="teamIds" value="${escapeAttribute(team.id)}"${selectedTeams.has(team.id) ? " checked data-current" : ""}>${escapeHtml(team.name)}</label>`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep team markers out of the public-confirmation selector

When a tier-1 patch already shared with selected teams switches to “Anyone on the internet,” its original team checkboxes remain checked and now carry data-current. The existing .share-audience:has(input[data-current]:checked) .share-change rule therefore hides the “Make public” confirmation, while the separate .share-save rule hides the regular submit button for a new public selection. The owner is left without a visible action to apply the change. Restrict the confirmation-hiding selector to the scope radios or use a distinct marker for previous team selections.

Useful? React with 👍 / 👎.

@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Nov 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee34bbbe52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const summary = input.dependants;
const dependencyWarning =
summary && summary.dependants.length + summary.hiddenCount > 0
? `<aside class="note note-warn" data-source-warning hidden><strong>Some people may lose shared reads</strong><ul>${summary.dependants.map((d) => `<li>${escapeHtml(d.name)}</li>`).join("")}${summary.hiddenCount ? `<li>${summary.hiddenCount} others</li>` : ""}</ul><p>Previously copied data stays with its destination.</p><label><input type="checkbox" name="force" value="true" disabled> Acknowledge shared-read failures</label></aside>`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use shared field styling for the dependency acknowledgement

When a source with dependants is narrowed to selected teams, the new acknowledgement renders with an unclassed label and checkbox. Unlike the other Share controls, it therefore misses the 44px minimum hit target provided by .field-choice in packages/core/src/html.ts:809, making the acknowledgement harder to activate on touch devices. Apply field-choice to the label and field-checkbox to the input, as required by the UI consistency spec that AGENTS.md mandates for served pages.

AGENTS.md reference: AGENTS.md:L79-L79

Useful? React with 👍 / 👎.

@allisonmahmood

Copy link
Copy Markdown
Owner

Superseded by #1416 (the rollback bridge) and #1417 (teams), which carry this work forward under Allison's decisions on #1192 (#1192 (comment)). Closing without merging; Srikar is co-author there. Posted by Fermy (Allison's agent).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:integrations Company connections and integration implementations area:primitives Patch tables and files area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles one-way Rolling production back past this PR would break the release before it size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants