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
62 changes: 62 additions & 0 deletions docs/contributing/runtime-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,68 @@ The post-run output scan skips `<runDir>/skills/` and
origins and warnings are documented in
[Configuring with Skills § The persona list file](../guides/user/customizing-with-skills.md#the-persona-list-file).

### The post-run output scan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] documentation-accuracy · divisor-guard

This section describes the token-preserving JSON walk, fail-closed markers, and ::error:: annotations in present tense as live behavior. At this head, internal/cli/run.go still performs only pipeline.Scan(text) with no structural path. Operators reading this will expect JSON-valid redaction guarantees this merge does not deliver. Could the docs mark the behavior as arriving with the follow-on PR in the stack?


`scanOutputFiles` runs the output pipeline (Unicode normalization, then secret
redaction) over every file under the run directory (`<runDir>/`, including
`iteration-N/` transcripts) except the skips above, any directory named
`security` (which holds `findings.jsonl`), and the telemetry JSONL.

A file whose content is one JSON document — or two or more newline-delimited
ones — is sanitized structurally, so redaction never changes its syntax. The
document is rewritten by a token-preserving walk rather than decoded into a map
and re-encoded: member order and duplicate keys survive, so an earlier value that
map decoding would drop is still scanned. Each object key and string value is
scanned on its own; a value whose member name marks it sensitive (key, token,
secret, password, credential, auth) is masked even when the value matches no
pattern, and a sanitized key name that would collide with a different member is
disambiguated (`<key>_<N>`). A leading UTF-8 BOM is stripped before the walk and
restored on write, and a clean document comes back byte for byte.

After the rewrite the serialized bytes are scanned once more, but only for
whole-value secrets — registered runtime values and private-key blocks — because
those are the only matches a leaf scan cannot see once a member value is masked.
Every other pattern has already been applied to the decoded key or value, so a
match on the serialized bytes would be a redaction placeholder plus JSON escape
characters, not a secret (#5705).

A private-key block can also span members or records: one string holds the BEGIN
marker, another the body, a third the END marker. Masking any of them would hide
the marker from every later scan, so such a block is detected on a decoded view
of the document or stream before anything is rewritten, and handled where it
lives. The members the match starts and ends in carry marker text, so they are
always masked — even when a marker is split across two members and neither
fragment looks like one alone. A member in between is masked when it carries a
block marker, a run that looks like body material (16+ base64 characters mixing
upper case, lower case and a digit, and not hex only), or when the joined text of
consecutive members does, which is what catches a body split into short chunks. An
object key keeps its name unless the name itself is block content, so a document
that merely quotes the PEM header in one finding and the footer in another keeps
the shape `review-result.schema.json` accepts, including its enum-valued fields.
A body split so that one-character and longer chunks alternate is a known
residual; uniform chunks and complete body lines are masked. Records that carry
part of a block across a record boundary are replaced with a fail-closed marker
instead, because the framing itself cannot be rewritten.

Some content cannot be redacted in place. A JSON document or JSONL record is
replaced with a valid fail-closed marker instead — never with corrupted
syntax — when a redaction would invalidate the JSON or a match spans record
boundaries. Markers look like `{"error":"output removed because …"}` and are
logged as findings in `security/findings.jsonl`. Because a replaced file loses
everything the agent wrote into it and the run still exits 0, the reason a
marker states is also emitted as a `::error::` workflow command whenever the job
sets `GITHUB_ACTIONS=true`. GitHub Actions renders it as an error annotation.
Forgejo Actions also sets `GITHUB_ACTIONS=true`, so its runner writes the same
line, but Forgejo has no annotation view: the line appears in the step log and
the exit status stays 0. On GitLab the line is not written at all.

A file that cannot be read, sanitized or written does not stop the walk: every
remaining file is still scanned and redacted, and the run fails closed afterwards
with all failures joined. The unredacted file is replaced with the fail-closed
marker so its bytes do not reach the uploaded artifact when the filesystem allows
it; if the marker write and the fallback removal both fail, that failure is added
to the joined error rather than left unreported.

## Agent rule layering

When `fullsend run` executes an agent, Claude Code loads instructions from
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/dev/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ cut can take the `@` that marks a password and the tail cut the `https://`
before it (`promptHidesAlterations`) — is recorded `***` whole; the
prompt the agent is sent is not changed, and the mask the first
scan leaves for a connection-string password of ten or more bytes matches
its own pattern and counts a finding —
its own pattern, counts a finding, and is itself masked `***` —
and sets `gen_ai.input.messages` on the span
before the runtime starts, so each finalize path carries it. Its findings
join the iteration's, and its encoded size is charged against
Expand Down
18 changes: 17 additions & 1 deletion docs/guides/user/run-artifacts-and-private-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,23 @@ Tool results in those files can quote what the agent read, such as the text
of a private Jira issue. On a public repository, any signed-in user can
download the artifact until it expires. The output scan masks secret
literals; it does not remove personal data, customer names or other private
business text.
business text. A secret that cannot be localized replaces the whole JSON
document, or the JSONL record that carries it, with a JSON error marker, and a
file whose redacted content cannot be read, written or computed is replaced by
such a marker and fails the run. If the marker cannot be written and the file
cannot be removed either, the run's error says the unredacted file is still on
disk. A private-key block that spans JSON members is handled in place instead:
object keys keep their names unless a key name is itself a line of the key body,
and each string value — or key name — that carries block text or base64 key
material becomes `[REDACTED PRIVATE KEY]`. When a
replacement happens in a run that still exits 0, the job log says so. On GitHub
Actions this is an error annotation: fullsend writes a `::error::` workflow
command whenever the job sets `GITHUB_ACTIONS=true`, and GitHub Actions renders
it. Forgejo Actions also sets `GITHUB_ACTIONS=true`, so the same `::error::`
line is written there, but Forgejo has no annotation view: its runner prints the
line in the step log and the exit status stays 0. On GitLab the line is not
written at all, so the run's log is the signal. A read, write or sanitize
failure needs no annotation because the run itself fails.

`fullsend run` leaves `output/` untouched. At the end of the job,
`fullsend prepare-artifacts` builds a filtered copy at the level you set, and
Expand Down
5 changes: 3 additions & 2 deletions internal/cli/content_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ func attachContent(span trace.Span, res contentResult) {
// values, once more after the fold, which can spell out a value that pass
// saw in compatibility forms. The mask that first scan leaves for a
// connection-string password of ten or more bytes ("abcd...") matches its
// own pattern again, so such a prompt counts a finding here; a shorter
// password is masked "***", which does not.
// own pattern again, so such a prompt counts a finding here and the
// placeholder is masked "***"; a shorter password is masked "***", which
// does not match.
// The pipeline also folds compatibility characters the agent received
// unfolded. Findings join the iteration's and surface through Result.
//
Expand Down
Loading
Loading