Repository navigation
🐛 Filter em-dashes on every outbound path, agent proxy writes included - #19110
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review follow-ups: 2 open of 2 (below
|
There was a problem hiding this comment.
Style review (head 39fa502): conventions are followed and the structure is clean, with one filter in crux, pkg delegating, an inventory CI guard, a changelog fragment and docs. One low-severity readability note is inline; no blockers.
-- hive: agent=adjudicator-4 backend=claude model=claude-sonnet-5-5 claude=2.1.327
| } | ||
|
|
||
| // graphQLProseMutationRe matches any name in graphQLProseMutations as a whole | ||
| // word. A substring test is the right posture here, unlike for a permission |
There was a problem hiding this comment.
Comment says 'A substring test is the right posture' but graphQLProseMutationRe is a whole-word match (\b(...)\b). Suggest rewording:
| // word. A substring test is the right posture here, unlike for a permission | |
| // word. Matching the name anywhere in the document is the right posture here, unlike for a permission |
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the GitHub egress proxy may rewrite agent request bodies after its gates, and the push broker amend the agent's HEAD commit message, to enforce the dash rule.
Routing, not a defect report: this PR changes proxy and push-broker behaviour (trust surface), so a person should accept it.
What I read: src/crux/proxy/outbound_prose.go (runs after every gate, JSON-only, skips git/LFS/non-JSON, 1 MiB cap forwards unchanged, Content-Length and chunking reset only when a field changed) and src/crux/pushbroker/commit_message.go plus its call site at pushbroker.go:218-232 (best-effort amend, HEAD re-read after). I found no correctness defect in those paths.
The decision: after this lands the proxy mutates what an agent sent to GitHub/Linear, and the broker changes the pushed HEAD sha. Both are reasonable for the rule in #19103, and both are switchable via HIVE_AGENT_PROSE_FILTER=false, but they are a policy choice on a trust boundary rather than an engineering detail.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
|
hive/scanner: the failing 🐝 Hive Agent: |
|
Scanner: the only red check is 🐝 Hive Agent: |
The #18970 filter covered hive's own GitHub writes but not text agents send themselves through the egress proxy, so a gh api comment kept its em-dashes. Move the one shared filter into the crux module so the proxy uses it, rewrite JSON text fields of allowed agent writes (REST and the comment, review, PR and issue GraphQL mutations), rewrite the HEAD commit message in the push broker, and route notifications, Discord, meeting chat and speech, hub posts, Linear, Jira and DIBS writes through it. A new inventory test fails CI when an outbound HTTP send is added without the filter or a stated reason. Fixes #19103 Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
…best-effort Hub self-report bodies carry the fleetreport affected-hives block, which is parsed back by its separators, so only their titles are filtered. The Linear digest filters before its skip-if-unchanged compare and its footer is now plain ASCII (the old marker is still matched). The persona voice sample is operator-only and stays out of the dashboard import ratchet. A failed commit-message rewrite is logged and never blocks a push. Signed-off-by: Andy Anderson <andy@clubanderson.com>
42fcc4e to
b02e6bc
Compare
There was a problem hiding this comment.
Two required checks are red on head b02e6bc, and both come from this diff. I read the proxy hook, src/crux/proxy/outbound_prose.go and the push broker amend path against the PR body; the design holds up.
Blocking CI (verified in the job logs)
relative links and anchors resolve:DRIFT src/docs/design/session-taint.md:84 src/crux/pushbroker/pushbroker.go:244 -> lacks anchor(s) near cited range: FindSecret. Adding thesanitizeHeadCommitMessagehook inpushbroker.goshifted the cited line. Fix:python3 src/scripts/check-docs-citations.py --fixand commit the doc change.coverage:crux/pushbroker: 98.3% (floor 99%). The newcommit_message.gohas error branches (os.CreateTemp,WriteString,Close) that the listed amend/read-failure tests may not reach. I did not map the uncovered lines, so check the per-function profile forrewriteHeadCommitMessage.
What I checked and found sound
- The proxy filter runs after every gate has read the body as the agent sent it, only on POST/PATCH/PUT with an empty or JSON content type, skips git paths, and forwards bodies over 1 MiB unchanged rather than truncating them. Content-Length is reset and
TransferEncodingcleared only when a field actually changed. - GraphQL handling rewrites only
variables, and only when the query is a mutation naming a listed prose mutation, so query text is never altered. - Amend uses
--only --cleanup=verbatim, so the agent's staged changes stay out of the commit and trailers survive.
Open question for the author, not a defect: the 1 MiB pass-through means an agent that sends an oversized body skips the filter silently. The debug-only logging gives an operator no signal for that case.
Both blockers are mechanical. Once they are green this looks correct to me; merge stays a human call.
-- hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327
…on-taint citations The commit-message rewrite staged the text through a temp file whose create, write and close failures cannot be driven from a test, and the missing-blank-line check was unreachable because an empty message has no dash. Passing the message as one -m argument removes those branches; the amend-failure path stays covered by the existing fail-open test and the success log is now asserted. The secret-gate citations in session-taint.md move to the shifted line. Signed-off-by: Andy Anderson <andy@clubanderson.com>
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether the egress proxy may rewrite agent-authored request bodies after its gates ran, and whether the push broker may amend an agent's HEAD commit, as proposed here.
Routing, not a defect report. I read the proxy hook, outbound_prose.go, SanitizeJSON and the push broker change against the base tree. I found no verified bug in the proxy path, but this PR changes trust surfaces (egress proxy request handling, push broker commit rewriting), so a person should sign off.
What I checked and found sound:
sanitizeAgentWriteProseruns after every gate has read the body (github_proxy_mitm.gohook), skips git and LFS paths, non-JSON content types, the internal caller and bodies over 1 MiB, and fixesContent-LengthandTransferEncodingonly when a field changed.SanitizeJSONleaves numbers exact (UseNumber) and returns the original bytes when nothing changed.- GraphQL handling filters only
variables, never query text, and only for mutations ingraphQLProseMutations.
What a maintainer should decide:
- The proxy now mutates agent-authored bodies that other gates previously saw verbatim. That is a policy choice about the proxy's role, and it is the same surface #19072 and #19007 touch.
rewriteHeadCommitMessage(src/crux/pushbroker/commit_message.go) runsgit commit --amendundergitEnv(), which setsGIT_AUTHOR_*andGIT_COMMITTER_*to the lane identity. Open question, not verified: if HEAD was authored by a different identity, the amend would reassign the author, and the sign-off guard nearpushbroker.go:484requires the lane's own Signed-off-by when both identities match the lane. Please confirm the guard cannot then reject a push that passed before, or that this matches whatstripTrailingBlankLinesalready does.- Size: about 2000 added lines across 39 files, with a lot of outbound sites touched at once. The
TestOutboundSitesInventoryguard is a good idea, but it is a lot for one review. Splitting proxy plus push broker from the notification and Discord hooks would make each half reviewable.
CI was still running when I read this (golangci-lint, build, several test shards).
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
|
@clubanderson this PR is back in your court (
Once the new head lands, CI and the review swarm re-run automatically and the PR returns to the normal path. Current head: |
|
Scanner triage: 🐝 Hive Agent: |
|
Scanner triage: the failing checks here (native-queue-policy, Sign-off survives the squash) are not on the default branch; the branch is behind v5 and the checks are stale. Suggested fix: merge the base branch into this branch (signed off) and let CI re-run. This is a human-authored branch, so I am not pushing. 🐝 Hive Agent: |
|
Scanner triage: baseline check says this branch is behind its base by 16 commits and the failing checks (native-queue-policy, Sign-off survives the squash) are not shared with the base branch. Suggested fix: merge the base branch into this branch (signed off, 🐝 Hive Agent: |
…bound-sites inventory It replays the model prompt to the inference backend, like its sibling retryInferenceOnAuthFailure, so it is a machine send site, not prose. Signed-off-by: Andy Anderson <andy@clubanderson.com>
f65da8c to
c8d3d6c
Compare
Fixes #19103
Root cause
#18970 added the shared dash filter in
src/pkg/prosefilterand applied it to hive's own GitHub writes. Agent writes made withgh apigo through the MITM egress proxy, andproxyHTTPHostinsrc/crux/proxy/github_proxy_mitm.goforwarded an allowed write withreq.Write(upstream)(the forward at the end of the request loop) without ever touching the body. The proxy lives in the nestedcruxmodule, which cannot importpkg/, so no proxy path could call the filter.What changes
crux.src/crux/prosefilternow holds the implementation (same replacement rule as ✨ Stop hive from writing em-dashes: shared outbound filter, ASCII trailer, base-prompt rule, ratchet test #18970, code fences, inline code and blockquotes untouched) plusSanitizeJSON, which applies it to string values under named JSON keys at any depth.src/pkg/prosefilteronly delegates.sanitizeAgentWriteProse(src/crux/proxy/outbound_prose.go) runs after every gate, just before forwarding. It rewrites RESTbody/title/message(reviewcomments[].bodyincluded), thebody/titlevariables of comment, review, review-thread reply, PR and issue GraphQL mutations, and Linear mutationbody/title/description. It never touches non-JSON bodies, non-JSON content types, other fields, the GraphQL query text, git smart-HTTP or LFS traffic, or hive control-plane requests. Content-Length is recomputed; oversized bodies (over 1 MiB) are forwarded unchanged. One debug line with counts, never text.src/crux/pushbroker/commit_message.go), using--cleanup=verbatimso only dashes change. Best-effort: a read or amend failure is logged and the push goes ahead unchanged. Older commits in a multi-commit push are not rebased; the squash commit hive writes is filtered (MergePRVia), so what lands on the default branch is clean.HIVE_AGENT_PROSE_FILTER(default on) turns off rewriting of agent-authored text (proxy and commit message). Hive-composed text is always filtered, as in ✨ Stop hive from writing em-dashes: shared outbound filter, ASCII trailer, base-prompt rule, ratchet test #18970.addPlainDashRule). Unchanged.TestOutboundSitesInventory(src/pkg/prosefilter/outbound_sites_test.go) AST-scanssrc/pkg,src/cmdandsrc/cruxfor every function that sends an HTTP request with a body, in the style of the notification write-site inventory. Each must be classed filtered (calls the filter), via (a named filtered function upstream), template (source under the emit ratchet), or machine (with a reason). A new sender that is not listed, or a filtered site that stops calling the filter, fails CI. It also pins the proxy, push broker, relay, PR, merge and notification boundaries. The emit ratchet now also coverspkg/forge,pkg/feedbackbundleandpkg/fleetreport.Outbound inventory
relayBody,CreatePR, issue-request watchercreateCommitOnBranchsanitizeAgentWriteProseMergePRVianotify.(*Notifier).Sendhub.sendSlackDMdiscord.(*Bot).do,setChannelTopicpostDiscordRequestWebhook,GitHubActivityFeed.postDiscordpushAuthAuditAlertchat.post,say,say.prewarm)meetings.(*Client).postpostHubGitHubIssuepkg/fleetreporttemplatesPostDigestlinearGraphQL,jiraSource.doJSONlinearagent.doGraphQLDibsDestination.Deliverpkg/forgeTests
proxyHTTP.SanitizeJSONtable test, switch test.Follow-ups
pkg/fleetreportstill renders em-dash separators in the affected-hives block and seen log (held by the emit ratchet); moving them to hyphens needs a parser that accepts both forms for already-filed issues.Coordination: PR #19107 (opened by the hive scanner agent) reached the same design independently: the filter moved into
crux/prosefilterwithpkg/prosefilterdelegating, and agent writes filtered in the egress proxy. Its tests (comment, review and GraphQL, other fields untouched, switch off) are covered by the proxy table test here. #19107 is closed as superseded by this PR.Kept to new files and small hooks. The only shared-file edits in
src/crux/proxyare one field ingithub_proxy.goand one call before the git-path branch ingithub_proxy_mitm.go, away from the hunks in #19072 and #19007.🤖 Generated with Claude Code