Skip to content

factory: Jira Cloud connector — feed, replier, jirastub, connect and poll (lane J) - #2476

Merged
santoshkumarradha merged 7 commits into
factory/general-intakefrom
factory/gi-jira
Nov 6, 2026
Merged

santoshkumarradha merged 7 commits into
factory/general-intakefrom
factory/gi-jira

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Lane J of the general-factory wave (docs/design/factory-general/DESIGN.md): Jira Cloud tickets become factory jobs through the inbox, and the ticket gets a comment with the pull request's link.

What changed

  • internal/factory/jira: translates and does nothing else.
    • Client: a typed client for exactly three Jira Cloud REST v3 calls, using basic auth: GET /rest/api/3/search/jql (paginated with nextPageToken), POST /rest/api/3/issue/{key}/comment (ADF), and GET /rest/api/3/myself. Errors are written in a person's words and never carry the token.

    • PlainText / Doc: an ADF description becomes plain text, and a comment's text becomes ADF with its links marked as links.

    • Feed (inbox.Feed, name jira): runs (<person's JQL>) [AND updated >= "<cursor>"] ORDER BY updated ASC and maps each ticket to an inbox.Entry:

      • the key, the browse URL, the summary and the description;
      • the reporter as Name <email>;
      • the ticket's labels plus jira-project:<KEY>;
      • the priority, through one table: Highest→p0, High→p1, Medium→p2, Low→p3, Lowest→none.

      The cursor is the newest updated minus 1 minute, in the account's /myself time zone. When that zone is unknown, the cursor is written in UTC with 14 h of slack, so no ticket is skipped.

    • Replier (inbox.Replier) posts three comments:

      • pr_opened → codeaf opened a pull request: <url>
      • merged → Merged: <url>
      • stuck → the event text
    • Connection: Connect checks /myself and runs one search before it keeps anything.

      • Site, email, JQL and zone go in jira.json in the floor folder.
      • Last read and last error are read from the poll's own source record (store.SourceMeta, written by inbox.PollOnce), never kept a second time. Connect and disconnect clear that record.
      • The token is kept the way the GitHub token is: the app's keys (jira) in app mode, otherwise the profile's jira_token (new internal/config/jira.go).
      • Feed() returns false when not connected. Replier() resolves the live connection on every call.
      • A refused answer carries a typed Reason decided once at the door (reasonOf), so nothing reads a status as a decision, which is the classifier law.
    • jirastub: an httptest fake of exactly those three endpoints. It checks auth and accepts only the JQL shape that Feed sends.

  • Wire (internal/appwire/factory_jira.go): factory.jira_connect, factory.jira_status and factory.jira_disconnect, plus the hello word factory.jira. All three are listed in PROTOCOL.md.
  • Engine and loop (cmd/codeaf/app_factory_jira.go, plus 4 lines in app_factory.go):
    • inbox.Poll(ctx, feed, floor, factoryPollEvery, after) starts beside the GitHub poll in readLoops and pollLoop, with the same after each of them uses.
    • Connect and disconnect restart it.
    • It passes inbox.WithRecipe through the floor's RecipeAt, the same way POST /api/intake does.
    • The replier follows the connection, not the loops. inbox.RegisterReplier("jira", conn.Replier()) runs from the host's mount while connected, and RegisterReplier("jira", nil) runs on disconnect.
    • While not connected, no loop starts.
    • Only the factory on this machine can be connected in wave 1.
  • Manual: internal/manual/chat/factory-jira.md (connect, tickets become jobs, which tickets/JQL, routing via jira-project:, the PR-link comment, disconnect/status, limits), with 10 new retrieval probes.
    • Two edits outside this lane, both in factory.md:
      • Lane I's heading now also says "the same ticket sent twice", so its probe reaches that page instead of the Jira one.
      • Lane R's "a mark on the board" now reads "a mark on the job", because the resident-vocabulary gate refused it.
  • Routing seam test: a ticket polled through the real inbox is matched by sources: [jira] + labels: [jira-project:FL] and not by OPS or github rules.

Not in this PR

  • factory serve (the team host) gets no Jira loop, because nothing can connect it. The wire reaches only the app's local host.
  • In app mode the token is held for the current launch only. The desktop has to keep the jira key in its keychain and hand it back with keys.set, the way it does for github.

Proof

make test-focus PKGS='./cmd/codeaf ./internal/factory/jira/... ./internal/appwire' RUN='^(TestJira…|TestTheJiraPoll…|TestFactoryJira…|TestTheProtocolDocument…|TestADF…|TestDoc…|TestPriorityTable|TestClient…|TestFeed…|TestReplier…|TestConnection…|TestNormalizeSite|TestAnUnknownZone…)$$'
ok  cmd/codeaf  ok  internal/factory/jira  ok  internal/appwire   (also with -race)
go test ./internal/manual/   ok
make test-laws               ok

make pr-ready BASE=e5effe0b2: every touched package except cmd/codeaf is green.

cmd/codeaf had 7 failures:

  • 4 fail identically on base e5effe0 with "say which repository the work is on":
    • TestTheManagersEditOfARunningJobIsNotLostToItsWorker
    • TestAWindowsLaunchRunsOnTheWorkerAndLands
    • TestARunTheWorkerRefusesGoesBackWithItsReason
    • TestFactoryStartLaunchesContinuesAndSaysWhy
  • 3 pass on both branch and base when run alone; they failed under load:
    • TestAppFactoryPlanFilesAnswer
    • TestGuardOwedAbsoluteMeasuredCommand
    • TestHostedTakeBackReachesAcquireWithoutSharedUploadsOrReleaseDelay

TestTheJiraPollFollowsTheConnection runs on the real inbox: ticket → job (Highest → urgent) within one poll → PR comment on the ticket while connected → no comment after a disconnect.

🤖 Generated with Claude Code

… and poll

internal/factory/jira translates Jira Cloud REST v3 into the inbox:
Feed runs the person's JQL narrowed by an updated cursor (account zone,
one minute overlap) into inbox.Entry values with a jira-project:<KEY>
label and Jira priority mapped p0-p3; Replier comments the pull request
link on open and merge and the job's words when stuck. jirastub fakes
exactly /myself, /search/jql and /issue/{key}/comment.

factory.jira_connect/_status/_disconnect connect this machine's factory,
checking /myself and one search before keeping anything; the token is
kept like the GitHub one. The Jira poll starts beside the GitHub poll
only while connected and restarts on connect and disconnect.
…e door

The classifier law forbids reading a status as a decision outside the
fact packages; IsAuth now reads the Reason the client stamped.
…ipes, one health record

The Jira answerer is registered from the host's mount while connected and
unregistered on disconnect, independent of the read loops. The poll passes
inbox.WithRecipe through the floor's RecipeAt, as POST /api/intake does.
Status reads last read and last error from the poll's own source record
(store.SourceMeta) instead of a second file. The poll-wiring test now
asserts ticket → job → PR comment, and silence after a disconnect.
… one

The asker's word is ticket; the heading that answers it now says so, and
the Jira page points there instead of restating the rule.
Lane R's priority section used the resident's word, which the chat
manual gate refuses.
@santoshkumarradha
santoshkumarradha merged commit a8b3cfb into factory/general-intake Nov 6, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the factory/gi-jira branch November 6, 2026 21:49
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