Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5572705
fix(#6966): flatten a rejected status before the generated post-scrip…
waynesun09 Sep 11, 2026
7158fee
test(#6966): skip the status-flattening exec test when jq is absent
waynesun09 Sep 11, 2026
637e8cc
fix(#6966): log the rejected status with printf so xpg_echo cannot ex…
waynesun09 Sep 11, 2026
1e96f48
feat(#6966): generate readonly_repo for the review role
waynesun09 Sep 11, 2026
5473296
test(#6966): pin readonly_repo in the rendered review harness
waynesun09 Sep 11, 2026
cba63a7
fix(#6966): on ok, replace an earlier findings comment with the all-c…
waynesun09 Sep 11, 2026
10e0b76
feat(#6966): issues post-comment --only-if-exists; the generated ok p…
waynesun09 Sep 11, 2026
baaac7f
test(#6966): cover --only-if-exists on the forge-client and Jira paths
waynesun09 Sep 11, 2026
8a9628d
fix(#6966): detect --only-if-exists before using it on the ok path
waynesun09 Sep 11, 2026
c083631
docs(#6966): list --only-if-exists in the CLI internals reference
waynesun09 Sep 11, 2026
9211ed9
fix(#6966): match only the poster's own comment under --only-if-exists
waynesun09 Oct 1, 2026
ab0d3f0
fix(#6966): tighten the generated ok path and its tests
waynesun09 Oct 1, 2026
f72f8bc
fix(#6966)!: never edit a marker comment post-comment cannot verify a…
waynesun09 Oct 1, 2026
8429156
test(#6966): pin that an unverified identity never edits an authorles…
waynesun09 Oct 1, 2026
33c3e4a
fix(#6966)!: fail instead of posting when post-comment cannot verify …
waynesun09 Oct 1, 2026
069e284
test(#6966): pin the identity lookup's cancellation and empty-identit…
waynesun09 Oct 1, 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
2 changes: 2 additions & 0 deletions docs/cli/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ command refuses an unknown one up front. The hosted mint serves these:
| `retro` | `actions:read`, `contents:read`, `pull_requests:write`, `issues:write`, `metadata:read` | vertex-ai, github-ro, github-artifacts |
| `prioritize` | `contents:read`, `issues:write`, `organization_projects:write`, `metadata:read` | vertex-ai, github-ro |

A `review` agent also gets `readonly_repo: true`, so the repository is mounted read-only in the sandbox: the prompt's "do not edit files" is enforced, not requested. That matches the review harness in fullsend-ai/agents.

Pick the role whose permissions fit what the agent does. An unknown role fails
immediately with this table, rather than returning `403` from the mint the
first time the agent runs. To use a role the hosted mint does not serve, you
Expand Down
1 change: 1 addition & 0 deletions docs/guides/dev/cli-internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fullsend
│ ├── --number <int> # Issue number
│ ├── --marker <string> # Sticky marker for idempotent updates (HTML comment or Jira property)
│ ├── --keep-history # Append previous content as collapsed history (default true)
│ ├── --only-if-exists # Update an existing marked comment, never create one
│ └── --fullsend-dir <path> # .fullsend config directory (resolves keep_history default)
├── post-review # Post sticky PR/MR review comments (formal review is best-effort)
│ ├── --forge <forge> # Forge backend: github (default) or gitlab
Expand Down
31 changes: 16 additions & 15 deletions docs/guides/user/issues-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ fullsend issues get \
## `fullsend issues post-comment`

Posts a comment with a sticky marker on an issue. On re-runs, finds
the existing comment by its marker and edits in-place. By default,
the existing comment by its marker and its own author (see
[Trust model](#trust-model)) and edits in-place. By default,
old content is collapsed into `<details>` blocks to preserve history;
set `keep_history: false` in config.yaml (or pass `--keep-history=false`)
to replace the body with no history.
Expand Down Expand Up @@ -85,8 +86,9 @@ echo "Triage complete. See PR #99." | fullsend issues post-comment \
| `--token` | No | API token (default: env var per tracker) |
| `--jira-url` | Jira only | Jira instance URL (default: `$JIRA_BASE_URL`) |
| `--jira-email` | Jira only | Jira user email for auth (default: `$JIRA_USER_EMAIL`) |
| `--dry-run` | No | Print what would be posted without making API calls |
| `--dry-run` | No | Print what would be posted without posting or editing anything |
| `--keep-history` | No | Append previous content as collapsed history blocks (default: `true`; set `false` to replace in-place) |
| `--only-if-exists` | No | Update an existing comment with this marker but never create one. Use it for an all-clear result, so a findings comment from an earlier run is updated in place (the old findings are kept as collapsed history unless `--keep-history=false`) while a clean first run posts nothing. Only a comment whose author is exactly the identity posting matches; if that identity cannot be resolved, the command fails without posting. |
| `--fullsend-dir` | No | Path to `.fullsend` config directory (sources defaults from its `config.yaml` when flags are omitted) |

### Jira marker storage
Expand Down Expand Up @@ -114,20 +116,19 @@ for how the `tracker` field resolves through the config overlay chain.

## Trust model

Marker-based comment lookup does not verify the comment author. In a
trusted CI environment (the intended deployment) this is safe because
only the bot writes marker-bearing comments.

For GitHub and GitLab, where markers are hidden HTML comments in the
body, an untrusted user who can post issue comments containing your
marker string could cause the bot to edit their comment instead of
creating its own. For Jira, markers are stored as comment entity
properties, which require comment-edit permissions to set — body-text
injection alone cannot spoof a marker.

Do not use this command in environments where untrusted users can write
arbitrary issue comments bearing your marker (GitHub/GitLab) or have
comment-edit permissions (Jira).
body, an existing comment is edited only when it carries the marker
**and** its author is exactly the identity the command posts as. A
comment anyone else wrote with the same marker is ignored, never edited.
If that identity cannot be resolved after a short retry, the command
fails with an error naming the cause and posts or edits nothing, with or
without `--only-if-exists`; rerun it. Posting a new comment instead would
leave the earlier one behind with content no later run updates.

For Jira, markers are stored as comment entity properties, which require
comment-edit permissions to set — body-text injection alone cannot spoof
a marker. Do not use this command where untrusted users have
comment-edit permissions on your Jira project.

## Environment variables

Expand Down
182 changes: 182 additions & 0 deletions internal/agentnew/postscript_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,185 @@ func TestGeneratedPostScriptRunsFromTheRunDirectory(t *testing.T) {
}
})
}

// TestGeneratedPostScriptFlattensAnInvalidStatusBeforeLogging feeds a status
// that carries a line break (LF, CR alone, or CRLF) and a workflow-command
// prefix. The rejection message must stay on one line and must not reproduce
// the injected line, because the script's stderr lands in the runner log
// where `::` at line start is interpreted as a command.
func TestGeneratedPostScriptFlattensAnInvalidStatusBeforeLogging(t *testing.T) {
Comment thread
waynesun09 marked this conversation as resolved.
Resolved
if _, err := exec.LookPath("jq"); err != nil {
t.Skip("jq not installed; the generated post-script needs it")
}
script := renderPostScriptTo(t, t.TempDir())
for name, brk := range map[string]string{"LF": "\n", "CR": "\r", "CRLF": "\r\n"} {
t.Run(name, func(t *testing.T) {
runDir := writeRunDir(t, map[string]any{
"iteration-1": map[string]any{
"status": "bogus" + brk + "::error::injected",
"summary": "s",
"comment": "c",
},
})
_, stderr, err := runPostScript(t, script, runDir)
if err == nil {
t.Fatal("expected the script to reject an invalid status")
}
if !strings.Contains(stderr, "status must be ok, findings or error") {
t.Fatalf("expected the status rejection, got stderr:\n%s", stderr)
}
for _, line := range strings.FieldsFunc(stderr, func(r rune) bool { return r == '\n' || r == '\r' }) {
if strings.HasPrefix(line, "::") {
t.Fatalf("model-supplied status reached the log as its own line: %q", line)
}
}
if strings.ContainsRune(stderr, '\r') || strings.Count(strings.TrimSpace(stderr), "\n") != 0 {
t.Fatalf("rejection must be a single log line, got: %q", stderr)
}
})
}
}

// TestGeneratedPostScriptDoesNotExpandEscapesUnderXpgEcho runs the script
// with bash's xpg_echo option on, where `echo` interprets backslash escapes.
// A status carrying a literal backslash-n must still be logged on one line.
func TestGeneratedPostScriptDoesNotExpandEscapesUnderXpgEcho(t *testing.T) {
if _, err := exec.LookPath("jq"); err != nil {
t.Skip("jq not installed; the generated post-script needs it")
}
script := renderPostScriptTo(t, t.TempDir())
runDir := writeRunDir(t, map[string]any{
"iteration-1": map[string]any{
"status": `bogus\n::error::injected`,
"summary": "s",
"comment": "c",
},
})
cmd := exec.Command("bash", "-O", "xpg_echo", script)
cmd.Dir = runDir
cmd.Env = append(os.Environ(),
"ISSUE_URL=https://github.com/fullsend-ai/demo/pull/99",
"GH_TOKEN=test-token",
DryRunEnvVar("lint-docs")+"=1",
)
var stderr strings.Builder
cmd.Stderr = &stderr
if err := cmd.Run(); err == nil {
t.Fatal("expected the script to reject an invalid status")
}
out := strings.TrimSpace(stderr.String())
if strings.Count(out, "\n") != 0 {
t.Fatalf("backslash escapes were expanded into a new log line:\n%s", out)
}
if !strings.Contains(out, `bogus\n::error::injected`) {
t.Fatalf("expected the literal value on the single line, got: %q", out)
}
}

// TestGeneratedPostScriptOkDryRunPostsNothing pins the ok path under dry
// run: the script exits 0 and says nothing was posted, without looking for
// an earlier comment. The live path is covered by the stubbed-fullsend tests
// below; the author check it relies on is tested in internal/cli.
func TestGeneratedPostScriptOkDryRunPostsNothing(t *testing.T) {
if _, err := exec.LookPath("jq"); err != nil {
t.Skip("jq not installed; the generated post-script needs it")
}
script := renderPostScriptTo(t, t.TempDir())
runDir := writeRunDir(t, map[string]any{
"iteration-1": map[string]any{"status": "ok", "summary": "All clear", "comment": "All added documentation links resolve."},
})
stdout, stderr, err := runPostScript(t, script, runDir)
if err != nil {
t.Fatalf("ok status must exit 0, got %v; stderr:\n%s", err, stderr)
}
if !strings.Contains(stderr, "nothing to post") {
t.Fatalf("expected the nothing-to-post notice, got stderr:\n%s", stderr)
}
if strings.TrimSpace(stdout) != "" {
t.Fatalf("ok under dry run must print no comment body, got:\n%s", stdout)
}
}

// TestGeneratedPostScriptOkReplacesEarlierFindingsViaOnlyIfExists runs the
// live ok path (no dry run) against a stub `fullsend` on PATH that records
// its arguments. The script must delegate the "is there an earlier findings
// comment" decision to `fullsend issues post-comment --only-if-exists`
// rather than reimplementing it with raw API calls in shell.
func TestGeneratedPostScriptOkReplacesEarlierFindingsViaOnlyIfExists(t *testing.T) {
if _, err := exec.LookPath("jq"); err != nil {
t.Skip("jq not installed; the generated post-script needs it")
}
binDir := t.TempDir()
argsFile := filepath.Join(binDir, "args")
stub := "#!/usr/bin/env bash\nif [[ \"$*\" == *--help* ]]; then echo ' --only-if-exists update an existing comment but never create one'; exit 0; fi\nprintf '%s\\n' \"$@\" > " + argsFile + "\ncat >/dev/null\n"
if err := os.WriteFile(filepath.Join(binDir, "fullsend"), []byte(stub), 0o755); err != nil {
t.Fatal(err)
}
script := renderPostScriptTo(t, t.TempDir())
runDir := writeRunDir(t, map[string]any{
"iteration-1": map[string]any{"status": "ok", "summary": "All clear", "comment": "All added documentation links resolve."},
})
cmd := exec.Command("bash", script)
cmd.Dir = runDir
cmd.Env = append(os.Environ(),
"PATH="+binDir+string(os.PathListSeparator)+os.Getenv("PATH"),
"ISSUE_URL=https://github.com/fullsend-ai/demo/pull/99",
"GH_TOKEN=test-token",
)
var stderr strings.Builder
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
t.Fatalf("ok live path must exit 0, got %v; stderr:\n%s", err, stderr.String())
}
got, err := os.ReadFile(argsFile)
if err != nil {
t.Fatalf("the script never invoked fullsend on the ok path: %v; stderr:\n%s", err, stderr.String())
}
args := string(got)
for _, want := range []string{"issues\npost-comment\n", "--only-if-exists\n", "--marker\n", "fullsend-ai/demo\n", "99\n"} {
if !strings.Contains(args, want) {
t.Errorf("fullsend was called without %q; args:\n%s", strings.TrimSpace(want), args)
}
}
}

// TestGeneratedPostScriptOkOnAnOlderFullsendPostsNothing pins the
// degradation path: the runner's fullsend is pinned by the repository, not
// by the CLI that generated the script, so when its post-comment has no
// --only-if-exists the ok path must post nothing and exit 0 rather than fail
// on an unknown flag.
func TestGeneratedPostScriptOkOnAnOlderFullsendPostsNothing(t *testing.T) {
if _, err := exec.LookPath("jq"); err != nil {
t.Skip("jq not installed; the generated post-script needs it")
}
binDir := t.TempDir()
argsFile := filepath.Join(binDir, "args")
// An older CLI: --help lists no --only-if-exists, and any real call
// with that flag would fail — so the stub fails loudly if invoked to post.
stub := "#!/usr/bin/env bash\nif [[ \"$*\" == *--help* ]]; then echo ' --dry-run print what would be posted'; exit 0; fi\nprintf '%s\\n' \"$@\" > " + argsFile + "\necho 'Error: unknown flag: --only-if-exists' >&2; exit 1\n"
if err := os.WriteFile(filepath.Join(binDir, "fullsend"), []byte(stub), 0o755); err != nil {
t.Fatal(err)
}
script := renderPostScriptTo(t, t.TempDir())
runDir := writeRunDir(t, map[string]any{
"iteration-1": map[string]any{"status": "ok", "summary": "All clear", "comment": "All added documentation links resolve."},
})
cmd := exec.Command("bash", script)
cmd.Dir = runDir
cmd.Env = append(os.Environ(),
"PATH="+binDir+string(os.PathListSeparator)+os.Getenv("PATH"),
"ISSUE_URL=https://github.com/fullsend-ai/demo/pull/99",
"GH_TOKEN=test-token",
)
var stderr strings.Builder
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
t.Fatalf("ok on an older fullsend must exit 0, got %v; stderr:\n%s", err, stderr.String())
}
if !strings.Contains(stderr.String(), "nothing to post") {
t.Fatalf("expected the nothing-to-post notice, got:\n%s", stderr.String())
}
if _, err := os.Stat(argsFile); err == nil {
t.Fatalf("an older fullsend must not be asked to post on the ok path")
}
}
1 change: 1 addition & 0 deletions internal/agentnew/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func buildHarness(opts Options, role Role) (*harness.Harness, error) {
Effort: opts.Effort,
PostScript: "scripts/post-" + opts.Name + ".sh",
TimeoutMinutes: opts.TimeoutMinutes,
ReadonlyRepo: role.ReadonlyRepo,
Trigger: opts.Trigger,
Env: &harness.EnvConfig{
Runner: map[string]string{
Expand Down
6 changes: 6 additions & 0 deletions internal/agentnew/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ func TestRoleImageReachesTheHarness(t *testing.T) {
if h.OpenShell == nil || !reflect.DeepEqual(h.OpenShell.Profiles, role.Profiles) {
t.Errorf("role %q: profiles = %v, want %v", name, h.OpenShell, role.Profiles)
}
// readonly_repo must survive into the emitted YAML, not only sit on
// the Role struct: a generated review harness that ships writable
// turns "do not edit files" back into a request.
if h.ReadonlyRepo != role.ReadonlyRepo || h.ReadonlyRepo != (name == "review") {
t.Errorf("role %q: readonly_repo = %v, want %v", name, h.ReadonlyRepo, name == "review")
}
seen[role.Image] = true
}
// Both image constants must be reachable, or one is dead configuration.
Expand Down
11 changes: 8 additions & 3 deletions internal/agentnew/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type Role struct {
Profiles []string
// Image is the sandbox image this role's agents run under.
Image string
// ReadonlyRepo mirrors the fleet: the review harness mounts the target
// repository read-only so the prompt's "do not edit files" is enforced,
// not requested. Set for roles whose fleet harness sets `readonly_repo`.
ReadonlyRepo bool
}

// roleTable is the set of roles `agent new` will generate for. Excluded on
Expand All @@ -60,9 +64,10 @@ var roleTable = map[string]Role{
"contents": "read", "pull_requests": "write", "issues": "write",
"checks": "read", "metadata": "read",
},
Providers: []string{"providers/vertex-ai.yaml", "providers/github-ro.yaml"},
Profiles: []string{"profiles/fullsend-vertex-ai.yaml", "profiles/fullsend-github-ro.yaml"},
Image: config.DefaultCodeImage,
Providers: []string{"providers/vertex-ai.yaml", "providers/github-ro.yaml"},
Profiles: []string{"profiles/fullsend-vertex-ai.yaml", "profiles/fullsend-github-ro.yaml"},
Image: config.DefaultCodeImage,
ReadonlyRepo: true,
},
"coder": {
Name: "coder",
Expand Down
13 changes: 13 additions & 0 deletions internal/agentnew/roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,16 @@ func TestCoderUsesEmbeddedGithubProvider(t *testing.T) {
t.Errorf("coder should use providers/github.yaml, got %v", role.Providers)
}
}

// TestReviewRoleMountsTheRepositoryReadOnly pins the fleet parity the
// authoring skill relies on: the review harness in fullsend-ai/agents sets
// readonly_repo, and the prompt's "do not edit files" is enforcement only if
// the generated harness does too.
func TestReviewRoleMountsTheRepositoryReadOnly(t *testing.T) {
for _, r := range roleTable {
Comment thread
waynesun09 marked this conversation as resolved.
Resolved
want := r.Name == "review"
if r.ReadonlyRepo != want {
t.Errorf("role %s: ReadonlyRepo = %v, want %v", r.Name, r.ReadonlyRepo, want)
}
}
}
Loading
Loading