Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions crates/twigpine-node/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ async fn collect_visible_ref_updates_inner(
// at admission, checked separately from the mirror's (untrustworthy)
// visibility fields. A folded is_public=false cannot enforce that here —
// visibility_check short-circuits to Allow for the owner before is_public is
// read, so an owner-matched row would leak. Instead, drop any row that names a
// quarantined repo in the loop below, before the visibility gate runs, so the
// drop bypasses that owner short-circuit entirely.
// read, so an owner-matched row would leak. Instead, the loop below calls
// RefUpdateRepoIndex::row_visible, which vetoes any row that names a
// quarantined repo before it checks visibility, so the drop bypasses that
// owner short-circuit entirely.
let quarantined = db.list_quarantined_repos().await?;
let ids: Vec<String> = deduped.iter().map(|r| r.id.clone()).collect();
let rules = db.list_visibility_rules_for_repos(&ids).await?;
let repos = crate::visibility::RefUpdateRepoIndex::new(&deduped, &quarantined);

// Never scan fewer rows than the caller asked for (no regression vs the old
// single LIMIT), but cap the walk so a feed of newest-private rows can't
Expand Down Expand Up @@ -110,15 +112,7 @@ async fn collect_visible_ref_updates_inner(
after = Some((last.received_at.clone(), last.id.clone()));
}
for u in rows {
// Quarantine denies unconditionally, before the visibility gate, so
// even a caller matching the mirror's owner_did cannot read the row.
if quarantined
.iter()
.any(|q| crate::visibility::ref_update_row_names_repo(q, &u.repo))
{
continue;
}
if crate::visibility::ref_update_row_visible(&deduped, &rules, caller, &u.repo) {
if repos.row_visible(&rules, caller, &u.repo) {
visible.push(u);
if visible.len() == want {
return Ok(visible);
Expand Down
7 changes: 3 additions & 4 deletions crates/twigpine-node/src/api/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ const MAX_TASK_SCAN_CANDIDATES: i64 = 1_000;
/// to — they hold its `payload` (and held `ucan_token`, though reads never
/// echo it back) from creating or being assigned it. Otherwise, a task naming
/// a locally-hosted repo follows that repo's normal read gate, the same way
/// `ref_update_row_visible` (`visibility.rs`) drops a ref-update row for a
/// repo the caller can't read. A task with no `repo_id`, or naming a repo this
/// node does not host, is visible only to its delegator/assignee — fail
/// closed, since an open-to-everyone default is exactly the gap #268 found
/// the ref-update feed drops a row for a repo the caller can't read. A task with
/// no `repo_id`, or naming a repo this node does not host, is visible only to
/// its delegator/assignee, since an open default is the gap #268 found
/// (`GET /api/v1/tasks` and `/tasks/{id}` had no gate at all).
pub(crate) fn task_visible(
task: &AgentTask,
Expand Down
Loading