Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1c1114d
feat(#1953): post the no-PR reason to Jira work items
ederign Nov 10, 2026
b3314ea
fix(#1953): point the skill's no-commit stops at pr_body
ederign Nov 10, 2026
7018877
fix(#1953): keep Jira token redaction inside Bash
ederign Nov 11, 2026
28fd57a
fix(#1953): give no-PR explanations a dedicated field
ederign Nov 11, 2026
7a70a33
docs(#1953): write the no-PR reason after retry initialization
ederign Nov 11, 2026
1931ea2
fix(#1953): publish Jira failures through the shared writer
ederign Nov 13, 2026
3d0ffa2
docs(#1953): name no-PR explanation variables consistently
ederign Nov 13, 2026
47b09cd
fix(#1953): retry transient Jira no-op comment failures
ederign Nov 13, 2026
1fa3a8c
chore(#1953): merge main and preserve Jira OAuth support
ederign Nov 16, 2026
6237d43
docs(#1953): align no-PR output with upstream file-writing guidance
ederign Nov 16, 2026
d487fd8
fix(#1953): rely on Jira client retries
ederign Nov 17, 2026
0704fdd
chore(#1953): merge main and preserve Jira transitions
ederign Nov 17, 2026
2fb0cfb
fix(#1953): guard Jira comment credentials under tracing
ederign Nov 19, 2026
e451c0f
fix(#1953): isolate failure diagnostics from PATH tools
ederign Nov 19, 2026
2e9ec21
fix(#1953): preserve leading no-PR explanations
ederign Nov 19, 2026
f2d1947
fix(#1953): guard filter lookup and redact Jira CLI logs
ederign Nov 20, 2026
9262e30
fix(#1953): explain bundled exit guards to ShellCheck
ederign Nov 20, 2026
f0faa38
Merge branch 'main' into feat/1953-jira-no-pr-reason
waynesun09 Nov 21, 2026
f2ec7ea
fix(#1953): redact the trimmed Jira token from the comment body
waynesun09 Nov 23, 2026
f92b545
Merge remote-tracking branch 'origin/main' into takeover-2010
waynesun09 Nov 23, 2026
42593bb
fix(#1953): skip whitespace-only credentials when redacting Jira comm…
waynesun09 Nov 23, 2026
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
37 changes: 31 additions & 6 deletions agents/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bump after the upstream change lands. When you find this:
and path the reference resolves to. A similarly named file in this
repository is not the target unless the reference resolves to it.
2. If the upstream change has not landed in a newer commit reachable from
the intended upstream reference, add `pr_body` naming the external
the intended upstream reference, add `no_pr_reason` naming the external
repository, file, and exact change needed. If the reference is pinned,
include its current SHA and say this repository's pin must be bumped after
the upstream change lands. Keep this escalation under 25 lines, put the
Expand Down Expand Up @@ -125,8 +125,8 @@ PR, even if the issue did not separately ask for the pin bump.

You MUST produce a JSON file at `$FULLSEND_OUTPUT_DIR/agent-result.json`
with `target_branch` (required) and optionally `pr_body` for the PR
description, or an upstream-fix explanation when you make no commit (see
"Repository boundary"). Delivery of no-commit context is described in
description, or `no_pr_reason` when you make no commit (see
"Stopping without a commit"). Delivery of no-commit context is described in
`docs/code.md`. The `code-implementation` skill describes the schema and
the exact steps where you write each field. The post-script reads this
file to determine the PR target branch and description. Without this
Expand All @@ -142,6 +142,31 @@ If validation fails, read the error output, fix the JSON file, and
re-run the check. If it still fails after 3 attempts, write the best
JSON you have and exit.

### Stopping without a commit
Comment thread
ederign marked this conversation as resolved.
Resolved

Whenever you stop with no commits ahead of the target branch (including
commits from an earlier run) and a clean working tree (no `ready-to-code`
signal, a gate label, the bug is already fixed, an open PR already covers
the issue, the issue is blocked or lacks acceptance criteria), set `no_pr_reason`
to a short explanation before validating. The
post-script posts it on the source issue (see `docs/code.md` for which
trackers) as the reason no PR was opened. Put
the reason first, then what would unblock the work, in under 25 lines and at most 4,000 characters, with
no credentials, tokens, or secret-bearing URLs. For a repository-boundary
escalation, use the format in "Repository boundary". If you stop before the
skill's step 3 wrote the result file, run step 3's default-branch discovery
and write the file as step 3 does first; a guessed `target_branch` can fail
the run. Write (overwrite) `/tmp/no-pr-reason.md` with your runtime's
file-writing tool, putting the reason first and what would unblock it next.
Then add the explanation without a shell heredoc:

```bash
f="${FULLSEND_OUTPUT_DIR}/agent-result.json"
jq --rawfile reason /tmp/no-pr-reason.md '. + {no_pr_reason: ($reason | sub("\n+$"; ""))}' \
"$f" > "$f.tmp" && mv "$f.tmp" "$f"
fullsend-check-output "$f"
```

## Failure handling

Secret scanning is **non-negotiable**. The `scan-secrets` helper runs before
Expand All @@ -154,9 +179,9 @@ Your exit state is the handoff contract:
scan).
- **No commit** → the post-script reads your transcript and exit code to
report the failure. Structured output should still be written when possible
so the post-script knows which branch was targeted. For a repository-boundary
escalation, the structured output's `pr_body` carries the upstream change
to report.
so the post-script knows which branch was targeted. With a clean working
tree, `no_pr_reason` carries the reason (see "Stopping without a commit"); for
a repository-boundary escalation, the upstream change to report.

## Validation retry behavior

Expand Down
51 changes: 40 additions & 11 deletions docs/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,21 @@ This separation ensures the agent never has direct write access to the repositor

When the fix belongs in another repository, the agent reports the upstream
repository, file, and required change without making a commit or restructuring
this repository. On GitHub/GitLab source issues, the no-PR path sanitizes
`pr_body`, keeps only its last 30 lines by default, and posts it as "Agent
context" under a generic "No PR created — agent determined no changes needed"
notice with retry guidance. Keep escalation text under 25 lines, put the
repository, file, and required change first, and omit the normal PR template.
External-tracker runs (such as Jira) emit only a generic notice; the upstream
explanation remains in the agent's final message in the run transcript.
this repository. The agent also sets `no_pr_reason` to a short explanation
whenever it stops without a commit for another reason (gate label, already
fixed, blocked, missing acceptance criteria). On GitHub, GitLab and Jira
source issues, the no-PR path prefers `no_pr_reason`, falling back to `pr_body` for older
agent outputs. It sanitizes and secret-scans the complete selected explanation,
then keeps its first 30 lines and adds a `... truncated` marker when more lines
remain. This fixed agent-context limit is independent of
`POST_FAILURE_DETAIL_MAX_LINES`, which controls failure-log tails. It posts the
result as "Agent context" under a generic "No PR created — agent determined no
changes needed" notice with retry guidance.
Keep escalation text under 25 lines, put the repository, file, and required
change first, and omit the normal PR template. On a Jira issue the notice
goes to an outcome comment with its own marker, so a rerun edits it and it
never replaces the PR/MR link comment. Other external trackers emit only a
generic notice in the job log.

If the target is referenced by a pinned SHA and the upstream fix has not
landed in a newer commit reachable from the intended upstream reference, the
Expand All @@ -102,7 +110,7 @@ text scan. If a text scan finds a secret or cannot complete, the issue comment
omits optional context, and the PR/MR description uses a generic fallback. A
rejected PR body falls back to the normalized commit body only if that text
passes the same scan. Raw text-scan diagnostics are not logged.
Jira-source no-PR runs still emit only their existing generic notice.
The Jira no-PR notice gets the same sanitization and context secret scan.

### Reruns on an open pull request

Expand Down Expand Up @@ -390,13 +398,34 @@ vars. Key differences from single-forge setup:
The post-script takes the Jira credentials out of its environment before
it runs any git command, so repo-controlled hooks, including the one that
fires when it renames the agent branch, cannot read them from their
environment or from a parent's `/proc/<pid>/environ`; only this Jira write
receives them. These are the same account the Jira poller treats as its own, so the update does not
dispatch agents. If the Jira write fails,
environment or from a parent's `/proc/<pid>/environ`; only the Jira writes
receive them. These are the same account the Jira poller treats as its own, so the update does not
dispatch agents. If the PR/MR link write fails,
the step fails, even though the PR/MR already exists. The branch, commits,
PR/MR, review and merge stay on the code host: GitHub targets get a GitHub
PR and GitLab targets get a GitLab MR. For GitLab targets the GitLab host
is taken from `CI_SERVER_HOST`, because `ISSUE_URL` is the Jira URL.
A clean no-op writes the notice and agent's explanation to a comment with
the marker `<!-- fullsend:code-agent-outcome -->`. A post-script failure
writes its category and sanitized detail under the separate marker
`<!-- fullsend:code-agent-failure -->`, including a refused rerun that would
replace another author's commits. Retries update the matching comment;
neither comment replaces the PR/MR link. A later successful run leaves
earlier no-op or failure comments alongside its link. These writes are best-effort: a
failed write is a warning and the run keeps its exit code. No-op and failure comments
each invoke the CLI once and rely on its HTTP retry policy: 429 responses
are retried for all methods; HTTP 500–504 and network failures are retried for
idempotent methods. There is no additional shell retry. A rerun after an
ambiguous comment POST failure relies on the sticky-marker property lookup
to find a comment the earlier request may have created. The shared comment
writer removes the saved token, email, OAuth client ID and secret (including
normalized values) from the comment body before delivery and from the
captured CLI stdout and stderr before logging. It also sanitizes workflow
commands in that output and preserves the CLI exit status.
Failure details use the same bounded regex/literal-token sanitizer as forge
failure comments, rather than `scan_public_text`. Failures can occur before
the public-text scanner is initialized; the scanner remains required for
optional agent context on the no-op path.
- **Policy** is `policies/base.yaml` for all forges. Network access is
provided by profiles (`fullsend-gitlab-code` for GitLab). Custom
harnesses using `base:` composition should override at the forge level
Expand Down
3 changes: 2 additions & 1 deletion harness/code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ overlays:
runner:
JIRA_BASE_URL: "${JIRA_BASE_URL}"
# Runner-only Jira credentials: pre-code can apply the configured
# started transition; post-code writes the stage update and PR/MR URL.
# started transition; post-code writes the stage update, PR/MR URL,
# no-op reason and failure details, and optional PR-ready transition.
# The sandbox never gets the real credential
# (the jira provider supplies a placeholder). They
# come from the FULLSEND_JIRA_TOKEN and optional FULLSEND_JIRA_EMAIL
Expand Down
8 changes: 7 additions & 1 deletion schemas/code-result.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "code-result.schema.json",
"title": "Code Agent Result",
"description": "Structured output from the code agent documenting the target branch and PR body for PR creation.",
"description": "Structured output from the code agent documenting the target branch, PR body, or reason no PR is needed.",
"type": "object",
"required": ["target_branch"],
"additionalProperties": false,
Expand All @@ -17,6 +17,12 @@
"maxLength": 60000,
"description": "PR description used as PR body instead of commit body. Supports markdown formatting and template-compliant structure without gitlint line-length constraints."
},
"no_pr_reason": {
"type": "string",
"minLength": 1,
"maxLength": 4000,
"description": "Explain why no pull request is needed or why implementation could not proceed, including any clarification or next step needed. Set when stopping without a commit and with a clean working tree."
},
"closes_issue": {
"type": "boolean",
"default": true,
Expand Down
107 changes: 62 additions & 45 deletions scripts/lib/post-failure-report.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@
[[ -n "${POST_FAILURE_REPORT_SH_LOADED:-}" ]] && return 0
POST_FAILURE_REPORT_SH_LOADED=1

# Resolve trusted system filters before repo-installed tools can change PATH.
# Raw diagnostics may contain credentials, including ones redacted by callers.
_post_failure_system_filter() {
local tool="$1" resolved=""
if ! resolved="$(command -p -v "${tool}")" || [[ "${resolved}" != /* ]] || [ ! -x "${resolved}" ]; then
printf 'ERROR: required system filter %s is unavailable in the system default PATH\n' "${tool}" >&2
return 1
fi
printf '%s' "${resolved}"
Comment thread
ederign marked this conversation as resolved.
Resolved
}
# In executed bundles, return is invalid and exit is reached.
# shellcheck disable=SC2317
_POST_FAILURE_SED="$(_post_failure_system_filter sed)" || { return 1 2>/dev/null || exit 1; }
# In executed bundles, return is invalid and exit is reached.
# shellcheck disable=SC2317
_POST_FAILURE_AWK="$(_post_failure_system_filter awk)" || { return 1 2>/dev/null || exit 1; }
# In executed bundles, return is invalid and exit is reached.
# shellcheck disable=SC2317
_POST_FAILURE_TAIL="$(_post_failure_system_filter tail)" || { return 1 2>/dev/null || exit 1; }
# In executed bundles, return is invalid and exit is reached.
# shellcheck disable=SC2317
_POST_FAILURE_CAT="$(_post_failure_system_filter cat)" || { return 1 2>/dev/null || exit 1; }
# In executed bundles, return is invalid and exit is reached.
# shellcheck disable=SC2317
_POST_FAILURE_GREP="$(_post_failure_system_filter grep)" || { return 1 2>/dev/null || exit 1; }

# shellcheck source=forge-transient-retry.lib.sh
source "${BASH_SOURCE[0]%/*}/forge-transient-retry.lib.sh"

Expand Down Expand Up @@ -39,7 +65,7 @@ _sanitize_workflow_value() {
# stripping mid-string :: (e.g. std::string in compiler output).
sanitize_comment_workflow_commands() {
local value="$1"
value="$(printf '%s\n' "${value}" | sed -E \
value="$(printf '%s\n' "${value}" | "${_POST_FAILURE_SED}" -E \
-e 's/^::(warning|error|notice|debug|group|endgroup):://')"
value="${value//%0A/}"
value="${value//%0a/}"
Expand Down Expand Up @@ -73,7 +99,7 @@ gha_echo() {
}

_redact_multiline_pem() {
awk '
"${_POST_FAILURE_AWK}" '
# OpenSSH/RSA/EC/DSA/PKCS8 PEM headers end in "...private key-----".
# OpenPGP'"'"'s ASCII-armor format instead ends in "...private key
# block-----" (issue #239) -- the optional "( block)?" covers both
Expand Down Expand Up @@ -107,31 +133,10 @@ _redact_literal_token() {
return 0
fi

export REDACT_LITERAL_TOKEN="${token}"
awk '
BEGIN {
token = ENVIRON["REDACT_LITERAL_TOKEN"]
repl = "[REDACTED]"
}
{
s = $0
while ((i = index(s, token)) > 0) {
s = substr(s, 1, i - 1) repl substr(s, i + length(token))
}
print s
}
' <<< "${detail}" | {
local line result=""
while IFS= read -r line || [ -n "${line}" ]; do
if [ -n "${result}" ]; then
result="${result}"$'\n'"${line}"
else
result="${line}"
fi
done
printf '%s' "${result}"
}
unset REDACT_LITERAL_TOKEN
# Keep credentials inside Bash: PATH may include repo-installed tools by
Comment thread
ederign marked this conversation as resolved.
Resolved
# the time a failure is reported. Quoting the pattern makes glob characters
# in tokens literal, and replacement text is not scanned again.
printf '%s' "${detail//"${token}"/[REDACTED]}"
}

# Strip tokens and truncate noisy command output before posting publicly.
Expand All @@ -140,7 +145,7 @@ sanitize_failure_detail() {
local max_lines="${2:-${POST_FAILURE_DETAIL_MAX_LINES}}"

detail="$(printf '%s\n' "${detail}" \
| sed -E \
| "${_POST_FAILURE_SED}" -E \
-e 's/gh[pousr]_[A-Za-z0-9_]{20,}/[REDACTED]/g' \
-e 's/github_pat_[A-Za-z0-9_]+/[REDACTED]/g' \
-e 's/glpat-[A-Za-z0-9_-]{20,}/[REDACTED]/g' \
Expand All @@ -162,7 +167,7 @@ sanitize_failure_detail() {
detail="$(sanitize_comment_workflow_commands "${detail}")"

if [ "${max_lines}" -gt 0 ]; then
detail="$(printf '%s\n' "${detail}" | tail -n "${max_lines}")"
detail="$(printf '%s\n' "${detail}" | "${_POST_FAILURE_TAIL}" -n "${max_lines}")"
fi

printf '%s' "${detail}"
Expand All @@ -176,13 +181,13 @@ set_post_failure() {
categorize_push_failure() {
local push_output="$1"

if echo "${push_output}" | grep -qiE \
if echo "${push_output}" | "${_POST_FAILURE_GREP}" -qiE \
'workflow.*without.*workflows?[[:space:]]+permission|refusing to allow.*GitHub App.*workflow'; then
echo "push-workflow-permission"
return 0
fi

if echo "${push_output}" | grep -qiE \
if echo "${push_output}" | "${_POST_FAILURE_GREP}" -qiE \
'non-fast-forward|rejected|fetch first|protected branch|GH006|permission denied|not a fast forward|rule violations'; then
echo "push-rejected"
return 0
Expand Down Expand Up @@ -212,7 +217,7 @@ post_failure_category_label() {
post_failure_security_note() {
case "$1" in
push-workflow-permission)
cat <<'EOF'
"${_POST_FAILURE_CAT}" <<'EOF'
> **Security boundary:** the coder app intentionally lacks `workflows` write permission. Changes to `.github/workflows/` must be made outside the agent (e.g., via a manual PR). Re-run the agent without workflow file changes, or apply those changes separately.
EOF
;;
Expand Down Expand Up @@ -256,8 +261,8 @@ build_post_failure_comment() {
fi

if [ -n "${sanitized_detail}" ]; then
indented_detail="$(printf '%s\n' "${sanitized_detail}" | sed 's/^/ /')"
detail_block="$(cat <<EOF
indented_detail="$(printf '%s\n' "${sanitized_detail}" | "${_POST_FAILURE_SED}" 's/^/ /')"
detail_block="$("${_POST_FAILURE_CAT}" <<EOF

**Details:**
${indented_detail}
Expand All @@ -274,7 +279,7 @@ EOF
fi

if [ "${category}" = "uncommitted-work" ]; then
cat <<EOF
"${_POST_FAILURE_CAT}" <<EOF
⚠️ **${agent_kind} agent killed before committing** — uncommitted work discarded (exit code ${exit_code})

The ${agent_kind} agent left uncommitted changes in the extracted repo and produced no commit to push. The run was likely killed (timeout) before \`git commit\` executed, so this work was discarded and no PR was opened.
Expand All @@ -288,7 +293,7 @@ EOF
return 0
fi

cat <<EOF
"${_POST_FAILURE_CAT}" <<EOF
⚠️ **Post-${agent_kind} script failed** — ${label} (exit code ${exit_code})

The ${agent_kind} agent completed, but the post-${agent_kind} script failed before finishing.
Expand Down Expand Up @@ -438,26 +443,38 @@ report_post_failure_to_issue() {
fi
POST_FAILURE_REPORTED=true

local category="${POST_FAILURE_CATEGORY:-post-script-error}"
local detail="${POST_FAILURE_DETAIL:-Post-code script failed before push or PR creation completed.}"
local body
# REPO_FULL_NAME is required by post-code.src.sh setup.
# Reporting must not replace the original failure, even if rendering fails.
# shellcheck disable=SC2153
if ! body="$(build_post_failure_comment \
"code" "${exit_code}" "${category}" "${detail}" \
"${REPO_FULL_NAME}" "/fs-code")"; then
gha_echo warning "Could not build the post-code failure comment; see workflow logs"
return 0
fi

# An external tracker may have no corresponding target-forge issue. The
# workflow status notification remains the source-of-truth; do not guess a
# target issue number and risk commenting on unrelated work.
# target issue number and risk commenting on unrelated work. A caller that
# can write to the tracker defines post_external_failure_comment
# (post-code does, for Jira); its result never changes this exit path.
if [ "${EXTERNAL_WORK_ITEM:-false}" = "true" ]; then
if declare -F post_external_failure_comment >/dev/null 2>&1 \
&& post_external_failure_comment "${body}"; then
return 0
fi
gha_echo warning "Post-code failure for ${WORK_ITEM_KEY:-external work item}; see workflow logs"
return 0
fi

_post_failure_ensure_token

local category="${POST_FAILURE_CATEGORY:-post-script-error}"
local detail="${POST_FAILURE_DETAIL:-Post-code script failed before push or PR creation completed.}"
local body
# ISSUE_NUMBER is required by post-code.src.sh for forge work items.
# shellcheck disable=SC2153
safe_issue_number="$(_sanitize_workflow_value "${ISSUE_NUMBER}")"
# ISSUE_NUMBER and REPO_FULL_NAME are required by post-code.src.sh before sourcing.
# shellcheck disable=SC2153
body="$(build_post_failure_comment \
"code" "${exit_code}" "${category}" "${detail}" \
"${REPO_FULL_NAME}" "/fs-code")"

gha_echo warning "Posting failure comment to issue #${safe_issue_number}..."
if declare -F forge_post_issue_comment >/dev/null 2>&1; then
Expand Down
Loading
Loading