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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ script-test:
$(call run-timed,bash scripts/pr-review-dependency-scope-test.sh)
$(call run-timed,bash scripts/post-review-test.sh)
$(call run-timed,bash scripts/risk-tier1-test.sh)
$(call run-timed,python3 scripts/fetch-fix-jira-context-test.py)
$(call run-timed,bash scripts/pre-fix-test.sh)
$(call run-timed,bash scripts/post-fix-test.sh)
$(call run-timed,bash scripts/review-body-fallback-test.sh)
Expand Down
9 changes: 9 additions & 0 deletions agents/fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ workflows. Fix `pr-related` failures only within authorized scope; a narrow
instruction such as `rebase` does not authorize extra CI-driven edits.
Record `ci_inspections` either way.

## Current Jira requirements

On every run, read the runner-provided `/sandbox/workspace/jira-context.json`
when present, following `fix-review` step 2e. Applicable requirements from
that issue are in scope alongside review feedback. Human instructions and
review feedback take precedence; report conflicts and request clarification
instead of silently choosing. Narrow human instructions still constrain
scope. Jira access is runner-only and read-only; never write back to Jira.

## Reconcile forge-reported merge conflicts

Before applying review fixes, inspect the change request's forge-specific
Expand Down
84 changes: 82 additions & 2 deletions docs/fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Review-feedback specialist that reads review comments on open PRs, implements ta

## Setup

No additional setup is required beyond the standard fullsend configuration.
No additional setup is required beyond the standard fullsend configuration
for review fixes. Reading [current Jira context](#current-jira-context)
requires the Jira tracker configuration and credentials described below.

## How it helps

Expand All @@ -22,7 +24,7 @@ The fix agent runs automatically when the [review agent](review.md) submits a

It can also be triggered manually with the `/fs-fix` command.

The harness also declares a CEL `trigger:` for fullsend's harness dispatch, on GitHub and GitLab only: `/fs-fix` from a human on a same-repo PR/MR, or a "changes requested" review from a `*-review[bot]` reviewer on a same-repo PR that is bot-authored or labeled `fullsend-fix` and is not labeled `fullsend-no-fix`. It has no Jira path. Dispatch does not evaluate it for the built-in fix agent yet, so the routing above is what runs today.
The harness also declares a CEL `trigger:` for fullsend's harness dispatch, on GitHub and GitLab only: `/fs-fix` from a human on a same-repo PR/MR, or a "changes requested" review from a `*-review[bot]` reviewer on a same-repo PR that is bot-authored or labeled `fullsend-fix` and is not labeled `fullsend-no-fix`. Jira issues do not trigger the fix agent directly. Dispatch does not evaluate it for the built-in fix agent yet, so the routing above is what runs today.

## Commands

Expand Down Expand Up @@ -55,6 +57,83 @@ command. The text gives you direct control over what to fix:
further automatic fix runs. Manual `/fs-fix` commands still work.
Remove the label or use `/fs-fix` to re-engage.

## Current Jira context

For a PR/MR carrying the Jira origin record created by the code agent,
the pre-script reads the current issue description and comments on every
fix run through `fullsend issues get --tracker jira`. No special wording
in `/fs-fix` is needed. The fix agent considers applicable requirements
alongside review feedback; a narrow instruction such as `rebase` still
limits its scope. Conflicts are reported for human clarification.

The runner needs `fullsend` with `issues get --fields` support, `yq`, and
`FULLSEND_DIR` containing trusted `tracker.jira.base_url` and
`tracker.jira.project` settings. Both the site and project must match the
origin record. The marker is editable PR content, not authenticated proof
of origin; project scoping limits reads but does not establish provenance.

On GitHub, named `FULLSEND_JIRA_*` repository secrets are delivered only to
Jira-sourced jobs. A fix run is forge-sourced. Use the existing
[runner-secrets channel](https://github.com/fullsend-ai/fullsend/blob/main/docs/guides/user/bring-your-own-agent.md#pass-secrets-to-host-side-scripts-github)
with a custom fix harness inheriting the upstream harness through `base:`
(see [custom harness configuration](code.md#how-to-configure)). Add:

```yaml
env:
runner:
JIRA_API_TOKEN: "${JIRA_API_TOKEN}"
JIRA_API_EMAIL: "${JIRA_API_EMAIL}"
FIX_JIRA_ACCEPTANCE_CRITERIA_FIELD: "customfield_10718"
```

Store the actual `JIRA_API_TOKEN` and `JIRA_API_EMAIL` values in the
`FULLSEND_GITHUB_RUNNER_SECRETS` JSON secret. Preserve existing entries
when updating that object; references to other GitHub secrets inside it
are not expanded. Do not use reserved names such as `FULLSEND_JIRA_TOKEN`
or `JIRA_TOKEN` as runner-secret keys or harness mapping targets.
For bearer authentication, omit the email mapping. For OAuth client
credentials, replace both token/email mappings with `JIRA_API_CLIENT_ID`
and `JIRA_API_CLIENT_SECRET`. Declare only the keys your installation
supplies: a declared missing runner secret fails harness validation before
the pre-script can run. The built-in harness requires none of these secrets;
without Jira access the normal fix flow continues with unavailable context.
GitLab deployments must supply these runner-only aliases through their
host configuration; the GitHub runner-secret bundle is GitHub-specific.

The field ID above is an example, not a portable default. Verify the
Acceptance Criteria field ID and its applicability to your project's issue
type, then set `FIX_JIRA_ACCEPTANCE_CRITERIA_FIELD` in the custom harness.
An unset, malformed, absent or inaccessible field is reported separately
from the description and comments. A null response cannot distinguish an
empty field from a field unavailable to the credential. Rich-text JSON is
preserved for the agent to read. The default field setting is empty.

The pre-script maps aliases into the CLI's canonical credential names only
for its trusted fetch process. Pre/post scripts remove both aliases and
canonical names before forge readers, repository hooks or dependency
installers run. Credentials never enter the sandbox. Only the read command
is used; no Jira sandbox provider is added.

Missing, malformed, multiple or misplaced origin records, a site or project
mismatch, or unavailable Jira access are reported while normal fixes continue.
Existing PRs without origin metadata are not backfilled. An incidental Jira
URL in prose or a branch name does not cause Jira access.

**Architecture note:** this draft creates a runner-side snapshot. Existing
code and triage agents instead read Jira directly through the built-in
read-only provider and `jira-forge` skill; that provider isolates credentials
but does not establish a general requirement for filtering Jira text.
Fullsend's [custom pre-script guidance](https://github.com/fullsend-ai/fullsend/blob/main/docs/guides/user/bring-your-own-agent.md#pre-script)
says scripts must not stage unfiltered source content, while describing a
future filtered snapshot. That guidance needs reconciling with this sidecar
approach during draft review. Selecting known response fields and telling
the agent to distrust text do not constitute a content-injection filter.

This integration supplies current content, not a historical diff. The agent
reports differences from the implementation and explicitly states that it
cannot verify what changed since PR creation. Historical comparison remains
follow-up work for AISDLC-835.

## Control labels

| Label | Meaning |
Expand All @@ -73,6 +152,7 @@ See [Customizing with AGENTS.md](https://fullsend.sh/docs/guides/user/customizin

| Variable | Default | Effect |
|----------|---------|--------|
| `FIX_JIRA_ACCEPTANCE_CRITERIA_FIELD` | empty | Runner-only Jira custom field ID (`customfield_N`); configure through a base-derived harness after verifying the field for the project. See [Current Jira context](#current-jira-context). |
| `FULLSEND_FORGE` | `github` | Selects the forge platform (`github` or `gitlab`). Set automatically by the harness forge overlays (`overlays:` entries guarded by `runtime.forge`). |
| `GITHUB_SIGNED_COMMITS` | `false` | `true` publishes the branch through the GitHub Git Data API so GitHub signs the commits (see [Signed commits](code.md#signed-commits)); anything else keeps `git push`. Set in the GitHub overlay (`runtime.forge == "github"`) of `harness/fix.yaml`; override via `base:` composition. |
| `FIX_CONFLICT_UPDATE_STRATEGY` | `merge` | How the fix agent updates a PR/MR when the forge reports a **real** merge conflict: `merge` (default; creates a merge commit and preserves history) or `rebase` (replays the PR onto the target; the post-script force-pushes with `--force-with-lease`). Blocked/behind/unknown mergeability is never treated as a conflict. Override via `base:` composition. |
Expand Down
10 changes: 10 additions & 0 deletions harness/fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ host_files:
optional: true
- src: ${REVIEW_BODY_FILE}
dest: /sandbox/workspace/review-body.txt
- src: ${REVIEW_BODY_FILE}.jira-context.json
dest: /sandbox/workspace/jira-context.json
optional: true
- src: ${GCP_OIDC_TOKEN_FILE}
dest: /sandbox/workspace/.gcp-oidc-token
optional: true
Expand Down Expand Up @@ -117,6 +120,7 @@ env:
# Conservative default: merge the target into the PR/MR branch when the
# forge reports a real conflict. Override via base: composition.
FIX_CONFLICT_UPDATE_STRATEGY: "merge"
FIX_JIRA_ACCEPTANCE_CRITERIA_FIELD: ""
sandbox:
MAX_RETRIES: "1"
TIMEOUT_SECONDS: "1500"
Expand Down Expand Up @@ -195,3 +199,9 @@ overlays:
PR_NUMBER: "${MR_NUMBER}"
PR_URL: "${GITLAB_MR_URL}"
FULLSEND_FORGE: gitlab
# Fix events come from the code forge. Credentials are opt-in through
# custom harness env.runner aliases and the runner-secrets channel.
- when: 'has(config.tracker) && has(config.tracker.jira)'
env:
runner:
FULLSEND_DIR: "${FULLSEND_DIR}"
78 changes: 78 additions & 0 deletions harness/triggertest/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1162,3 +1162,81 @@ func hasTrigger(t *testing.T, harnessFile string) bool {
}
return strings.TrimSpace(h.Trigger) != ""
}

func TestFixJiraCredentialOverlay(t *testing.T) {
data, err := os.ReadFile(filepath.Join("..", "fix.yaml"))
if err != nil {
t.Fatal(err)
}
var h struct {
Env struct {
Runner map[string]string `yaml:"runner"`
Sandbox map[string]string `yaml:"sandbox"`
} `yaml:"env"`
Overlays []struct {
When string `yaml:"when"`
Env struct {
Runner map[string]string `yaml:"runner"`
Sandbox map[string]string `yaml:"sandbox"`
} `yaml:"env"`
} `yaml:"overlays"`
}
if err := yaml.Unmarshal(data, &h); err != nil {
t.Fatal(err)
}
for key := range h.Env.Runner {
if strings.HasPrefix(key, "FULLSEND_JIRA_") {
t.Fatalf("Jira credential %s required on non-Jira repositories", key)
}
}
when := ""
for _, overlay := range h.Overlays {
if overlay.Env.Runner["FULLSEND_DIR"] != "" {
when = overlay.When
}
for key := range overlay.Env.Runner {
if strings.HasPrefix(key, "FULLSEND_JIRA_") || strings.HasPrefix(key, "JIRA_API_") {
t.Fatalf("built-in harness requires Jira credential %s", key)
}
}
for key := range overlay.Env.Sandbox {
if strings.HasPrefix(key, "FULLSEND_JIRA_") || strings.HasPrefix(key, "JIRA_API_") || key == "JIRA_TOKEN" {
t.Fatalf("Jira credential %s enters sandbox", key)
}
}
}
if when == "" {
t.Fatal("no Jira credential overlay")
}
env, err := cel.NewEnv(cel.Variable("config", cel.DynType))
if err != nil {
t.Fatal(err)
}
ast, issues := env.Compile(when)
if issues != nil && issues.Err() != nil {
t.Fatal(issues.Err())
}
prg, err := env.Program(ast)
if err != nil {
t.Fatal(err)
}
for _, tc := range []struct {
name string
config map[string]any
want bool
}{
{"no tracker", map[string]any{}, false},
{"GitHub tracker", map[string]any{"tracker": map[string]any{"github": map[string]any{}}}, false},
{"Jira tracker on a forge fix run", map[string]any{"tracker": map[string]any{"jira": map[string]any{}}}, true},
} {
t.Run(tc.name, func(t *testing.T) {
out, _, err := prg.Eval(map[string]any{"config": tc.config})
if err != nil {
t.Fatal(err)
}
if got, _ := out.Value().(bool); got != tc.want {
t.Errorf("Jira overlay = %v, want %v", got, tc.want)
}
})
}
}
Loading
Loading