Skip to content

factory: comment on a job's issue from the app, and the manager's read of each new comment - #2109

Merged
santoshkumarradha merged 5 commits into
app/v3from
feat/c25-d-issue-comment
Nov 2, 2026
Merged

santoshkumarradha merged 5 commits into
app/v3from
feat/c25-d-issue-comment

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

What the job page needs

The job page's Issue tab lets people comment on the job's GitHub issue without leaving the app, and draws one quiet line under each comment the manager handled ("Manager read this · …"). This PR is the engine side of both.

Wire

Hello features (the app hides the comment box and the read lines unless announced):

  • factory.issue_comment: the engine serves the method below.
  • factory.issue_comment_reads: job reads carry comment id/url and desk.comment_reads.

factory.issue_comment

Params (strict):

{"factory": "<connection id>", "job": 12, "body": "please cover the batch path too"}

body is trimmed and must be 1 to 8000 characters (factory.IssueCommentMost). No expect: a comment changes nothing the person read.

Result:

{"factory": {...}, "job": 12,
 "comment": {"author": "alice", "body": "…", "at": "2026-10-16T12:00:00Z",
             "id": "4401", "url": "https://github.com/acme/api/issues/12#issuecomment-4401"}}

Errors: bad_params (empty or too long; also an empty body from the factory's 422), conflict (the job has no GitHub issue, or the factory is older than the route: "This factory doesn't support that yet…"), forbidden ("Your GitHub sign-in can't comment on owner/repo (HTTP 403); nothing was posted", for GitHub 403/404/410), signed_out/github_expired (GitHub 401; a factory sign-in token is ended), busy (GitHub 429), uncertain (transport failure, 5xx, or a yes without a receipt; the comment may have posted, nothing is retried).

Factory route: POST /v1/jobs/{id}/issue_comment with {"body": "…"} → api.IssueCommentPosted. The comment is posted as the caller with the token of their own factory sign-in, never a host token; a solo factory uses its host's token (the host is the person), exactly as the pipeline pull request does. The words go as written, with no publication marker. The posted comment is added to the job's cached comments at once, so the next job read carries it.

Job read additions (desk)

desk.comments[] gains optional fields: id, url, tier (owner | collaborator | stranger, the author's standing on the repo), by_factory (the factory's own publication comment).

desk.comment_reads[] (absent when none):

{"comment_id": "4401", "at": "2026-10-16T12:01:00Z", "outcome": "asked",
 "line": "asked you in the manager chat whether the plan should change"}
outcome when line
context author has no write access to the repo read as context · no write access to the repo
nothing job finished the job is finished · nothing to change
nothing job not started the job hasn't started · its plan reads the issue's comments
asked write access, job with a run under way asked you in the manager chat whether the plan should change
adopted reserved, never produced yet —

An asked read also adds a manager line to the job's conversation (desk.thread, id comment_<comment id>): @raj commented on the issue: “…”. I don't change the plan from a comment on my own. Should the plan change for it? Reply here with what to do.

How reads are decided

  • The GitHub source now keeps each comment's id and page, asks the author's standing (the existing per-process Permission cache), and marks the factory's own publication comments.
  • factory.ReadComments (pure) runs inside the poll's merge, the one place the floor learns of comments. The comments a job first reads are its context and get no read. Every later comment with an id gets exactly one read. A comment posted from the app waits until the poll reads its author's standing (about a minute), so it is handled by the same path as any other comment. The factory's own comments get none. Reads keep the newest 20.

The engine cannot tell a comment that narrows scope from one that widens it deterministically, so this first version never adopts. Every comment from someone with write access on an active job becomes an ask. The ask is a line in the manager conversation, not the job's blocking needs-you question: that question belongs to the run's own state machine, and a GitHub read must not change it under a running step. The person's reply in the manager chat reaches the manager as any reply does. No model is called.

Tests

  • internal/factory: TestReadCommentsFirstReadIsTheBaseline, TestReadCommentsOutcomes, TestReadCommentsWhenNoRunIsUnderWay.
  • internal/factory/github: TestMergeHandsNewCommentsToTheManager. TestReadCarriesThePageCommentsFilesAndChecks now also checks the comment id, URL, tier and the factory marker read through the real forge client.
  • cmd/codeaf: TestAppFactoryIssueCommentAgainstTheRealServer runs the wire, the real factory server and store, with a GitHub in the test. It covers: hello announces both features; a person posts as themselves with their own token and the words alone; the next read carries the comment; the poll's read records one asked read and the manager line; GitHub 403 is forbidden and the job is unchanged; empty or too-long words are refused before GitHub; a job with no issue is refused; an older factory's missing route is "doesn't support that yet".
  • api.TestEveryFieldRoundTrips: Item.CommentsSeen is service-only and listed in Lost; the other new fields round-trip.
  • No live model was used: nothing here calls a model.
  • make test-touched BASE=origin/app/v3 passes. cmd/codeaf TestProcessActionsOpensALightCrewOwnerOnce was judged flaky; praf/github TestFilesChecksAndOneIssue already fails on app/v3. make manual-gates passes. make pr-ready stops at changelog-check on entries already on app/v3 that are not this PR's; this PR's entry passes.

Limits

  • An asked comment does not pause the job or show as needs-you; it is a manager-chat question.
  • The manager model is not handed the comment as input. Step briefs already carry the issue's last three comments.
  • Reads appear after the factory's next GitHub read of the issue (about 60s); the app shows "Manager is reading…" until then.
  • Comment write needs a token that can write issues. The team sign-in asks for read:user repo, which can. A token without it is refused as forbidden.
  • Older factories send no id, url or comment_reads; the app shows no read line.

…e manager's read of each new comment

factory.issue_comment posts the person's words on the job's GitHub issue with
their own sign-in and keeps the comment on the job. The poll's read of every
new comment records what the job's manager did with it (comment_reads):
context for people without write access, an ask in the manager conversation
on a job with a run under way, nothing on a job not started or finished. The
first version never adopts a comment on its own.
…mment

# Conflicts:
#	internal/factory/api/jobs.go
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 2, 2026 01:03
@santoshkumarradha
santoshkumarradha merged commit 986887a into app/v3 Nov 2, 2026
@santoshkumarradha
santoshkumarradha deleted the feat/c25-d-issue-comment branch November 2, 2026 01:03
santoshkumarradha added a commit that referenced this pull request Nov 2, 2026
…y declares

#2109 and this branch each added the same constant and the same helper with
identical bodies; the merge keeps app/v3's declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 2, 2026
…newest or its stub (#2111)

* factory: a job keeps its brief versions, and factory.job_brief reads the newest or its stub

The job keeps its last 20 BriefVersions on the item. The facts row is
computed from the steps' structured results (test counts or exit,
findings, proof claims shown of total, rule checks), and a job with no
version is answered a stub from engine data alone. GET /v1/jobs/{id}/brief
answers the newest version, its status and the keys changed since a rev;
the job read carries the brief's rev and status. The Brief block palette
is Go types with its limits as faults. The hello says factory.job_brief.

* factory: gofmt the brief mark

* factory: one spelling for a route a factory does not serve; brief write states are status words

* changes: the job brief entry

* factory: keep the one EndpointNotFound and routeMissing app/v3 already declares

#2109 and this branch each added the same constant and the same helper with
identical bodies; the merge keeps app/v3's declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 2, 2026
…cked by the factory before it is kept (#2116)

* factory: a job keeps its brief versions, and factory.job_brief reads the newest or its stub

The job keeps its last 20 BriefVersions on the item. The facts row is
computed from the steps' structured results (test counts or exit,
findings, proof claims shown of total, rule checks), and a job with no
version is answered a stub from engine data alone. GET /v1/jobs/{id}/brief
answers the newest version, its status and the keys changed since a rev;
the job read carries the brief's rev and status. The Brief block palette
is Go types with its limits as faults. The hello says factory.job_brief.

* factory: gofmt the brief mark

* factory: one spelling for a route a factory does not serve; brief write states are status words

* changes: the job brief entry

* factory: the brief's writer, one small errand on the job's agent, checked by the factory before it is kept

The factory assembles the writer's input (issue, plan, each step's try,
change stats and hunk index, rules, facts, the brief before) and hashes it;
POST brief/begin decides whether to write (unchanged inputs, a write under
way, the cost guard of $0.03 a version and 5% of the job's spend, held
back except for an ask, the end or a retry) and marks it generating. The
engine asks the job's agent one errand under the new brief role on the
small-work tier and hands the answer to POST brief/keep, which checks it
against the job (palette limits, evidence that exists, every number in its
evidence), keeps what passes, counts the drops and books the cost to the
job. Runner progress news and step or model edits trigger it, ten seconds
debounced. factory.job_brief_write is the page's Retry; the hello says
factory.job_brief_writer.

* factory: the change's stat is evidence of its own; the replay prices the brief role as an errand

* factory: one rule for the triggers the cost guard lets through

* changes: the brief writer entry

* factory: keep the one EndpointNotFound and routeMissing app/v3 already declares

#2109 and this branch each added the same constant and the same helper with
identical bodies; the merge keeps app/v3's declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
santoshkumarradha added a commit that referenced this pull request Nov 2, 2026
…t reads it (#2119)

* factory: a job keeps its brief versions, and factory.job_brief reads the newest or its stub

The job keeps its last 20 BriefVersions on the item. The facts row is
computed from the steps' structured results (test counts or exit,
findings, proof claims shown of total, rule checks), and a job with no
version is answered a stub from engine data alone. GET /v1/jobs/{id}/brief
answers the newest version, its status and the keys changed since a rev;
the job read carries the brief's rev and status. The Brief block palette
is Go types with its limits as faults. The hello says factory.job_brief.

* factory: gofmt the brief mark

* factory: one spelling for a route a factory does not serve; brief write states are status words

* changes: the job brief entry

* factory: the brief's writer, one small errand on the job's agent, checked by the factory before it is kept

The factory assembles the writer's input (issue, plan, each step's try,
change stats and hunk index, rules, facts, the brief before) and hashes it;
POST brief/begin decides whether to write (unchanged inputs, a write under
way, the cost guard of $0.03 a version and 5% of the job's spend, held
back except for an ask, the end or a retry) and marks it generating. The
engine asks the job's agent one errand under the new brief role on the
small-work tier and hands the answer to POST brief/keep, which checks it
against the job (palette limits, evidence that exists, every number in its
evidence), keeps what passes, counts the drops and books the cost to the
job. Runner progress news and step or model edits trigger it, ten seconds
debounced. factory.job_brief_write is the page's Retry; the hello says
factory.job_brief_writer.

* factory: the change's stat is evidence of its own; the replay prices the brief role as an errand

* factory: a brief's spot opens on its own hunks with the writer's notes; factory.job_brief_spot reads it

Spots are numbered as a version is kept, and a spot may carry the writer's
one-line notes on its hunks, each checked to name a hunk of its file.
GET /v1/jobs/{id}/brief/spots/{spot} answers the hunks of the spot's file
in the job's change, narrowed to its symbol when a hunk names it, with the
notes as annotations after their hunks. The hello says
factory.job_brief_spot.

* factory: one rule for the triggers the cost guard lets through

* changes: the brief writer entry

* changes: the brief spot entry

* factory: keep the one EndpointNotFound and routeMissing app/v3 already declares

#2109 and this branch each added the same constant and the same helper with
identical bodies; the merge keeps app/v3's declarations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant