From ccdd0efbe1db9fb142c9e2628b1d0ea81aa34fd0 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 22 Oct 2026 13:36:05 +0300 Subject: [PATCH 1/4] docs(adr): coalesce entity-source discovery queries Define one scoped candidate search, local harness routing, and a final source-query membership gate without changing the current entity authorization contract. Signed-off-by: Barak Korren Assisted-by: Codex (GPT-6) --- .../0098-entity-first-harness-evaluation.md | 6 + ...use-poll-and-entity-bound-run-processes.md | 5 + ...oalesce-entity-source-discovery-queries.md | 134 ++++++++++++++++++ docs/architecture.md | 11 ++ docs/problems/agent-architecture.md | 4 + 5 files changed, 160 insertions(+) create mode 100644 docs/ADRs/0149-coalesce-entity-source-discovery-queries.md diff --git a/docs/ADRs/0098-entity-first-harness-evaluation.md b/docs/ADRs/0098-entity-first-harness-evaluation.md index 412707ca6c..59c6441180 100644 --- a/docs/ADRs/0098-entity-first-harness-evaluation.md +++ b/docs/ADRs/0098-entity-first-harness-evaluation.md @@ -42,6 +42,12 @@ trusted, entity-bound `fullsend run` may recheck only its canonical entity with eventless paths require eligible entity sources, trusted Fullsend invocation provenance, current actor filtering, and the same harness CEL predicate. +[ADR 0149](0149-coalesce-entity-source-discovery-queries.md) partially +supersedes the optional query sharing below: entity-source discovery requires +one combined logical search per source scope and local per-harness routing. +For source-backed harnesses, even an event-supplied candidate must pass a +current local source-query membership check before sandbox admission. + ## Context [ADR 0061](0061-harness-cel-dispatch.md) made a `NormalizedEvent` the sole CEL diff --git a/docs/ADRs/0144-reuse-poll-and-entity-bound-run-processes.md b/docs/ADRs/0144-reuse-poll-and-entity-bound-run-processes.md index be9a351f76..10ef8c8867 100644 --- a/docs/ADRs/0144-reuse-poll-and-entity-bound-run-processes.md +++ b/docs/ADRs/0144-reuse-poll-and-entity-bound-run-processes.md @@ -29,6 +29,11 @@ Partially supersedes [ADR 0063](0063-polling-based-work-discovery.md): `fullsend poll` may remain resident instead of always exiting after one cycle. Its per-repository scope and driver architecture remain current. +[ADR 0149](0149-coalesce-entity-source-discovery-queries.md) decides the +entity-source discovery-query strategy left separate below and requires a +current local query match, as well as true CEL, before a source-backed +sandbox cycle. + ## Context [ADR 0098](0098-entity-first-harness-evaluation.md) makes the current entity, diff --git a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md new file mode 100644 index 0000000000..693352d387 --- /dev/null +++ b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md @@ -0,0 +1,134 @@ +--- +title: "149. Coalesce entity-source discovery queries and route candidates locally" +status: Accepted +relates_to: + - agent-architecture +topics: + - polling + - entities + - dispatch +--- + +# 149. Coalesce entity-source discovery queries and route candidates locally + +Date: 2026-10-22 + +## Status + +Accepted + +Partially supersedes [ADR 0098](0098-entity-first-harness-evaluation.md): +combining compatible entity-source queries becomes required, and source-query +membership becomes a harness eligibility condition as well as a way to find +candidates. [ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md) +continues to govern poll and bound-run lifecycles; this decision adds a local +source-query check before each source-backed sandbox cycle. + +## Context + +ADR 0098 lets harnesses declare entity sources but only permits sharing +compatible provider queries. ADR 0144 relies on recurring repository-scoped +discovery to recover work after a bound run exits. A separate provider search +for every harness increases reads and still leaves `poll` to determine which +harnesses should receive each result. A provider search result also cannot +prove that an entity remains in a harness's source when `run` starts. + +**Planned:** Entity-source discovery is not yet implemented; [#8418](https://github.com/fullsend-ai/fullsend/issues/8418) +tracks entity-first execution and [#8421](https://github.com/fullsend-ai/fullsend/issues/8421) +tracks discovery requirements. The current [`fullsend poll` command](https://github.com/fullsend-ai/fullsend/blob/0777c7f37b9cdcf0d293635be1bd40f25c1806d8/internal/cli/poll.go#L41-L64) +uses event-reconstructing input drivers. + +## Options + +### Search separately for each harness + +This allows arbitrary provider-native queries, but provider search cost grows +with the number of harnesses and duplicate hits still need routing. + +### Combine admissible queries and route locally + +This shares discovery work, but limits sources to queries that an adapter can +combine without missing candidates and re-evaluate locally. + +## Decision + +For each discovery cycle and source scope, `fullsend poll` MUST issue one +logical candidate search covering the union of all enabled harness +entity-source queries in that scope. A scope is the provider, tenant, +repository or project, entity kind, and effective credential scope. A trusted +scope guard stays outside the harness-query union; neither a harness query +nor composition may widen it. `poll` verifies every hit's canonical scope +before routing. Pagination and coverage partitions may implement one logical +search, but separate full searches per harness do not. + +An entity-source query is admissible only if its adapter can plan a search +that includes every possible local match and can reproduce query membership +locally from a defined routing projection and, if needed, follow-up reads. +A broader search is allowed within the trusted scope and provider bounds. +Opaque provider-only operators and ranking or top-N membership are unsupported +when their result cannot be reproduced locally. The adapter rejects an +unsupported source rather than silently omitting it or searching separately. + +`poll` deduplicates hits by canonical entity identity and evaluates each +relevant harness query locally. It routes a matching candidate to every +matching harness for CEL evaluation. If local query membership is unresolved, +`poll` may fetch more evidence or hand the candidate to bound `run` for +resolution; missing data never means false. Candidate search and routing need +not fetch all entity fields or history required for final CEL evaluation. + +Before every sandbox cycle for a source-backed harness, including a cycle +prompted directly by an event or wakeup, bound `run` resolves current entity +facts and locally checks both source-query membership and harness CEL. It may +settle either check first, but both MUST be definitively true before starting +a sandbox. A verified event supplies a candidate and retains its separate +actor-authorization gate; it cannot bypass the declared source query. A stale +search hit is not evidence of current membership. Unresolved membership +cannot launch a sandbox and must retain a retry or rediscovery path. + +Actor-originated facts used by a query receive the same harness-stage +authorization as action-indicating facts used by CEL. A raw provider filter +must not omit an entity whose query could match after unauthorized facts are +removed locally, including for a negated condition. This decision does not +relax [ADR 0098](0098-entity-first-harness-evaluation.md) or the +[Authorization Contract v1](../normative/authorization/v1/README.md): before +CEL, the full action-indicating superset is still enumerated, every actor's +current permission is resolved, and the required audit is retained. A local +query check that does not evaluate CEL may stop on a proven non-match, but +cannot derive that result from unverified actor evidence. + +The combined search must preserve candidate coverage across pagination, +provider caps, delayed indexing, and concurrent changes. Finishing the pages +alone does not prove completeness; an adapter needs a stable covered range or +sound overlap and reconciliation for possibly missed entities. An unproven +range cannot advance a completion checkpoint without durable retry or proven +rediscovery. A plan change requires a catch-up scan for newly eligible +entities. Time-dependent queries require periodic rediscovery or durable due +records even when an entity does not change. + +Before entity-source discovery is enabled, a versioned normative query +protocol must define source declarations, allowed operators, routing facts, +provider mappings, bounds, pagination, coverage evidence, and conformance +cases. Before source-backed execution is enabled, a new major authorization +contract under [ADR 0015](0015-normative-specifications-directory.md) must +define the source-query admission gate and actor evidence. This ADR does not +choose query syntax or require full entity hydration during discovery. + +## Forge scope + +This applies to GitHub, GitLab, Forgejo, and Jira entity-source adapters. +Each adapter must prove the combined-search and local-recheck semantics for +the source queries it accepts. Existing event-reconstructing poll drivers, +including Jira's `--jql` override, remain under +[ADR 0063](0063-polling-based-work-discovery.md). Event-only harnesses +without an entity source are unaffected. + +## Consequences + +- Logical searches scale with source scopes rather than harness count; + broader searches can increase result volume and local routing work. +- Source queries cannot use provider features that cannot be combined and + rechecked locally; harness CEL remains a separate predicate. +- Partial scans and uncertain query results stay visible and retryable rather + than silently omitting candidates or admitting a sandbox. +- Event-backed runs for source-backed harnesses also reject current query + non-matches while preserving the existing event-actor gate. diff --git a/docs/architecture.md b/docs/architecture.md index 41f870fad4..69cecf9399 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -470,11 +470,22 @@ The existing design principle is that [the repo is the coordinator](problems/age ([ADR 0098](ADRs/0098-entity-first-harness-evaluation.md), [ADR 0144](ADRs/0144-reuse-poll-and-entity-bound-run-processes.md)). +**Planned:** Entity-source discovery combines admissible harness queries into +one logical candidate search per source scope and routes possible matches +locally. A bound `run` rechecks source-query membership before event-backed or +eventless sandbox cycles ([ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md)). +Implementation and the normative query protocol are tracked in +[#8418](https://github.com/fullsend-ai/fullsend/issues/8418) and +[#8421](https://github.com/fullsend-ai/fullsend/issues/8421). + **Open questions:** - What normative entity-history, query-planning, and handled-state contract can support entity-first harness evaluation without unbounded provider reads ([ADR 0098](ADRs/0098-entity-first-harness-evaluation.md))? + [ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md) decides + query combination and local routing; syntax, adapter mappings, coverage + details, entity history, and handled state remain open. - Is GitHub's event system sufficient for forge-native duplicate protection, or do we need additional coordination beyond label/state conventions and agent idempotency? (Jira polling per ADR 0063 uses entity-property locks and runner diff --git a/docs/problems/agent-architecture.md b/docs/problems/agent-architecture.md index 644f278b79..17ff75b25a 100644 --- a/docs/problems/agent-architecture.md +++ b/docs/problems/agent-architecture.md @@ -149,6 +149,10 @@ The repository's existing infrastructure provides all the coordination needed: harness predicates should be evaluated. Each predicate can inspect the resolved entity and an optional prompting event ([ADR 0098](../ADRs/0098-entity-first-harness-evaluation.md)). + [ADR 0149](../ADRs/0149-coalesce-entity-source-discovery-queries.md) + combines source queries into one logical candidate search and routes each + possible result locally. A bound run rechecks source-query membership, + including when an event supplies the candidate. No agent orchestrates other agents. Each agent independently observes the state of the PR and acts according to its role: From 97cfccd928ef2243753e582dae0ae103a350df25 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Fri, 23 Oct 2026 00:25:54 +0300 Subject: [PATCH 2/4] docs(adr): address source discovery review wording Signed-off-by: Barak Korren Assisted-by: Codex (GPT-6) --- ...49-coalesce-entity-source-discovery-queries.md | 9 ++++++--- docs/architecture.md | 15 ++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md index 693352d387..aae905689c 100644 --- a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md +++ b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md @@ -33,9 +33,12 @@ for every harness increases reads and still leaves `poll` to determine which harnesses should receive each result. A provider search result also cannot prove that an entity remains in a harness's source when `run` starts. -**Planned:** Entity-source discovery is not yet implemented; [#8418](https://github.com/fullsend-ai/fullsend/issues/8418) -tracks entity-first execution and [#8421](https://github.com/fullsend-ai/fullsend/issues/8421) -tracks discovery requirements. The current [`fullsend poll` command](https://github.com/fullsend-ai/fullsend/blob/0777c7f37b9cdcf0d293635be1bd40f25c1806d8/internal/cli/poll.go#L41-L64) +Entity-source discovery is not yet implemented. +[#8418](https://github.com/fullsend-ai/fullsend/issues/8418) +tracks entity-first execution, while +[#8421](https://github.com/fullsend-ai/fullsend/issues/8421) +tracks discovery requirements. The current +[`fullsend poll` command](https://github.com/fullsend-ai/fullsend/blob/0777c7f37b9cdcf0d293635be1bd40f25c1806d8/internal/cli/poll.go#L41-L64) uses event-reconstructing input drivers. ## Options diff --git a/docs/architecture.md b/docs/architecture.md index 69cecf9399..f52f89b586 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -470,13 +470,14 @@ The existing design principle is that [the repo is the coordinator](problems/age ([ADR 0098](ADRs/0098-entity-first-harness-evaluation.md), [ADR 0144](ADRs/0144-reuse-poll-and-entity-bound-run-processes.md)). -**Planned:** Entity-source discovery combines admissible harness queries into -one logical candidate search per source scope and routes possible matches -locally. A bound `run` rechecks source-query membership before event-backed or -eventless sandbox cycles ([ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md)). -Implementation and the normative query protocol are tracked in -[#8418](https://github.com/fullsend-ai/fullsend/issues/8418) and -[#8421](https://github.com/fullsend-ai/fullsend/issues/8421). +- Entity-source discovery (target state): `fullsend poll` combines admissible + harness queries into one logical candidate search per source scope and routes + possible matches locally. A bound `run` rechecks source-query membership + before event-backed or eventless sandbox cycles + ([ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md)). + Implementation and the normative query protocol are tracked in + [#8418](https://github.com/fullsend-ai/fullsend/issues/8418) and + [#8421](https://github.com/fullsend-ai/fullsend/issues/8421). **Open questions:** From b7bbb4f64dfa7ebe0d8b0632e65857205d31d555 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 28 Oct 2026 15:49:35 +0200 Subject: [PATCH 3/4] docs(adr): simplify entity-source discovery language Signed-off-by: Barak Korren Assisted-by: Codex (GPT-6) --- ...oalesce-entity-source-discovery-queries.md | 185 +++++++++--------- 1 file changed, 95 insertions(+), 90 deletions(-) diff --git a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md index aae905689c..8fd1326d13 100644 --- a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md +++ b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md @@ -1,5 +1,5 @@ --- -title: "149. Coalesce entity-source discovery queries and route candidates locally" +title: "149. Combine entity-source searches and route matches locally" status: Accepted relates_to: - agent-architecture @@ -9,7 +9,7 @@ topics: - dispatch --- -# 149. Coalesce entity-source discovery queries and route candidates locally +# 149. Combine entity-source searches and route matches locally Date: 2026-10-22 @@ -17,21 +17,22 @@ Date: 2026-10-22 Accepted -Partially supersedes [ADR 0098](0098-entity-first-harness-evaluation.md): -combining compatible entity-source queries becomes required, and source-query -membership becomes a harness eligibility condition as well as a way to find -candidates. [ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md) -continues to govern poll and bound-run lifecycles; this decision adds a local -source-query check before each source-backed sandbox cycle. +This ADR partially supersedes +[ADR 0098](0098-entity-first-harness-evaluation.md): compatible entity-source +queries must be combined, and matching a source is required both to find a +candidate and to let a harness act on it. +[ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md) still governs +poll and bound-run lifecycles. This ADR adds a local source check before each +sandbox cycle for a source-backed harness. ## Context -ADR 0098 lets harnesses declare entity sources but only permits sharing -compatible provider queries. ADR 0144 relies on recurring repository-scoped -discovery to recover work after a bound run exits. A separate provider search -for every harness increases reads and still leaves `poll` to determine which -harnesses should receive each result. A provider search result also cannot -prove that an entity remains in a harness's source when `run` starts. +ADR 0098 lets harnesses declare entity sources, but allows sharing only when +their provider queries are compatible. ADR 0144 relies on repeated +repository-wide discovery to recover work after a bound run exits. Searching +separately for each harness increases provider reads and still leaves `poll` to +decide which harnesses receive each result. A search result also cannot prove +that an entity still matches a harness's source when `run` starts. Entity-source discovery is not yet implemented. [#8418](https://github.com/fullsend-ai/fullsend/issues/8418) @@ -45,93 +46,97 @@ uses event-reconstructing input drivers. ### Search separately for each harness -This allows arbitrary provider-native queries, but provider search cost grows -with the number of harnesses and duplicate hits still need routing. +Each harness can use any query its provider supports. But provider reads grow +with the number of harnesses, and duplicate results still need routing. ### Combine admissible queries and route locally -This shares discovery work, but limits sources to queries that an adapter can -combine without missing candidates and re-evaluate locally. +One search uses less provider work. But adapters can accept only queries they +can combine without missing matches and check locally. ## Decision -For each discovery cycle and source scope, `fullsend poll` MUST issue one -logical candidate search covering the union of all enabled harness -entity-source queries in that scope. A scope is the provider, tenant, -repository or project, entity kind, and effective credential scope. A trusted -scope guard stays outside the harness-query union; neither a harness query -nor composition may widen it. `poll` verifies every hit's canonical scope -before routing. Pagination and coverage partitions may implement one logical -search, but separate full searches per harness do not. - -An entity-source query is admissible only if its adapter can plan a search -that includes every possible local match and can reproduce query membership -locally from a defined routing projection and, if needed, follow-up reads. -A broader search is allowed within the trusted scope and provider bounds. -Opaque provider-only operators and ranking or top-N membership are unsupported -when their result cannot be reproduced locally. The adapter rejects an -unsupported source rather than silently omitting it or searching separately. - -`poll` deduplicates hits by canonical entity identity and evaluates each -relevant harness query locally. It routes a matching candidate to every -matching harness for CEL evaluation. If local query membership is unresolved, -`poll` may fetch more evidence or hand the candidate to bound `run` for -resolution; missing data never means false. Candidate search and routing need -not fetch all entity fields or history required for final CEL evaluation. - -Before every sandbox cycle for a source-backed harness, including a cycle -prompted directly by an event or wakeup, bound `run` resolves current entity -facts and locally checks both source-query membership and harness CEL. It may -settle either check first, but both MUST be definitively true before starting -a sandbox. A verified event supplies a candidate and retains its separate -actor-authorization gate; it cannot bypass the declared source query. A stale -search hit is not evidence of current membership. Unresolved membership -cannot launch a sandbox and must retain a retry or rediscovery path. - -Actor-originated facts used by a query receive the same harness-stage -authorization as action-indicating facts used by CEL. A raw provider filter -must not omit an entity whose query could match after unauthorized facts are -removed locally, including for a negated condition. This decision does not -relax [ADR 0098](0098-entity-first-harness-evaluation.md) or the +For each discovery cycle and source scope, `fullsend poll` MUST run one +combined logical search for candidates matching any enabled harness +entity-source query in that scope. A scope includes the provider, tenant, +repository or project, entity kind, and effective credential scope. Keep the +trusted scope guard separate from the harness queries; neither a query nor +their combination may widen it. Before routing each result, `poll` MUST verify +its canonical scope. Pagination and coverage partitions may split the work +within this one search, but `poll` MUST NOT run a separate full search for each +harness. + +An adapter may accept a query only if its provider search includes every entity +that might match locally. It must then be able to check whether each result +belongs to the harness source, using defined routing fields and follow-up reads +when needed. It may search more broadly if it stays within the trusted scope +and provider limits. It cannot accept provider-only operators or ranking and +top-N rules when local checks cannot reproduce their results. Reject a source +the adapter cannot support; do not silently omit it or search for it separately. + +`poll` removes duplicate results by canonical entity identity and checks each +relevant harness query locally. It sends each candidate to every harness whose +query matches for CEL evaluation. If it cannot tell whether a query matches, +`poll` may fetch more data or pass the candidate to bound `run`; missing data +never counts as a non-match. Discovery and routing need not fetch every entity +field or history needed for the final CEL check. + +Before each sandbox cycle for a source-backed harness, bound `run` reads the +current entity facts and checks both source membership and harness CEL locally. +This also applies to cycles started by an event or wakeup. The checks may run +in either order, but both MUST be true before a sandbox starts. A verified +event supplies a candidate and still goes through its separate actor- +authorization check; it cannot skip the source query. A stale search result +does not prove current membership. If membership is unknown, do not start a +sandbox; keep a retry or rediscovery path. + +Before a query uses actor-originated facts, those facts MUST pass the +harness-stage authorization required for action-indicating facts before CEL. +A provider filter MUST NOT exclude an entity that could match after +unauthorized facts are removed locally, including when the query negates a +condition. This ADR keeps the rules in +[ADR 0098](0098-entity-first-harness-evaluation.md) and the [Authorization Contract v1](../normative/authorization/v1/README.md): before -CEL, the full action-indicating superset is still enumerated, every actor's -current permission is resolved, and the required audit is retained. A local -query check that does not evaluate CEL may stop on a proven non-match, but -cannot derive that result from unverified actor evidence. - -The combined search must preserve candidate coverage across pagination, -provider caps, delayed indexing, and concurrent changes. Finishing the pages -alone does not prove completeness; an adapter needs a stable covered range or -sound overlap and reconciliation for possibly missed entities. An unproven -range cannot advance a completion checkpoint without durable retry or proven -rediscovery. A plan change requires a catch-up scan for newly eligible -entities. Time-dependent queries require periodic rediscovery or durable due -records even when an entity does not change. - -Before entity-source discovery is enabled, a versioned normative query -protocol must define source declarations, allowed operators, routing facts, -provider mappings, bounds, pagination, coverage evidence, and conformance -cases. Before source-backed execution is enabled, a new major authorization -contract under [ADR 0015](0015-normative-specifications-directory.md) must -define the source-query admission gate and actor evidence. This ADR does not -choose query syntax or require full entity hydration during discovery. +CEL runs, the system still collects the full set of action-indicating facts, +checks every actor's current permission, and keeps the required audit. A query +check that does not run CEL may stop when it proves there is no match, but it +cannot use unverified actor facts to prove that. + +The combined search must not miss candidates because of pagination, provider +result caps, delayed indexing, or concurrent changes. Reaching the last page +does not prove the search is complete. An adapter must establish a stable +covered range or use overlap and reconciliation to find possible misses. If +coverage is uncertain, it cannot mark the range complete unless it records a +durable retry or can prove the entities will be found later. When the search +plan changes, scan for newly eligible entities. Queries that depend on time +need periodic rediscovery or durable due records, even when an entity does not +change. + +Entity-source discovery cannot be enabled until there is a versioned normative +query protocol. It must define source declarations, allowed operators, routing +facts, provider mappings and limits, pagination, coverage evidence, and +conformance cases. Source-backed execution cannot be enabled until a new major +authorization contract under +[ADR 0015](0015-normative-specifications-directory.md) defines the +source-query admission gate and actor evidence. This ADR leaves query syntax +open and does not require fetching every entity field during discovery. ## Forge scope -This applies to GitHub, GitLab, Forgejo, and Jira entity-source adapters. -Each adapter must prove the combined-search and local-recheck semantics for -the source queries it accepts. Existing event-reconstructing poll drivers, -including Jira's `--jql` override, remain under -[ADR 0063](0063-polling-based-work-discovery.md). Event-only harnesses -without an entity source are unaffected. +This applies to entity-source adapters for GitHub, GitLab, Forgejo, and Jira. +Each adapter must show that it can combine and locally check the queries it +accepts. Existing poll drivers that reconstruct events, including Jira's +`--jql` override, remain under +[ADR 0063](0063-polling-based-work-discovery.md). Harnesses without an +entity source are unaffected. ## Consequences -- Logical searches scale with source scopes rather than harness count; - broader searches can increase result volume and local routing work. +- Search work grows with the number of source scopes, not harnesses. Broader + searches may return more results and require more local routing. - Source queries cannot use provider features that cannot be combined and - rechecked locally; harness CEL remains a separate predicate. -- Partial scans and uncertain query results stay visible and retryable rather - than silently omitting candidates or admitting a sandbox. -- Event-backed runs for source-backed harnesses also reject current query - non-matches while preserving the existing event-actor gate. + checked locally. Harness CEL remains a separate condition. +- Partial scans and uncertain results stay visible and retryable; they cannot + silently drop candidates or start a sandbox. +- For source-backed harnesses, event-backed runs also reject entities that no + longer match the source query and still check the event actor's authorization. From 9d81404959da02c70b9a3ec9208158831fd0d0f5 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Wed, 28 Oct 2026 17:48:19 +0200 Subject: [PATCH 4/4] docs(adr): clarify paginated entity routing Signed-off-by: Barak Korren Assisted-by: Codex (GPT-6) --- ...49-coalesce-entity-source-discovery-queries.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md index daf2f14993..b0983aee41 100644 --- a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md +++ b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md @@ -62,8 +62,7 @@ entity-source query in that scope. A scope includes the provider, tenant, repository or project, entity kind, and effective credential scope. This keeps the trusted scope guard separate from the harness queries; neither a query nor their combination may widen it. Before routing each result, `poll` MUST verify -its canonical scope. Pagination and coverage partitions may split the work -within this one search, but `poll` MUST NOT run a separate full search for each +its canonical scope. `poll` MUST NOT run a separate full search for each harness. An adapter may accept a query only if its provider search includes every entity @@ -76,10 +75,14 @@ the adapter cannot support; do not silently omit it or search for it separately. `poll` removes duplicate results by canonical entity identity and checks each relevant harness query locally. It sends each candidate to every harness whose -query matches for CEL evaluation. If it cannot tell whether a query matches, -`poll` may fetch more data or pass the candidate to bound `run`; missing data -never counts as a non-match. Discovery and routing need not fetch every entity -field or history needed for the final CEL check. +query matches for CEL evaluation. If provider pagination guarantees that a page +contains all results the query can return for a given entity, `poll` MAY route +that entity once it has processed the page while it fetches later pages. This +does not establish complete coverage for the combined search; the coverage +rules below still apply. If it cannot tell whether a query matches, `poll` may +fetch more data or pass the candidate to bound `run`; missing data never counts +as a non-match. Discovery and routing need not fetch every entity field or +history needed for the final CEL check. Before each sandbox cycle for an entity-driven harness, bound `run` reads the current entity facts and checks both source membership and harness CEL locally.