diff --git a/docs/ADRs/0079-bind-entity-execution-through-named-sources.md b/docs/ADRs/0079-bind-entity-execution-through-named-sources.md new file mode 100644 index 0000000000..f8704d3f59 --- /dev/null +++ b/docs/ADRs/0079-bind-entity-execution-through-named-sources.md @@ -0,0 +1,473 @@ +--- +title: "79. Bind entity-driven execution through named connections and sources" +status: Accepted +relates_to: + - agent-architecture + - agent-infrastructure +topics: + - configuration + - entities + - dispatch + - polling +--- + +# 79. Bind entity-driven execution through named connections and sources + +Date: 2026-11-08 + +## Status + +Accepted + +Refines [ADR 0098](0098-entity-first-harness-evaluation.md): harnesses declare +named entity slots and their kinds; repository configuration binds those slots +to concrete sources. +Partially supersedes [ADR 0149](0149-coalesce-entity-source-discovery-queries.md): +source membership uses native provider semantics and may be checked remotely, +rather than requiring local reproduction over actor-filtered data. Its combined +search, current-membership, coverage, and retry requirements remain. The +lifecycles in [ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md) +remain unchanged. + +## Context + +The current `tracker` mapping selects one issue backend and its issue-creation +policy, as specified in [issue #9074](https://github.com/fullsend-ai/fullsend/issues/9074). +[PR #9091](https://github.com/fullsend-ai/fullsend/pull/9091) added the +Jira connection and polling configuration contract. The +[review proposal](https://github.com/fullsend-ai/fullsend/pull/9091#discussion_r4465261777) +separates reusable connections, named entity sources, and agent bindings: one +connection can supply several entity kinds, and one agent can process equivalent +work from several systems. + +[ADR 0098](0098-entity-first-harness-evaluation.md), +[ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md), and +[ADR 0149](0149-coalesce-entity-source-discovery-queries.md) define entity +evaluation, reusable run processes, and combined discovery, but leave the +configuration and CI integration incomplete. +This ADR aims to connect those decisions through one repository-owned binding +model, while keeping agent coordination in entity state and predicates. + +## Options + +### Keep the current `tracker` syntax + +The existing syntax is compact and already understood by the issue commands, +Jira poller, and configuration tooling. For example: + +```yaml +tracker: + jira: + base_url: https://example.atlassian.net + project: PROJ1 + allowed_targets: + projects: [PROJ2] + poll: + enabled: true + query: 'statusCategory != Done ORDER BY updated DESC' +``` + +This selects Jira for issue commands, supplies one primary project and polling +query, and permits issue creation in the additional project. It works for a +single tracker, including Jira used from a repository hosted on GitHub or GitLab. +Keeping it avoids a configuration migration. + +The mapping accepts at most one provider block. It has no names for multiple +instances of a provider, no per-agent source bindings, and no source/target +entity-kind declarations. The example cannot express a triage agent reading +both native and Jira work items while a code agent reads only Jira and produces +native change proposals. Those concepts would have to be added to or alongside +`tracker`; the current shape is insufficient as the shared entity-execution +configuration model. It remains useful as a compatibility input. + +### Separate connections, sources, and harness bindings + +Named connections describe service instances, sources describe what to select, +and harness bindings connect those sources to an agent's needs. This supports +multiple providers and instances without putting repository-specific names in +reusable harnesses. It introduces more configuration concepts and requires a +compatibility adapter, but each concept has one role and can be shared across +agents. This is the selected option. + +## Decision + +Adopt named connections and entity sources as the binding between portable +agent harnesses and the shared discovery, dispatch, and run path. The +[entity-source configuration v1 contract](../normative/entity-source-configuration/v1/README.md) +defines the fields, defaults, layering, destination policy, and compatibility +translation. The sections below describe the target design; existing +deployments use `tracker` until their consumers migrate. + +### Configuration responsibilities + +The model separates four concepts: + +- A **connection** identifies a service instance, such as a Jira site or GitHub + Enterprise host. Repository configuration defines it under `connections`. +- An **entity source** identifies a connection, repository or project scope, and + selection query. Repository configuration defines it under `entity_sources`. +- A **slot** names an entity requirement of a harness. The harness's + `entity_kinds` map declares each slot's kind, such as `work_item` (an issue) + or `change_proposal` (a pull or merge request). +- A **binding** assigns a list of entity sources to a slot. Repository + configuration defines it under `agents[].entities`. + +Connections share the registry proposed for Vault in +[PR #9097](https://github.com/fullsend-ai/fullsend/pull/9097); a connection's +`kind` selects its service type. Sources do not have a `kind` field. Fullsend +checks that each source's provider and query support the consuming slot's kind. +Bindings select where an agent can look for entities; credentials and permission +checks remain separate. + +### Harness slots and defaults + +Only the `source` slot drives automatic discovery and scheduling. Its binding +list is a union of possible inputs: each run processes one source entity. +`target` gives the run its default destinations for new entities. Additional +slots give it other named scopes to query or use. Those slots do not start +polling loops, fetch every entity in advance, or create combinations of inputs. +Every slot accepts a list. When several output destinations are possible, the +operation must choose one explicitly; a list does not broadcast writes. + +Apply defaults after all configuration layers have been combined: + +- In the harness, the `source` kind defaults to `work_item`; the `target` kind + defaults to the effective source kind. Additional slots require a kind. +- In `agents[].entities`, `source` defaults to `[native]`; an omitted `target` + copies the effective source list. An explicit target, including an inherited + one, takes precedence. Additional slots require explicit nonempty bindings. +- Omitted slot values inherit. An explicit binding list replaces that slot's + inherited list. `source: []` disables source-based execution; `target: []` + removes the default output scope. + +Copying a source list to `target` copies names, not entities or kinds. For +example, a Jira work-item source cannot supply a `change_proposal` target; that +agent must bind its target to a compatible source, such as `[native]`. Unknown +slots and incompatible bindings fail validation. An old event-only harness +stays on its existing path until it is explicitly migrated; these defaults do +not opt it into entity execution. + +### Repository and harness examples + +The following YAML illustrates the target contract, not fields supported by the +current CLI. Repository configuration supplies connections, scopes, and bindings: + +```yaml +# .fullsend/config.yaml +connections: + jira1: + kind: jira + base_url: https://example.atlassian.net + api_url: https://api.atlassian.com + +entity_sources: + github: + # Customizes native selection when the configuration was cloned from GitHub. + query: 'is:open -label:blocked' + jira_work: + connection: jira1 + projects: [PROJ1] + query: 'statusCategory != Done' + discovery: true + jira_related: + connection: jira1 + projects: [PROJ1, PROJ2] + query: '' # No additional filter within these projects. + +agents: + - name: code + entities: + source: [jira_work] + target: [native] + related_work: [jira_related] + - name: triage + entities: + source: [native, jira_work] + # target is omitted, so it defaults to [native, jira_work]. +``` + +The same body can live in a preset installed as `.fullsend/config.base.yaml`, +or under `defaults.config`, `github.config`, `gitlab.config`, or a repository +entry's `config` in `repos.yaml` +([layered configuration](../guides/infrastructure/layered-config-reference.md)). +An overlay can replace one slot's list while inheriting the other slots. + +The corresponding code harness declares the kinds of its slots and its +predicate over the primary source entity: + +```yaml +# Harness YAML; other agent, policy, and runtime fields omitted. +entity_kinds: + source: work_item + target: change_proposal + related_work: work_item +entity_filters: + source: + github: 'is:open label:"needs-code" no:assignee' + gitlab: open + jira: 'statusCategory != Done' +trigger: >- + entity.kind == "work_item" && + entity.state == "open" && + "needs-code" in entity.labels +``` + +With the code binding above, this harness receives Jira work items, targets +native change proposals, and can query `related_work` when needed. `entity` in +CEL is the one source entity for the run. The example predicate works without +an event. After successful processing, the agent must remove the request signal +or use a predicate that checks whether it has already handled the work. A +predicate that reads event fields must first check `event != null`. Labels used +by CEL remain subject to the actor-authorization rules. + +Harness `entity_filters` maps slot names to provider-specific queries. Each +filter narrows the bound source's query and trusted scope; it cannot widen them. +Missing provider entries add no restriction. Only source filters participate in +automatic discovery and dispatch; other slot filters constrain explicit searches. +Filters do not inherit from source to target. They filter searches, not creation +destinations or lookups by an explicit entity identity. Matching a filter is +required for source-based execution, but the full harness CEL predicate must +also pass. + +For a work-item agent using the default kinds, the declaration can be: + +```yaml +# Harness YAML; source defaults to work_item and target defaults to source. +entity_kinds: {} +``` + +Together with the triage binding above, this means native and Jira work-item +inputs and the same native/Jira choices for new work-item targets. Creating in +Jira still needs an independent connection policy grant. If both binding keys +are omitted, they resolve to `source: [native]` and `target: [native]`. +Additional named slots require explicit bindings. The agent names in these +examples illustrate roles; they do not define a fixed inventory. + +### Resolving native sources + +`native` is an entity-source selector. Resolve it in three steps: + +1. The repository from which fullsend configuration was cloned selects the + provider: GitHub, GitLab, or Forgejo. The platform running fullsend does not + select it. +2. The corresponding reserved source name (`github`, `gitlab`, or `forgejo`) + uses the provider-default connection with the same name. It cannot use a + differently named connection. +3. That connection selects the instance. A trusted override of its `base_url` + can select another instance. For the origin provider, the reserved source's + repository path defaults to the clone path on that instance; its explicit + scope can select another path. Sources for other providers need explicit + repository scopes. + +Reserved connection names imply their provider kind; an explicit `kind` must +agree. For example, a GitHub.com configuration clone can use a GitHub Enterprise +instance as its native forge: + +```yaml +# Configuration cloned from https://github.com/example/project. +connections: + github: + kind: github + base_url: https://github.example.com +entity_sources: + github: + query: 'is:open -label:blocked' +agents: + - name: triage + entities: + source: [native] +``` + +Here `[native]` and `[github]` both select `example/project` on +`github.example.com`, including when fullsend runs on standalone Kubernetes or +in GitLab CI. Set `entity_sources.github.repositories` if the repository path +differs. The override selects an instance; access still requires credentials and +permissions for that instance. + +Provider source names can also be bound explicitly for external systems. A +GitHub-origin configuration can use `[gitlab]` when a GitLab connection and +repository scope are configured, without changing its native provider. The +contract includes a complete cross-provider example. A matching provider name +and `native` are aliases for the same effective source and do not duplicate +runs. Without a native-source override, selection includes all lifecycle states. +Defining `entity_sources.native` is forbidden. Additional names may be reserved +in future revisions, with validation of existing definitions. + +### Candidate selection and CEL evaluation + +Source queries and harness provider filters use the same language for each +provider: + +- Jira uses native JQL. Fullsend combines selection conditions with `OR` inside + the configured project scope and manages traversal order separately. +- GitHub uses the contract's subset of UI filters: state, labels, + author/assignee, milestone, issue type, missing metadata, dates, and PR + draft/branch fields, with Boolean combinations and exclusions. Full-text and + history/review search filters are outside the initial subset. Lifecycle + filters use `is:open` or `is:closed`; an empty query adds no restriction. +- GitLab initially uses `open`, `closed`, and `all` presets. For change + proposals, `closed` expands to the union of native `state=closed` and + `state=merged` results; work items use native `state=closed`. Adapter support + may expand without requiring the same query language on every provider. + +For each source binding, require both the repository's source query and the +harness filter, within the configured repository or project scope. Combine +those effective selections across enabled harnesses so discovery retrieves +candidates needed by any of them. A provider adapter may retrieve a broader +shared set if it can then check each harness's selection exactly. It must still +account for pagination, provider limits, and missed or incomplete results. + +Source membership means that an entity currently matches this effective +selection. Use the provider's semantics. Reuse fetched data only when a local +check can prove the same answer; otherwise batch the remaining membership +checks through the provider, including Jira's +[JQL match API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-jql-match-post). +Equivalent queries and repeated references to the same entity share work when +their credential and authorization scopes are compatible. Unknown membership +remains unresolved and retryable; it is not evidence that no work exists. + +For GitHub, prefer GraphQL advanced search and request fields based on the +enabled harnesses' compiled CEL expressions. Fetch inexpensive shared fields +first, then additional fields and history only where evaluation remains +unresolved. Include the authorship and coverage evidence needed for +authorization, even when CEL does not reference those fields directly. +[ADR 0147](0147-evaluate-entity-cel-over-selectively-acquired-data.md) governs +these partial-data checks. Selecting fewer fields does not remove search caps +or pagination requirements. + +An entity matching a provider query is only a candidate. Before execution, +fullsend must establish authorized invocation, a current source match, and a +true harness predicate over actor-filtered data. It must also prepare filtered +model context under [ADR 0141](0141-deterministic-filtered-entity-context-staging.md). +Provider-native fields may include changes that CEL is not allowed to use, so +query membership can select or suppress candidates but never proves an actor's +authority. This is the explicit change to ADR 0149's source-membership rule. + +### CI coordination and run modes + +Webhooks and polling supply candidates to the same fullsend selection and +authorization path. Each dispatch identifies the agent, target repository, +canonical source entity, and resolved configuration revision. A resolved plan +contains the connections, source queries, slot bindings, and harness requirements +for that revision. Source aliases are not entity identities. + +Fullsend decides whether an agent should act. CI provides trusted invocation, +capacity, job deadlines, execution serialization, and result publication. +Existing jobs may remain as execution wrappers during migration; migrated jobs +use fullsend's decisions rather than separate stage-routing conditions. + +Agents coordinate by changing entity state and recording completed work, which +other agents' predicates can observe. For example, triage can make a work item +eligible for a code agent, and a resulting change proposal can become eligible +for review. This introduces no workflow graph or automatic next-agent step. + +This binding model supplies the entities and eligibility checks needed by +[ADR 0144](0144-reuse-poll-and-entity-bound-run-processes.md). Its run modes remain: + +- `once`: one discovery cycle for `fullsend poll`, or one eligibility check and + at most one sandbox cycle for an entity-bound `fullsend run`, then exit. +- `poll`: repeat checks while waiting for work. An entity-bound run exits after + a finite idle period; the discovery process may stay alive until stopped. +- `timed`: repeat checks within a hard deadline, with the same idle exit for an + entity-bound run and enough budget reserved for each sandbox cycle it starts. + +An entity-bound run stays associated with one canonical entity and rechecks its +current source membership and predicate before each sandbox cycle. Reusing the +host process does not reuse the sandbox or model session. `fullsend poll` still +defaults to `once`. Bound runs default to `once` outside CI; the automatic CI +choice of `timed` also requires a usable deadline, sufficient initial-cycle +budget, permission for eventless checks, and working recurring discovery. + +Installation sets up recurring discovery for enabled source bindings. Before a +run can repeat checks without events, fullsend must verify that discovery is +operational for its current plan and can recover work after the run exits. An +installed workflow file alone is insufficient. Missing or stale discovery +evidence keeps the automatic `once` fallback or rejects an explicit request to +repeat eventless checks. A configuration change invalidates old readiness; an +existing process stops starting new cycles under the obsolete plan. ADR 0144's +pending-work, cancellation, and rediscovery rules continue to preserve unfinished +work. + +### Destinations and standalone commands + +Inside a run, new entity creation defaults to the `target` slot. Updates to an +existing entity use that entity's canonical origin; a native target does not +redirect comments on a Jira source issue. Connection-scoped +`allowed_targets` remains an independent policy for work-item creation. A source +binding or query match does not grant write access. The contract defines the +destination checks and explicit cross-project creation rules. No separate +`issue_commands` configuration block is introduced. + +Standalone issue commands select one named source with the proposed +`--entity-source ` flag, or explicitly select `native` after resolving the +origin's provider and configured connection/source overrides. The command +supplies the `work_item` kind; no harness or agent binding is needed. Infer the +project or repository only when the selected scope has one choice; otherwise +require explicit selection. For example, using `jira_work` from the repository +example: + +```sh +fullsend issues get --fullsend-dir .fullsend --entity-source jira_work --number 123 +fullsend issues get --fullsend-dir .fullsend --entity-source native --number 123 +``` + +The first command retrieves PROJ1-123 from Jira; the second retrieves issue 123 +from the effective native source, including any instance override. Operations +with an explicit entity identity use the connection and lookup scope without +applying discovery filters, so the first command also works for a closed issue. +Creation remains subject to independent permissions. These flags describe the +target CLI, not current functionality. Omitting the selector is an error unless +the compatibility adapter can preserve legacy command selection. An explicit +source overrides legacy defaults; combining `--entity-source` and `--tracker` +is an error. + +### Migration and activation + +Accept deprecated `tracker` mappings by translating them in memory, with +actionable warnings and no automatic file rewrite. Preserve connection settings, +queries, polling enablement, command defaults, credentials, and creation +permissions. The old syntax remains usable while its consumers migrate. + +Scripts that read raw tracker YAML must migrate to effective configuration before +new-only configurations are enabled. Syntax translation alone does not move an +agent from event reconstruction to entity-state execution. + +First make configuration loading and existing consumers understand both forms. +Then deliver the provider adapters, CI integration, and entity-capable harnesses. +Switch each agent/source binding once; its old and new dispatch paths must not +run in parallel. Activation requires the normalized-entity contract, a provider +query protocol with coverage guarantees, the new major authorization contract +required by ADR 0149, and model-context support for the provider and entity kind. +That authorization contract must account for native source-membership semantics. +This configuration contract does not replace those prerequisites. +Implementation is tracked under +[#8418](https://github.com/fullsend-ai/fullsend/issues/8418), with entity and +discovery contracts in [#8420](https://github.com/fullsend-ai/fullsend/issues/8420) +and [#8421](https://github.com/fullsend-ai/fullsend/issues/8421). + +## Forge scope + +The initial entity-adapter targets are GitHub and GitLab work items and change +proposals, plus Jira work items. A Jira project remains distinct from the code +repository where the agent works. Forgejo and additional kinds such as +conversations use the same binding model, but remain disabled until the required +entity, discovery, context, and execution support is available and validated. + +GitHub Actions and GitLab CI are the first CI integrations. Source providers are +independent of execution platforms; the same configuration-resolution rules +apply to standalone runtimes, including Kubernetes. Each combination activates +only when its adapters satisfy the relevant contracts. Existing event-only paths +remain available. + +## Consequences + +- Agents can process equivalent entities from several systems without knowing + deployment-specific connection names. +- Explicit connections, sources, and bindings add configuration concepts that + the single-tracker model did not require. +- Provider queries remain expressive, and shared discovery and selective reads + can reduce API work, subject to exact membership and coverage checks. +- Existing tracker configurations continue working, but raw-YAML consumers and + CI require a coordinated migration. +- Coverage readiness and adapter conformance become explicit activation + requirements for resident runs. diff --git a/docs/ADRs/0098-entity-first-harness-evaluation.md b/docs/ADRs/0098-entity-first-harness-evaluation.md index e2b084052b..c248a466e9 100644 --- a/docs/ADRs/0098-entity-first-harness-evaluation.md +++ b/docs/ADRs/0098-entity-first-harness-evaluation.md @@ -62,10 +62,14 @@ 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. -Living contract: -[Normalized entity v1](../normative/normalized-entity/v1/README.md) specifies -the logical `entity` value, coverage states, and partial-data invariants that -this ADR requires. +The [Normalized entity v1 contract](../normative/normalized-entity/v1/README.md) +specifies the logical `entity` value, coverage states, and partial-data +invariants that this ADR requires. + +[ADR 0079](0079-bind-entity-execution-through-named-sources.md) refines source +declarations into named, typed harness slots and repository-owned binding lists. +It also permits native provider membership checks as a separate selection gate; +actor-filtered CEL and model-context admission remain required. ## Context diff --git a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md index a7c9f3a44f..15b5e87bcc 100644 --- a/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md +++ b/docs/ADRs/0149-coalesce-entity-source-discovery-queries.md @@ -25,6 +25,13 @@ candidate and to let a harness act on it. poll and bound-run lifecycles. This ADR adds a local source check before each sandbox cycle for an entity-driven harness. +[ADR 0079](0079-bind-entity-execution-through-named-sources.md) partially +supersedes the local-reproduction and actor-filtered source-query requirements: +membership follows native provider semantics, with exact local checks where +possible and batched provider checks otherwise. Combined enumeration, current +membership, coverage, and retry remain required; actor-filtered harness CEL +and model-context admission are independent gates. + ## Context ADR 0098 lets harnesses declare entity sources, but allows sharing only when diff --git a/docs/architecture.md b/docs/architecture.md index 17391303f5..f386006832 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -606,6 +606,39 @@ The existing design principle is that [the repo is the coordinator](problems/age or explicit receipts to decide whether work has already been handled ([ADR 0098](ADRs/0098-entity-first-harness-evaluation.md), partially superseding [ADR 0063](ADRs/0063-polling-based-work-discovery.md)). +- Entity binding and CI integration (target state): harness `entity_kinds` maps + named slots to kinds, with source defaulting to work item and target to the + source kind. Repository `agents[].entities` maps those slots to lists of + scopes. Source defaults to `[native]`; omitted target copies the effective + source list, while additional slots require explicit bindings. + The configuration clone selects the native provider independently of the + runtime or CI platform. Its host and repository path supply defaults; + provider-default connections (`github`, `gitlab`, `forgejo`) can override the + instance, including GitHub.com to GitHub Enterprise. Reserved source names + default to those connections and can override queries and repository scopes. + The matching provider source and `native` resolve identically. Other provider names + require explicit external connections and scopes when bound. A source named + `native` is forbidden. Only source schedules work. + Harness `entity_filters` narrows each slot's source queries + by provider; primary selections combine for discovery and are checked before + full CEL admission. Other slot filters apply to explicit searches only. + GitHub source queries and harness filters share a bounded subset of native + UI metadata filters and Boolean combinations; unsupported syntax is rejected. + GitHub prefers GraphQL discovery with selective projections derived from + compiled CEL dependencies, progressively acquiring further decision and actor + evidence under ADR 0147. + The same resolved plan drives event + dispatch, broad polling, and bound-run checks, with CI providing trusted + invocation and execution rather than separate agent-routing decisions. + Installation verifies recurring discovery coverage for the effective plan + before resident eventless cycles can run. Target and additional slots make + typed scopes available to the run without implicit joins or broadcast writes. + Creation policy stays on connections independently of discovery; standalone + commands without context require explicit scope selection. Deprecated + `tracker` mappings translate in memory with warnings and preserved legacy + command defaults + ([ADR 0079](ADRs/0079-bind-entity-execution-through-named-sources.md), + [configuration contract](normative/entity-source-configuration/v1/)). - GitLab dispatch uses a native webhook fast-path for low-latency candidates and the cron-poller as the authoritative reconciliation backstop ([ADR 0125](ADRs/0125-gitlab-hybrid-webhook-poller-dispatch.md)). Native `merge_request_event` dispatch stays removed ([#7322](https://github.com/fullsend-ai/fullsend/issues/7322)). No external webhook bridge (see [ADR 0067](ADRs/0067-gitlab-cron-polling-event-dispatch.md) for the poller, credentials, and in-job gate). - Conversation participation: GitHub Discussions (and future chat systems) enter dispatch as resolved entities with `entity.kind: conversation`; when a @@ -711,11 +744,17 @@ The existing design principle is that [the repo is the coordinator](problems/age [ADR 0151](ADRs/0151-harness-human-role-minimums.md), [Authorization Contract v2](normative/authorization/v2/)). -- 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)). +- Entity-source discovery (target state): `fullsend poll` combines source + queries into one logical candidate search per source scope. Source membership + follows native provider semantics, with exact checks over already-fetched + data or batched provider checks; Jira accepts native JQL, GitHub accepts a + bounded subset of UI metadata filters and Boolean combinations, and GitLab + starts with open/closed/all state selections. A bound `run` rechecks current + membership before event-backed or eventless sandbox cycles. Provider-native + selection can reflect changes excluded from the actor-filtered CEL view; it + grants no authority and does not admit content to the model + ([ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md), partially + superseded by [ADR 0079](ADRs/0079-bind-entity-execution-through-named-sources.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). @@ -738,9 +777,13 @@ The existing design principle is that [the repo is the coordinator](problems/age [ADR 0147](ADRs/0147-evaluate-entity-cel-over-selectively-acquired-data.md) for selective acquisition and its authorization rules, and [ADR 0149](ADRs/0149-coalesce-entity-source-discovery-queries.md) - for query combination and local routing. The normative discovery protocol, - including query syntax, adapter mappings, and discovery coverage evidence, - remains open. + for query combination and local routing. Named source bindings and provider + query configuration are decided in + [ADR 0079](ADRs/0079-bind-entity-execution-through-named-sources.md) and the + [Entity-source configuration v1 contract](normative/entity-source-configuration/v1/README.md). + Provider-adapter mappings, pagination and consistency proofs, and coverage + evidence needed to establish complete discovery remain open for the discovery + protocol. - 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/normative/entity-source-configuration/v1/README.md b/docs/normative/entity-source-configuration/v1/README.md new file mode 100644 index 0000000000..7a4ee80b1d --- /dev/null +++ b/docs/normative/entity-source-configuration/v1/README.md @@ -0,0 +1,845 @@ +# Entity-source configuration v1 + +This contract defines the configuration binding chosen by +[ADR 0079](../../../ADRs/0079-bind-entity-execution-through-named-sources.md). +It applies to effective per-repository configuration, including managed +`repos.yaml` layers. MUST, SHOULD, and MAY express requirements for conforming +implementations. + +**Target contract, not implemented:** existing configuration continues to use +`tracker`. This document is not the complete discovery/query wire protocol, +normalized-entity specification, or authorization contract. Those contracts, +provider conformance, and context support are prerequisites for entity-driven +execution, as required by ADR 0079. + +The `v1` label versions this contract; it does not add a version field to +`config.yaml`. Configuration readers remain strict and older binaries may reject +the new fields. Deploy updated readers and managed-config consumers before +writing entity-source fields; mixed-version readers are not supported during +that cutover, and diagnostics MUST identify the unsupported configuration key. + +## Configuration shape + +Repository configuration binds named harness slots to entity-source scopes: + +```yaml +# .fullsend/config.yaml +connections: + jira1: + kind: jira + base_url: https://example.atlassian.net + api_url: https://api.atlassian.com + +entity_sources: + github: + # Customizes native selection when the configuration was cloned from GitHub. + query: 'is:open -label:blocked' + jira_work: + connection: jira1 + projects: [PROJ1] + query: 'statusCategory != Done' + discovery: true + jira_related: + connection: jira1 + projects: [PROJ1, PROJ2] + query: '' # No additional filter within these projects. + +agents: + - name: code + entities: + source: [jira_work] + target: [native] + related_work: [jira_related] + - name: triage + entities: + source: [native, jira_work] + # target is omitted, so it defaults to [native, jira_work]. +``` + +The example code harness declares +`entity_kinds: {source: work_item, target: change_proposal, related_work: work_item}`. +A triage harness can declare `entity_kinds: {}` to use the default work-item +source and target kinds. Agent names are illustrative, not a fixed inventory. +Concrete connection names and repository/project scopes belong to repository +configuration. The `entities` map is configuration, not a map of already-fetched +entity values exposed to CEL. + +Unknown fields, unknown names, incompatible provider/kind pairs, and empty +required scope lists MUST fail validation. Unsupported capabilities cannot be +treated as empty discovery results. Compatibility placeholders for existing +incomplete tracker declarations are limited to the migration rules below. + +### Connections + +`connections` is a map of names to service-specific settings. Each ordinary +entry MUST specify `kind`; arbitrary names do not imply a provider. The reserved +names `github`, `gitlab`, and `forgejo` are provider-default connections: their +kind is implied, and an explicit `kind` MUST agree. Initial enabled entity +connection kinds are `github`, `gitlab`, and `jira`; reserving `forgejo` does not +enable an unsupported adapter. Non-entity connection kinds, +such as Vault under [PR #9097](https://github.com/fullsend-ai/fullsend/pull/9097), +share the registry but MUST NOT be accepted by an entity source. + +Record the repository from which this invocation's fullsend configuration was +cloned as trusted origin metadata: provider, host, and canonical repository +identity/path. This selects the native provider and supplies connection defaults; +it does not lock native entities to the clone host. For the origin's provider, +synthesize its named connection when absent, using the origin host. A declared +connection of that name replaces the default and MAY set a different `base_url`. +If it omits `base_url`, use the origin host; never fill it from the CI platform. +Other provider-default connections require an explicit endpoint when used. +Connection kinds and endpoints determine where credentials are sent. Only +configuration layers designated trusted by the repository's configuration +policy may set or change them; event data, harnesses, and untrusted overlays +MUST NOT. At minimum, trusted layers include managed `repos.yaml` values and +`.fullsend/` configuration selected by the workflow: for a pull request, the +PR target branch head, as described by +[ADR 0033](../../../ADRs/0033-per-repo-installation-mode.md). The PR source +branch's config, harness content, and event data cannot designate themselves +as trusted endpoint overrides. Credential bindings MUST be provisioned for the +canonical provider endpoint and tenant, and the resolver MUST refuse to send a +credential to any other endpoint even when the connection name and kind match. +Changing an endpoint requires a separately provisioned credential binding for +that host; the old host's credential, grants, and cached evidence do not +transfer. + +For example, a GitHub.com clone selects the `github` provider. Setting +`connections.github.base_url` to a GitHub Enterprise URL makes that instance +the default GitHub connection used by native entities. The same rule applies to +GitLab and Forgejo. The execution platform and imported layer/harness origins do +not change the selected provider, but trusted configuration layers can change the +provider-default connection's instance. Missing origin prevents native-provider +inference; it MUST NOT be guessed from the runner or current Git remote. There +is no separate fixed `repository` connection. Entity `native` is distinct from +the Vault proposal's `native` secret-source selector. + +Forge connections identify their provider instance through `base_url`; +Jira uses `base_url` for the site and optional `api_url` for its API +gateway, preserving the current Jira gateway default. Provider validation MUST +reject endpoints containing embedded credentials. An inherited issue-creation +policy MUST NOT authorize a different instance unless trusted configuration +explicitly rebinds that policy to the new instance. + +Connections identify where to connect, not an authorization principal. Host +credential resolution MUST bind each connection to a provisioned credential +scope for the exact canonical endpoint and tenant, and keep discovery +credentials separate from harness run identities. A connection name or kind +alone MUST NOT select or reuse a credential for another host. Changing an +endpoint invalidates the old binding until a credential for the new host is +separately provisioned. +Legacy translated connections retain existing credential lookup. Credentials +MUST NOT be written into this configuration or sent in dispatch descriptors. +Additional connections require independently provisioned host bindings; they +MUST NOT inherit credentials merely because their `kind` matches. Concrete +credential-reference formats remain part of the provider credential contracts. + +### Sources and queries + +`entity_sources` is a map of named entries. Each source MUST resolve a +connection and provider-valid `query`; it MUST NOT declare a `kind`. If a source +omits `connection`, use the connection with the same name as the source and +require that connection to exist when the source is active. An unbound reserved +preset may omit its connection as described below. Reserved provider entries +follow the stricter same-name rule below. The +adapter's supported kinds and the query's selection are checked against each +consuming harness slot's kind. The same source may serve differently typed slots. +The planner enumerates only the kinds needed by active primary-source bindings. +An active forge source's `repositories` list scopes it to explicit canonical +repository paths. If omitted, the scope defaults to the clone's repository path +when the source resolves to the configuration origin provider's provider-default +connection. This applies to reserved and ordinary source names, including when +that connection uses an explicit `base_url` for another instance. All other +active forge sources, including those using another provider-default or named +connection, MUST specify `repositories`. An unbound reserved entry for another +provider is an inert preset and may omit its connection and repository scope +until it is bound. An explicit list selects those paths; it does not claim they +are the same canonical repository as the clone. A Jira source MUST specify a +nonempty `projects` list. +Source scopes MUST resolve to canonical provider identities before use. +Configuration authorizes a source scope, not an arbitrary target code +repository. + +GitHub accepts the bounded UI filter subset defined below; an explicitly empty +query adds no filter beyond the scope and kind guards. GitLab initially accepts +`open`, `closed`, and `all` presets for `work_item` and `change_proposal`. These +are fullsend lifecycle predicates translated into native API filters. For change +proposals, `closed` means not open and expands to the union of native +`state=closed` and `state=merged` results; these are separate GitLab API states. +CEL can distinguish merged from closed-unmerged entities. Jira work-item sources +accept native JQL; an explicitly empty string +adds no filter beyond the project guard. Their project guard is independent of +the query: +`OR` terms MUST NOT widen it. When scopes overlap, adapters plan per canonical +provider/tenant/project-or-repository/kind/credential scope, so each scope has +one combined logical enumeration under ADR 0149, not one search per alias. + +GitLab's presets are an initial fullsend subset, not a claim that the provider +supports only lifecycle filters. Its [REST issue filters](https://docs.gitlab.com/api/issues/#list-all-project-issues) +also include labels, assignees, and dates. The +[merge request API](https://docs.gitlab.com/api/merge_requests/#list-project-merge-requests) +exposes `closed` and `merged` as separate `state` values; the fullsend `closed` +preset therefore combines both native queries. The +[GLQL operators](https://docs.gitlab.com/user/glql/#operators) support conjunction +and some same-field alternatives through `in`, but not arbitrary disjunctions +of whole queries. GitHub supports +[Boolean and nested issue filters](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/filtering-and-searching-issues-and-pull-requests#building-advanced-filters-for-issues) +and an advanced-search option in its +[search API](https://docs.github.com/en/rest/search/search#search-issues-and-pull-requests). +Query support requires adapter conformance for the deployed provider +version, exact membership, and complete discovery under provider limits. + +For Jira, combine parenthesized selection predicates and use one adapter-owned +traversal order. Individual `ORDER BY` clauses do not alter set membership and +MUST be separated before combination. Any batching or partitioning required by +provider limits remains part of that combined logical enumeration and MUST +preserve coverage. Unsupported queries or capabilities MUST fail explicitly; +they cannot silently become unrestricted, disappear from the plan, or cause a full +search per agent. Time-dependent queries require periodic rediscovery even +without entity updates. Provider-side filter changes and other dependencies +must likewise be reconciled rather than assumed immutable. + +Native provider semantics determine membership. Local evaluation MAY avoid a +provider membership request only when it proves the same result from current, +sufficiently complete data under the same provider scope, credential identity, +and relevant query context. The adapter MUST NOT substitute the actor-filtered +CEL view. For example, `currentUser()` cannot be reinterpreted using the agent's +run identity. Batch unresolved membership checks across entities and distinct +queries in one credential scope. Query errors or uncertain freshness produce +an unresolved candidate with retry/rediscovery, never a false result. A proven +false harness predicate MAY avoid membership reads for that harness; a true +predicate cannot bypass membership. A prior discovery result does not prove +membership at a later sandbox cycle. + +`discovery` is a boolean, defaulting to `true`, that permits broad enumeration +and eventless rechecks when this scope is bound to the primary `source` slot. +Binding it only to another slot adds no scheduled work. It does not authorize execution or +set the clock frequency. `false` permits event-backed candidates subject to +current membership and admission, but excludes this source from broad polling +and eventless execution. Effective platform eligibility and operational polling +coverage remain required even when it is `true`. + +### Native sources and reserved names + +`native` is an entity binding selector, not a definable source name. +`entity_sources.native` MUST fail validation in every configuration layer. +Resolve `native` in order: the configuration origin selects the provider's +reserved source name (`github`, `gitlab`, or `forgejo`); that source selects its +connection; the effective connection selects the instance. Resolve the source's +repository scope and consuming slot's kind on that instance. The clone host and +path are defaults, not immutable native destinations. Execution platform never +selects the provider or overrides these configured values. + +The reserved provider names customize native selection. A declared reserved +entry MUST contain a provider-valid `query`. The reserved source name is also +its connection name: `entity_sources.github` uses `connections.github`, +`entity_sources.gitlab` uses `connections.gitlab`, and `entity_sources.forgejo` +uses `connections.forgejo`. The source may omit `connection`, which defaults to +that same name; if specified, `connection` MUST equal the reserved source name. +A reserved source MUST NOT use a differently named connection, even when its +kind matches. To select a different instance for the native provider, configure +the same-named provider-default connection's `base_url`. If the origin's +matching source entry is absent, synthesize it on that provider-default +connection with an all-state query and `discovery: true`: an empty query for +GitHub, or `all` for GitLab. If present, its `query` and optional `discovery` +override those defaults under ordinary whole-entry layering. Its repository +scope defaults to the clone's path on the same-named connection, including when +that connection's endpoint is overridden. The same repository-path default +applies to any active forge source that resolves to this connection; an explicit +`repositories` list selects another path. Other named sources can select +additional instances or scopes. + +Provider names MAY also appear explicitly in `agents[].entities` lists and in +standalone source selection. For the origin's provider, `[github]` (for example) +and `[native]` resolve to the same customized source even if its definition was +omitted. For a different provider, such as `[gitlab]` with a GitHub origin, an +explicit binding is allowed when the same-named provider-default connection and +an explicit repository scope are configured. Do not infer that external +connection from the execution platform. Such a source does not change native +resolution or acquire credentials or creation grants. + +An unbound reserved entry for another provider may contain just its query and +discovery settings so a preset can customize several native providers. It does +not activate that provider. Binding it explicitly on a nonmatching origin +requires the missing external connection and scope to be supplied; otherwise +validation fails. Reservation alone does not enable a Forgejo adapter: provider, +kind, query, and admission support are still required before a source is used. +Additional names may be reserved in future contract revisions; adding a +reservation must diagnose existing incompatible definitions rather than silently +reinterpret them. + +```yaml +# Configuration cloned from GitHub.com; runtime may be Kubernetes or GitLab CI. +# Native entities use the configured GitHub Enterprise instance. +connections: + github: + kind: github + base_url: https://github.example.com + gitlab: + kind: gitlab + base_url: https://gitlab.example.com +entity_sources: + github: + query: 'is:open -label:blocked' + gitlab: + repositories: [example/related-work] + query: open +agents: + - name: triage + entities: + source: [native, gitlab] + target: [github] +``` + +Here `native` and `github` select `example/project` on `github.example.com`, +even though the configuration was cloned from GitHub.com. The `github` source +omits both `connection` and `repositories`: the same-named connection is used, +and the clone's owner/repository path carries over to that connection's +enterprise endpoint. `gitlab` selects the configured external scope. +Binding both `native` and `github` +does not duplicate discovery or executions. Native customization applies to all +uses of that native source, including omitted source bindings and targets that +inherit them; query filters still do not constrain creation or explicit identity +operations. Source and target kind defaults are unchanged. + +### GitHub query subset + +GitHub source `query` values and harness `entity_filters..github` accept +the same subset of native issue/PR search syntax. The initial supported +qualifiers are: + +- Lifecycle: `is:open`, `is:closed`, and their `state:` equivalents; for change + proposals, also `is:merged` and `is:unmerged`. +- Metadata: `label:`, `author:`, `assignee:`, and `milestone:` with literal + values; `type:` for issue types on work items. GitHub's `type:issue` and + `type:pr` aliases are kind assertions, like `is:issue` and `is:pr`. +- Missing metadata: `no:label`, `no:assignee`, and `no:milestone`. +- Dates: `created:`, `updated:`, and `closed:`, plus `merged:` for change + proposals. Accept absolute dates or timestamps, comparisons, and inclusive + ranges using GitHub's [date syntax](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates). +- Change-proposal fields: `draft:true`, `draft:false`, `base:`, and `head:`. + +Use native [qualifier semantics](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests), +including quoted values, case handling, and branch matching. Accept explicit +`AND`, whitespace conjunction, `OR`, and parentheses with GitHub's precedence. +Accept `-` exclusion of a single supported qualifier where GitHub permits it; +`-no:...` and negation of groups are not supported. Positive label comma lists +are native alternatives; repeated label terms are conjunctive. Express +exclusions with individual terms, such as `-label:blocked -label:wip`. +Use `is:open` or `is:closed` for lifecycle selection and `query: ''` for no +additional restriction. Bare `open`, `closed`, and `all` are unsupported free +text, not query shorthands. The adapter always retains the scope and kind guards. + +For example, a GitHub repository can provide a named source while a portable +harness further narrows it: + +```yaml +# .fullsend/config.yaml on a GitHub repository +entity_sources: + actionable_work: + connection: github + query: 'is:open (label:bug OR label:enhancement) -label:blocked' +agents: + - name: code + entities: + source: [actionable_work] + target: [native] +``` + +```yaml +# Harness YAML; other fields omitted. +entity_kinds: + source: work_item + target: change_proposal +entity_filters: + source: + github: 'is:open label:"needs-code" no:assignee' +``` + +The effective query requires both expressions inside the configured repository +and work-item guard. `actionable_work` omits `repositories` because it resolves +to the origin's provider-default `github` connection, so its scope is the +configuration repository. A review harness could instead use a +change-proposal source with `is:open draft:false base:main -label:blocked`. + +Parse and validate this subset before provider submission; do not pass unknown +syntax through as free text. Reject bare text, `in:`, general `NOT`, relative +dates, viewer-relative identities such as `@me`, and qualifiers outside the +list above. This excludes review/CI status, involvement or comment-history +filters, interaction counts, and project-board membership in v1. Richer agent +conditions remain in CEL until their native query membership and acquisition +contracts are supported. Sorting and ranking are adapter-owned; user `sort:` +is not accepted. Reject `repo:`, `org:`, and `user:` with a diagnostic pointing +to source scope configuration. Kind assertions MUST agree with the slot and +cannot replace the adapter's independent kind guard. + +Combine parsed expressions, then serialize with explicit grouping and escaped +values; never concatenate unchecked strings. Preserve every condition when +provider query-length or nesting limits require partitioning or broader shared +enumeration. Exact local checks use current provider-view metadata, including +complete relevant collections, and follow the native membership rules above. +Unknown membership remains unresolved; negative filters cannot treat unfetched +labels, assignees, or other metadata as absent. + +### Harness slots and repository bindings + +`entity_kinds` is a harness map from slot names to single normalized kind names. +The reserved slots are `source` and `target`; other names declare additional +requirements. Compose explicit harness declarations first, preserving which +keys were omitted, then apply these defaults: + +- Missing `source` means `work_item`. +- Missing `target` means the effective `source` kind. +- Every additional slot must explicitly name its kind. + +An explicit inherited target kind remains explicit when a child changes the +source kind. A defaulted target follows the final source kind. These defaults +apply to the entity-capable contract; they MUST NOT silently activate an old +event-only harness. `entity_kinds: {}` is an explicit declaration of the default +slots. A legacy harness without the declaration stays on its compatibility +path until coordinated entity-mode cutover. + +`agents[].entities` maps the same slot names to lists of scope names. Every +value MUST be a list, including when it contains one name. Every referenced +scope MUST exist and support the slot's effective kind. Compose bindings by +slot name: omission inherits, and an explicit list replaces that slot's list +rather than extending it. After composition, a missing `source` becomes +`[native]`; a missing `target` copies the effective source list, including an +explicit empty list. Explicit target lists, including inherited lists, win. +Copy scope names, not resolved entities or their kinds: resolve each copied +name against the target kind and reject incompatibility. For example, a Jira +source with a change-proposal target needs an explicit `target: [native]`. +Additional harness slots require explicit, nonempty lists, possibly inherited +from an explicit configuration layer. Unknown slot keys and missing required +bindings are configuration errors. Do not materialize default target lists in +parent layers before child source overrides have been applied. + +An explicit `source: []` disables source-based scheduling, including +source-backed event candidates, without restoring native defaults or inventing +an event-only fallback. An explicit `target: []` provides no default output +scopes; operations needing that slot fail until a valid target is bound. +Use ordinary agent enablement to disable an agent completely. + +Resolve `native` and the reserved provider names using the native-source rules +above, after configuration composition. The same source can resolve differently +for a work-item slot and a change-proposal slot. Missing native origin or +provider/kind support MUST be diagnosed, not replaced by an external connection +or treated as empty. External sources always require explicit bindings. + +Only the `source` slot drives automatic candidate discovery, event routing, +and scheduling. Its list is a union of alternatives; one run binds one +canonical source entity, exposed as `entity` to the existing CEL contract. +`target` and additional slots provide typed scopes available to the run. They +MUST NOT create automatic joins, Cartesian products, eager acquisition, or +independent polling/dispatch merely by being bound. Reading from such a scope +still requires the appropriate acquisition, actor-admission, and context +filtering contracts. A configured scope is not admitted model context. + +Every slot accepts multiple scopes. Output lists are choices, not automatic +broadcast. An operation identifies the slot and, when necessary, a specific +scope and repository/project within it. A single unambiguous destination may +be selected automatically; otherwise the operation MUST require an explicit +selection rather than use list order. Each selected destination must support +the slot's kind and pass independent run and creation policy checks. + +Deduplicate primary-source candidates by target code repository, agent, and +canonical entity identity, independently of aliases. Do not combine evidence +from incompatible credential/admission scopes to manufacture a successful +check. Matching several source aliases does not create several executions. +Replies and status updates on an existing entity use its canonical origin; +`target: [native]` does not redirect a Jira source issue's update to a forge +issue with the same display number. + +### Harness provider filters + +Harnesses MAY declare `entity_filters`, a map from effective entity slot names +to maps of provider kinds and query strings. Filters do not change the shape or +defaults of `entity_kinds`. For example: + +```yaml +entity_kinds: + source: work_item + target: change_proposal +entity_filters: + source: + github: 'is:open label:"needs-code" no:assignee' + gitlab: open + jira: 'statusCategory != Done' +trigger: >- + entity.state == "open" && + "needs-code" in entity.labels +``` + +Choose the provider entry from each bound connection's kind, including the +resolved native provider, not its connection alias. Query values use the same +provider-specific language and kind validation as source queries. Unknown +slots, unknown provider keys, and explicitly unsupported filters MUST fail +validation. An omitted provider entry adds no restriction. Compose filters by +slot and provider: omission inherits, while an explicit query replaces that +slot/provider's inherited query. Use an empty query for GitHub or Jira, or +`all` for GitLab, to explicitly remove an inherited restriction. Target filters +MUST NOT default to source filters, even when kinds and bindings do. + +For each binding, the effective selection is the intersection of the trusted +source scope, source query, and harness filter for that provider. The source's +scope and query remain enforced; a harness cannot broaden either. Combine the +effective selections of enabled primary-source bindings with logical OR in each +compatible discovery scope, deduplicating equivalent expressions. This is a +logical union requirement, not a requirement to serialize a native OR operator. +If the provider cannot express the union, the adapter MAY enumerate a shared +superset within the trusted scope and check the effective selections exactly. +It MUST preserve coverage, provider limits, and retry semantics; it MUST NOT +drop a filter or fall back to separate full searches per harness. When no +conforming plan is possible, report an unsupported combination. + +For `source`, the filter is a required selection condition, not an optional +performance hint. It applies to polling, event-backed candidates, and every +further bound-run cycle. Match the combined source query and harness filter +using native semantics, the exact local fast path, and batched unresolved +provider checks described above. Cheap filter mismatches can skip full CEL +evaluation; execution still requires both a current selection match and full +actor-filtered harness CEL, along with independent authorization and context +admission. A broader discovery result alone proves neither condition. + +Only `source` drives automatic discovery and scheduling. Filters on `target` +or additional named slots constrain explicit searches in those scopes without +adding background enumeration or eager acquisition. As with source queries, +they do not restrict creation destinations or explicit identity operations. +Standalone issue commands do not load a harness's filters. + +### GitHub search and selective acquisition + +The GitHub adapter SHOULD use GraphQL where it can combine discovery with +selective field acquisition. GitHub documents +[advanced search through GraphQL](https://github.blog/changelog/2025-03-06-github-issues-projects-api-support-for-issues-advanced-search-and-more/) +using `search(type: ISSUE_ADVANCED, query: ...)`; the current +[search schema](https://docs.github.com/en/graphql/reference/search) exposes that +type and typed issue/pull-request results. Validate the supported mode for the +deployed host. An unsupported mode MUST NOT silently fall back to interpreting +the same Boolean text with legacy search semantics. Preserve the per-kind +discovery scopes, using `is:issue` or `is:pr` explicitly. Search remains lexical +and set-based; semantic relevance and top-N ranking cannot establish coverage. + +Build two coordinated plans: a candidate-selection query from the effective +source/filter expressions, and a field-acquisition plan from enabled harness +CEL dependencies under [ADR 0147](../../../ADRs/0147-evaluate-entity-cel-over-selectively-acquired-data.md). +Mapping CEL field dependencies to GraphQL projections does not authorize +translating arbitrary actor-filtered CEL conditions into provider search terms. +The initial projection SHOULD share identity, scope, membership-routing facts, +and inexpensive decision-relevant fields across compatible harnesses. After +selection and partial evaluation eliminate harnesses or candidates, batch +further node reads for the dependencies still needed. Do not eagerly project +the union of every harness's complete history requirements onto every result. +Share acquired facts only across compatible credential and admission scopes. + +Projections MUST include or subsequently acquire the provenance, authorization +evidence, and coverage needed to establish a decision, even when those fields +are not named directly in CEL. Derived fields and provider aggregates cannot +substitute for the actor-filtered view. Page nested connections as necessary; +a partial label, comment, review, or timeline page is not a complete collection. +Apply ADR 0147's proven true/false versus unresolved semantics throughout. + +The search API exposes at most 1,000 results for one search, independently of +the selected fields. Partition or reconcile discovery as required by ADR 0149; +reaching that cap cannot establish coverage. GraphQL +[resource limits and partial errors](https://docs.github.com/en/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api) +also apply: selecting fewer fields can reduce work, but does not by itself +guarantee fewer billed points or complete results. Required data affected by an +error remains unresolved, never absent. Full model-context acquisition remains +a separate admitted step after selection and predicate evaluation. + +### Destination policy and issue commands + +There is no `issue_commands` configuration block. Inside an agent run, new +entity creation defaults to the `target` slot; an operation may explicitly +select another declared slot and a destination in its list. Existing-entity +operations use the resolved entity's origin. A slot binding selects a provider, +kind, and scope; it does not grant credentials or mutation authority. Source +queries are neither creation templates nor authorization policies. A new entity +need not already satisfy a discovery query before it can be created. + +`connections..allowed_targets` carries the independent work-item creation +policy formerly under `tracker`: GitHub `orgs`/`repos`, GitLab `groups`/`repos`, +and Jira `projects`. Omission grants no additional destinations. The target +code repository remains implicitly allowed on its own forge and host, subject +to actual run permissions. For Jira, allowed creation projects must be listed +explicitly; the translator includes the legacy primary project to preserve its +implicit grant. Binding a Jira project as an input or output does not itself +grant creation rights there. Policies replace as whole values; grants cannot +move to another instance merely by reusing a connection alias. + +`allowed_targets` is part of trusted repository configuration and uses the +same workflow-selected revision as connection settings. On pull-request runs, +that is the PR target branch head; configuration changes present only on the PR +source branch do not change creation policy. This is the existing repository +configuration trust boundary; it requires no separate per-field trust or layer +mechanism. Untrusted overlays, harness content, and event data MUST NOT add or +replace creation grants or remove an inherited restriction. Legacy `tracker` +`allowed_targets` grants follow the same rule before translation. + +Lookup scope supplies the ordinary destination choices. An explicit work-item +creation destination outside that lookup scope is allowed only when the +connection's separate `allowed_targets` policy covers it, the operation selects +a compatible bound slot/connection, and run permissions allow it. This retains +legacy explicit cross-project issue creation without turning a discovery query +into a write grant. Change-proposal creation retains the execution repository +boundary and the existing forge/run permission checks. + +### Standalone issue commands + +Without agent/entity context, `fullsend issues` commands select one scope using +`--entity-source `, where the name is an effective `entity_sources` entry, +the reserved `native` selector, or its matching provider name. This is target +CLI syntax, not an implemented +flag. The command supplies the `work_item` kind, so the selected source MUST +support that kind. Resolve configuration through the normal layers, selected +with `--fullsend-dir` where needed; no agent or harness is required. The selector +is singular: standalone operations MUST NOT fan out across sources or inspect +an agent's `entities` bindings to choose a default. + +For the configuration above: + +```sh +# Resolve PROJ1-123 through jira1; jira_work has only one project. +fullsend issues get --fullsend-dir .fullsend --entity-source jira_work --number 123 + +# Select a project explicitly when the source contains several projects. +fullsend issues get --fullsend-dir .fullsend --entity-source jira_related --project PROJ2 --number 123 + +# Resolve issue 123 in the effective native source, including connection overrides. +fullsend issues get --fullsend-dir .fullsend --entity-source native --number 123 +``` + +Infer an omitted `--project` only when the selected scope identifies exactly one +project or repository. Otherwise require an explicit project/repository, or an +unambiguous entity identity where the command accepts one. Resolve `native` +only when its provider and effective connection/scope can be resolved from the +configuration origin plus overrides; missing required context MUST produce an +error. Validate explicit entity origins against the selected +connection and lookup scope. Explicit creation destinations remain subject to +the independent creation policy above, including its cross-project allowance. + +An explicit identity operation such as `get`, `post-comment`, or `link` MUST NOT +run the discovery query or require the identified entity to match it. For +example, `jira_work` can retrieve a closed PROJ1 issue by number even though its +discovery query excludes completed work. Queries select candidates for discovery; +they do not prohibit explicit scoped reads or updates. Authentication and +mutation checks still apply, and `create` still requires creation permission. + +Without an explicit source, standalone commands MUST NOT silently select the +first configured source, the first agent, or a native default. The compatibility +adapter alone preserves existing tracker command selection, including the old +`--tracker` selector and default connection/project behavior, with deprecation +warnings. An explicit `--entity-source` overrides legacy command defaults; +supplying it together with `--tracker` MUST fail as conflicting selectors. With +neither a selected source nor a legacy selection, fail with a diagnostic that +requests `--entity-source`. No new repository-wide command-default block is +introduced. Removing legacy tracker configuration therefore requires updating +standalone invocations; agent-context operations obtain their slots from the +plan. + +## Layering and legacy translation + +Named `connections` and `entity_sources` entries replace whole entries by name; +they do not deep-merge. Provider-default connections and reserved provider source +overrides use the same whole-entry replacement. After composition, use the +recorded configuration origin to fill omitted native defaults, then resolve the +effective connection and source. Explicit connection endpoints and repository +scopes win over clone-derived defaults. Omitted maps +inherit; empty maps do not delete unrelated +inherited names. Harness `entity_kinds` and agent `entities` compose by slot +name, with defaults applied only after composition. Each explicit binding list +replaces the inherited list for that slot. Creation allowlists MUST NOT be +unioned across layers. + +Resolve legacy `tracker` using its existing whole-block replacement semantics +across layers, then translate the effective result into a canonical fallback. +Explicit new entries override their translated equivalents, even if legacy +syntax occurs in a later layer; diagnostics MUST identify shadowed settings. +A new explicit slot binding replaces that translated slot's entire list. This +allows mixed-layer migration without changing legacy-only behavior or retaining +write grants from a replaced tracker provider. + +For every present provider block, the translator creates the compatibility +connection `legacy_tracker` using the legacy endpoint and credential-resolution +rules. It attaches that block's `allowed_targets` to this connection, including +for GitHub and GitLab blocks that contain only creation policy; they MUST NOT be +copied to another provider-default connection. A provider-only block still does +not create a discovery scope. Explicit entries with the name `legacy_tracker` +replace the corresponding generated entries and undergo ordinary validation; +independent new names coexist. Effective-config inspection MUST distinguish translated entries, explicit +replacements, and compatibility-only command defaults. + +Translate existing tracker configuration without guessing missing values: + +- Preserve provider, endpoint, host credential binding, and effective command + default connection/project. Jira's primary project becomes the lookup + scope's `projects` element; native JQL and its legacy default are retained. +- Preserve `poll.enabled`: true permits discovery, while false or omission + does not. A provider-only declaration creates no usable discovery scope; + incomplete Jira declarations retain their existing use-time failure. +- Copy `allowed_targets` to the connection policy, including Jira's implicit + primary-project grant and the existing native-repository grant. Do not add + fresh-install defaults to an existing installation's permissions. +- Legacy drivers and commands consume this resolved configuration through an + internal compatibility projection, including command defaults where there is + no agent context. Translation alone MUST NOT add entity declarations, change + poll checkpoints, switch predicate semantics, or replay historical work. +- At coordinated entity-mode cutover, established external routes become + explicit `entities.source` bindings and established output destinations + become typed slot bindings. Native defaults MUST NOT silently replace them. + An unmappable route or destination prevents that binding's cutover and keeps + its legacy path with a diagnostic. + +Runtime loading and managed installation MUST share normalization and +validation. Warn once per loaded legacy definition per process, with its +location and replacement guidance, on diagnostics rather than machine-readable +stdout. Reads MUST NOT rewrite source files. Raw-YAML consumers must migrate +to effective configuration or a host-generated compatibility projection before +new-only configuration is enabled; the projection is never a second authority +merged back into configuration. + +No release or removal date is set for `tracker` support. Keep the +compatibility translator until every supported reader, command, poller, +installer, and raw-YAML consumer has migrated and no supported execution +path depends on the legacy form. Removing it requires a later ADR and a +published major-release migration window. Until then, deprecation +warnings do not disable the old configuration. + +## Execution readiness and cutover + +The resolved execution plan records the agent/harness revision, trusted target +repository identity, configuration-origin provider/host/repository identity, +effective connection endpoints and canonical source repositories after overrides, +named slot kinds and binding lists, query/configuration revision, +credential-scope identity, and platform eligibility. Dispatch conveys canonical +entity identity and optional verified event context with a reference to this +trusted plan; event payloads MUST NOT supply connection endpoints, credentials, +or self-asserted eligibility. The receiving run revalidates the plan and current +admission before creating a sandbox. A discovery alias is not an execution lock. + +Installers reconcile recurring discovery only for enabled effective `source` +bindings; target and auxiliary lists do not add scheduled work. For GitHub Actions +execution this is a managed workflow; for GitLab CI execution it is a managed +pipeline schedule/job. These are execution adapters, not native-provider +selection rules. A standalone scheduler uses the same readiness and coverage +contract. Each invokes the shared fullsend discovery path, +with the proper trusted credential scope, rather than reproducing agent routing +in workflow expressions. Event-driven GitHub Actions execution retains synchronous +dispatch correlation; GitLab CI uses its protected-default-branch delivery model. +Concurrency and result publication conform to ADR 0144, including preservation +of pending event-backed work and the latest selected cycle's result. + +Resident eventless execution requires evidence that the discovery mechanism is +enabled, compatible, and making progress for the same effective plan, including +durable retry or reconciliation for uncovered work. A workflow filename or a +historical successful job alone is insufficient. The execution adapter MUST +define a bounded readiness age relative to its configured schedule, retry and +cycle budget, and store/check that evidence in trusted per-repository state. +No new centralized scheduler is required. Missing or stale evidence gives +automatic once behavior; an explicit resident request fails with a diagnostic. + +Before each further cycle, verify current eligibility and plan readiness. A +changed configuration origin, binding, policy, credential scope, or execution +contract invalidates old readiness and cached membership. The resident process MUST stop admitting +new cycles and relinquish its claim through ADR 0144's pending-work protocol; +an already admitted sandbox retains the existing cancellation policy. New +invocations resolve the updated plan. Coverage invalidation MUST trigger a scan +for newly eligible work, not inherit a watermark that could skip it. + +Activate by agent/source binding after its contracts, adapters, context handling, +and harness support are deployed. For that binding, only one of legacy event +reconstruction and entity-driven admission may own dispatch at a time. Keep +legacy paths for unmigrated agents. Generic execution jobs or existing stage +wrappers may deliver admitted work, but all migrated bindings use the same +fullsend admission logic. Job deadlines and lifecycle choices use ADR 0144; +source queries do not select lifecycle or define an agent sequence. + +## Conformance requirements + +Implementations MUST cover at least these observable cases: + +- The v1 contract has no in-band configuration version field. Old strict readers + reject entity-source keys with an actionable key-specific error; managed + rollout does not write those keys until every supported reader is upgraded. +- Connection endpoints can be changed only by trusted layers. Discovery + credentials are bound to the canonical endpoint and tenant; changing the host + requires a separately provisioned binding and never sends the previous host's + credential to the new endpoint. +- Pull-request workflows resolve connection and creation-policy configuration + from the PR target branch head. A destination grant present only on the PR + source branch cannot widen a same-endpoint `allowed_targets` policy, replace + or remove an inherited restriction, or affect grants translated from legacy + `tracker` configuration. The existing repository configuration trust + boundary provides this behavior; no additional per-field trust mechanism is + required. +- Kind defaults and per-slot inheritance resolve correctly; all binding values + are lists, source defaults to `[native]`, and an omitted target copies the + final source list. Explicit targets win, copied names must support the target + kind, and additional named slots require explicit compatible nonempty bindings. +- A source that omits `connection` uses the connection with the same name; + validation fails when that connection is absent. Reserved source names may use + only their same-named provider connection. For a GitHub-origin clone, + `entity_sources.github` may omit both `connection` and `repositories`; it uses + `connections.github` and the clone path even when that connection points to + GitHub Enterprise. Any other active forge source resolving to + `connections.github`, such as `actionable_work`, may also omit `repositories`. + A source using an external or separately named connection must specify its + repository scope. `entity_sources.github.connection: enterprise` fails + validation. Untrusted layers cannot change endpoints, and a new endpoint + requires a separately provisioned credential binding. +- Native resolution uses the clone's provider independently of Kubernetes, + GitHub Actions, or GitLab CI execution. Its provider-default connection can + override the instance. Explicit matching-provider aliases deduplicate with + `native`; external names do not change native resolution. Unbound + cross-provider preset overrides start no discovery, and endpoint changes do + not transfer grants or evidence. +- Only the primary source list schedules work; target/auxiliary lists create + neither implicit joins nor broadcast writes, and ambiguous destinations need + explicit selection. Empty source/target lists suppress their defaults. +- Harness filters resolve by slot and connection provider, inherit by + slot/provider, and only narrow source selection. Missing filters add no + restriction; targets do not inherit source filters. Shared enumeration covers + the union of effective selections, with exact per-harness checks before + admission even when enumeration must use a superset. Event-backed and resident + cycles enforce the same filters. Other slots filter only explicit searches. +- GitHub subset parsing preserves Boolean grouping, quoted values, label + alternatives and exclusions, kind assertions, and native metadata/date + semantics. Unsupported terms and embedded scope/sort qualifiers fail before + provider submission. Negative and missing-metadata tests require complete + relevant facts; combining or partitioning cannot weaken a configured filter. +- GitHub discovery uses a verified advanced-search mode, with a projection + derived from currently relevant CEL and admission dependencies. Irrelevant + history is not eagerly fetched, partial nested collections remain explicit, + and search caps or field errors cannot establish complete coverage or a + negative predicate result. +- One canonical entity matching several aliases/queries admits at most one + execution per agent and target repository, without mixing credential scopes. +- Jira query combination preserves scoped membership; the local fast path + agrees with native evaluation, and unresolved checks batch without per-agent + searches or changing the effective Jira principal. GitLab `closed` for a merge + request combines native `state=closed` and `state=merged` results, while a work + item uses `state=closed`; neither preset mistakes merged for open. +- A source match alone cannot authorize a sandbox or admit content; uncertain + membership, actor authority, or coverage cannot masquerade as a non-match. +- Legacy translation preserves command defaults, polling enablement, credential + resolution, and creation permissions, including whole-block tracker replacement + and shadowing. For provider-only GitHub and GitLab blocks, `allowed_targets` + attaches to the generated `legacy_tracker` connection; it is not lost or + copied to a provider-default connection. Provider-only Jira entries follow the + same rule. Standalone invocations without legacy defaults or agent/entity + context require explicit scope selection. +- Standalone `--entity-source` selects one work-item scope independently of + agent bindings. Unique projects are inferred; ambiguous projects require + selection. Explicit identity operations can access entities outside a source's + discovery filter while retaining scope and authorization checks. Conflicting + new and legacy selectors fail, and legacy defaults cannot override an explicit + new selection. +- A new-format configuration works through migrated script consumers without + retaining `tracker` on disk; diagnostics do not corrupt machine-readable output. +- Lost coverage readiness and changed plans prevent new resident cycles while + preserving pending events and rediscovery; closed/merged entities remain + eligible for matching agents, including after webhook loss. + +Provider query pagination/consistency proofs, detailed authorization evidence, +and normalized entity/context schemas are specified and tested in their owning +contracts. Passing configuration conformance alone MUST NOT enable execution. diff --git a/docs/problems/agent-architecture.md b/docs/problems/agent-architecture.md index 6ac93af766..81da441cf9 100644 --- a/docs/problems/agent-architecture.md +++ b/docs/problems/agent-architecture.md @@ -161,6 +161,20 @@ The repository's existing infrastructure provides all the coordination needed: 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. + [ADR 0079](../ADRs/0079-bind-entity-execution-through-named-sources.md) + binds named, typed harness entity slots to repository-owned source lists. + Harness provider filters further narrow those queries before full CEL + evaluation, with effective primary selections combined for discovery. + The configuration clone selects the native provider independently of where + agents execute. Provider-default connections can override its instance; + reserved source names supply queries and repository scopes, including + explicitly configured external providers. + Only the source slot schedules work; other slots supply scopes for the run + without automatic joins or broadcast outputs. It permits provider-native + membership with exact local checks or + batched remote checks; actor-filtered agent predicates remain independent. + CI supplies execution and verified recurring discovery, while coordination + stays in entity state and receipts rather than an agent workflow graph. No agent orchestrates other agents. Each agent independently observes the state of the PR and acts according to its role: diff --git a/docs/problems/agent-infrastructure.md b/docs/problems/agent-infrastructure.md index 2501435f4b..e468352c3f 100644 --- a/docs/problems/agent-infrastructure.md +++ b/docs/problems/agent-infrastructure.md @@ -161,6 +161,11 @@ implementation and operational acceptance remain open. agent resource access remains open. - Do we need a dedicated “agent runner” image or environment with a known, auditable tool set? - ~~How do we preserve end-to-end traceability for event-driven agent dispatch in GitHub Actions?~~ Decided in [ADR 0041](../ADRs/0041-synchronous-workflow-call-event-dispatch.md) (synchronous `workflow_call` dispatch for the event path). +- How do CI wiring and recurring discovery support entity-bound resident runs + without introducing a separate agent coordinator? The design direction is + decided in [ADR 0079](../ADRs/0079-bind-entity-execution-through-named-sources.md): + shared binding/admission in fullsend, execution in CI, and verified discovery + readiness under ADR 0144. Required contracts, adapters, and rollout remain open. - How do we compare 3rd party vs internal vs build-our-own on concrete criteria: cost, time to first agent, compliance, and alignment with our security and coordination model? - Who in the org would own and operate agent infrastructure, and how does that align with existing platform or CI ownership? [ADR 0123](../ADRs/0123-tenant-configuration-from-repos-yaml.md) establishes the existing `repos.yaml` v1 format for tenant configuration in a possible centralized offering; the source of truth, service, operational ownership, and infrastructure remain open. - For cluster-hosted agents, how do we preserve an acceptable inner loop (fast local or sandboxed tests) without granting dangerous privilege, and how do we avoid paying for idle capacity while work waits on humans? (The poll/run process lifecycle and bound-run idle exit are decided in [ADR 0144](../ADRs/0144-reuse-poll-and-entity-bound-run-processes.md); capacity policy and the inner loop remain open.) diff --git a/docs/reference/config-reference.md b/docs/reference/config-reference.md index 3f687daf2a..12ce59fbe9 100644 --- a/docs/reference/config-reference.md +++ b/docs/reference/config-reference.md @@ -434,6 +434,20 @@ list, which may omit the ensured defaults. ### `tracker` +The target replacement is specified in +[ADR 0079](../ADRs/0079-bind-entity-execution-through-named-sources.md) and the +[entity-source configuration contract](../normative/entity-source-configuration/v1/): +named `connections`, `entity_sources`, and `agents[].entities` slot bindings, +with connection-scoped creation policy, in-memory legacy translation, and +deprecation warnings. +The configuration clone selects the native entity provider independently of the +execution platform. Provider-default connections (`github`, `gitlab`, `forgejo`) +can override its instance, including GitHub.com to GitHub Enterprise. Reserved +provider source names select queries and repository scopes and can be explicitly +bound; defining a source named `native` is forbidden. +These fields and the translation are not implemented yet; the current supported +configuration remains the `tracker` mapping documented below. + The issue tracker, as a single provider-discriminated mapping. `tracker` holds at most one provider block — `github`, `gitlab`, or `jira` — and the block that is present selects the provider. It is the default backend for the `--tracker`