Skip to content

gitlab: pull_request and push triggers on the op-pipeline generator, and a merge-request note activity - #2268

Merged
lex00 merged 5 commits into
mainfrom
feat/2256-gitlab-op-triggers-mr-note
Sep 8, 2026
Merged

lex00 merged 5 commits into
mainfrom
feat/2256-gitlab-op-triggers-mr-note

Conversation

@lex00

@lex00 lex00 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2256.

Rebased onto main at 8244ba0, which is #2264's squash-merge of #2257. No longer stacked: this branch is five commits on top of current main and merges on its own.

The gitlab op-pipeline generator was cron-only and refused four things by name. Two of those refusals were wrong about GitLab rather than about chant.

Refusals that went away

Refusal Why it went Replaced by
"pull_request" trigger, but GitLab has no pull_request/push event model (#2084) $CI_PIPELINE_SOURCE == "merge_request_event" exists on every pipeline and rules: selects a job on it a rule per target branch on $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
the same refusal for a "push" trigger $CI_PIPELINE_SOURCE == "push" likewise $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "<branch>", defaulting to main
findingMode "comment" ... chant has no GitLab merge-request note activity (#2231) it has one now reconcilePr writes an MR note by the same marker/edit-in-place recipe
adds permissions { id-token: write } ... chant does not generate id_tokens: the refusal already named the shape to reach for id_tokens: { CHANT_ID_TOKEN: { aud: $CI_SERVER_URL } }

Refusals that remain

  • findingMode: "comment" on a cron or push trigger. Not a forge gap: the mode posts onto the merge request that triggered the run, and neither trigger has one. This is exactly the refusal the github generator already makes, on the same terms, and it is asserted on both forges.
  • A setup step spelled uses:. A GitLab job runs script lines and nothing else, so there is no shape to translate a marketplace action into.
  • Every additive permissions scope except id-token: write. GitLab has no per-job token-scope mapping at all, and a silently dropped scope emits a job that reads as granted and runs with nothing. id-token: read is refused too: GitLab either mints the token into the job or does not.
  • A branch name carrying ", $ or \ in a trigger filter (new). A rules: if-expression is a string GitLab parses; a quote would end it early and a $ would expand as a variable, either of which silently changes which pipelines run the job.
  • findingMode: "issue" and "merge-request" are still GitHub-only in practice. reconcilePr implements them by shelling to gh issue create / gh pr create; only the comment mode grew a GitLab path. Not in scope here, and not newly broken — flagged below.

What is in each commit

  1. feat(op): a merge-request note activity … — reconcilePr comment mode gains a GitLab half in the same activity, not a second one. mergeRequestContextFrom is the whole forge detection: only a merge_request_event pipeline sets CI_MERGE_REQUEST_IID, so a run that has it is unambiguously GitLab and a GitHub run never reaches that branch. A fork's merge request runs its pipeline in the fork, so the note goes on CI_MERGE_REQUEST_PROJECT_ID in preference to CI_PROJECT_ID. Over fetch, not a CLI: gh ships on GitHub's hosted runners and is already this activity's dependency, glab ships on no GitLab runner and would fail on the node:22-slim image the generator emits. Also gives writeGatedRunSummary a CHANT_GATE_SUMMARY surface, since GitLab has no step summary.
  2. feat(gitlab): the merge_request and push triggers … — the generator.
  3. test(gitlab): re-pin #2257's byte fixture … — see "One test of feat(ops): an environment option on a scheduled Op, so a deployment-protection reviewer can gate the generated apply (#2257) #2264's that I moved".
  4. docs(terraform): plan-on-pr gains a gitlab generation … — the example and its assertions.
  5. docs: the three pages that said GitLab refuses ….

The token, which the issue and I disagree on slightly

The issue says POST /projects/:id/merge_requests/:iid/notes with CI_JOB_TOKEN. That endpoint is not on GitLab's job-token allowlist on current versions, so CI_JOB_TOKEN alone would 401 on most projects. gitlabNoteTokenFrom therefore resolves CHANT_GITLAB_TOKEN → GITLAB_TOKEN → CI_JOB_TOKEN, and sends the first two as PRIVATE-TOKEN and the last as JOB-TOKEN, which are two different headers for two different credentials rather than a fallback. A project access token with api scope is enough; CI_JOB_TOKEN still works on an instance whose allowlist covers notes. The generated header already named GITLAB_TOKEN for every non-report mode, so this is the variable the file was asking for anyway. A merge-request pipeline with neither says which variable to set.

The gated apply, without a notice job

GitHub gets --gated-exit 0 --json, job outputs, and a follow-up job that posts on the merged pull request. GitLab gets --gated-exit 0 and no --json, because the two surfaces GitLab has are the job log — where chant run's human render of the gate already goes — and an artifact:

app-apply:
  variables:
    CHANT_GATE_SUMMARY: chant-gate-app-apply.md
  script:
    - chant run app-apply --gated-exit 0
  artifacts:
    when: always
    paths: [chant-gate-app-apply.md]
    expire_in: 30 days

No follow-up job, deliberately: posting on the merged merge request would cost a forge token an apply Op with findingMode: "report" should not have to carry. A run that walks through its gate writes no block, and GitLab reports the empty artifact upload as a warning rather than a failure.

Setup steps: script:, not before_script:

The issue asked for before_script lines. Setup entries are emitted at the head of script: instead, which is where lexicons/gitlab/src/components/generate-pipeline.ts puts the same beforeScript option's lines in this same lexicon, and the two keys concatenate identically at run time. Splitting only the Op generator would make the lexicon's two generators disagree for no behavioural gain. Say the word and I will move both.

One test of #2257's that I moved

generateGitlabOpPipeline: a deployment environment (#2257), which arrived in main with #2264, pins the whole emitted document for a cron Op with no environment, to prove its option is additive. Two lines inside that pin moved: the header's opening paragraph, because the Pipeline Schedule instructions are now printed only for the Ops that need one (a merge-request or push job needs none), and resource_group, which every job gains. The fixture is rewritten to the new bytes rather than loosened into a containment check, so it still proves what it was written to prove. The cron job's rule, script and stage are byte-for-byte unchanged.

choudoufu's hand-written .gitlab-ci.yml (INTENTIUS/choudoufu#807 item (e))

Yes, all five Ops generate after this, with two changes on the choudoufu side and one caveat. I read examples/ci-pipelines/generate.ts and gitlab/.gitlab-ci.yml and changed nothing there.

  • live-check (pull_request/report), live-plan (pull_request), live-adopt (push to staging), live-apply (push to main) and live-discover (its own opSchedule cron) all emit — into one document with five jobs, since a GitLab trigger is job-scoped. The header's "four of them are refused by name" section retires, as does the "not emitted by generate.ts" claim.
  • Change one: assumeRole() returns a uses: step, still refused. generate.ts needs a gitlab branch returning a { run } line, which lexicons/terraform/examples/plan-on-pr now demonstrates end to end — id_tokens: puts the JWT in $CHANT_ID_TOKEN, the line writes it to a file and exports AWS_ROLE_ARN/AWS_WEB_IDENTITY_TOKEN_FILE, and the AWS SDK inside the provider does the exchange. No AWS CLI needed. That also answers open question Q2 of fly: move Sprites out of temporal into the fly lexicon #807 with a shape rather than a sketch, though nobody has run it against a real GitLab yet.
  • Change two: WORKFLOW_DIR has no gitlab entry, and the generator's suggested file name is scheduled-ops.gitlab-ci.yml, not .gitlab-ci.yml. generate.ts already writes result.files by name and prunes what it did not write, so a rename there is a one-line map.
  • Caveat: live-plan can be findingMode: "comment" on gitlab now, but live-discover must stay "report" as it is on forgejo. Its GitHub value is "issue", and reconcilePr's issue mode shells to gh issue create — only comment grew a GitLab path. CHANT_FORGE can therefore become a real third value in src/forge.ts for the comment half while live-discover stays report-only.

Two follow-ups worth their own issues, not done here: scheduled-ops is now a misnomer for both the emitted file name and the stage every job sits in, and reconcilePr's issue/merge-request modes have no GitLab implementation.

Every new assertion, proven red then green

Core (16 red). npx vitest run packages/core/src/op/activities/reconcile.test.ts packages/core/src/op/gate-summary.test.ts before the implementation:

 Test Files  2 failed (2)
      Tests  16 failed | 22 passed (38)

listing every mergeRequestContextFrom, gitlabNoteTokenFrom, note POST/PUT/pagination/403/no-token case and writeGatedRunSummary's CHANT_GATE_SUMMARY surface. After:

 Test Files  2 passed (2)
      Tests  38 passed (38)

The pagination test found a real bug in its own first draft: url.includes("page=1") also matches per_page=100, so every page looked like page one. It looped to the generator's 50-page bound and stopped there rather than forever, which is the bound doing its job; the test was fixed to endsWith.

Generator (18 red). npx vitest run lexicons/gitlab/src/components/generate-op-pipeline.test.ts before:

 Test Files  1 failed (1)
      Tests  18 failed | 10 passed (28)

After (with #2257's five environment tests, now in main, alongside): 33 passed (33).

Example (7 new, proven red in two rounds). Round one broke MERGE_REQUEST_SOURCE, resource_group, the id_tokens audience, the gate-summary path, --gated-exit and the environment key:

 × plans on a merge request and applies on a push, both in one document
 × mints the OIDC token through id_tokens, and stores no static key
 × keeps a gated apply green, with the pending gate in the log and in an artifact
 × puts the apply behind a GitLab environment too, and the plan behind none (#2257)
      Tests  4 failed | 37 passed (41)

Round two neutered the three refusals and the header's token note:

 × posts the plan as a merge-request note, and refuses the mode where there is no merge request
 × has no permissions: block at all, and says where the note's write access comes from
 × refuses the github marketplace action rather than dropping it
      Tests  3 failed | 38 passed (41)

Restored: 41 passed (41).

Gates

$ npx tsc --noEmit -p packages/core/tsconfig.json
(exit 0)

$ npm run build -w @intentius/chant-lexicon-gitlab      (exit 0)
$ npm run build -w @intentius/chant-lexicon-github      (exit 0)
$ npm run build -w @intentius/chant-lexicon-terraform   (exit 0)

$ npx tsx scripts/typecheck.ts
Repo-wide typecheck: 32 known failure(s), no regressions. (32 baselined)

$ just lint
✖ 2 problems (0 errors, 2 warnings)
   (both pre-existing, in packages/core/src/meta/publish-metadata.test.ts, untouched here)

$ node scripts/lint-docs-sentences.mjs
Docs prose lint: 4084 gated finding(s), no regressions. (4084 baselined)

$ just docs-check
docs: 20 tutorial, 52 how-to, 58 reference, 34 explanation

The prose baseline is ratcheted to 4084. Six findings sat below its recorded value after the rebase onto the squashed main, across four pages this branch does not touch: contributing/examples.mdx, tutorials/sprites-build-sandbox.mdx, tutorials/sprites-managed-agent-worker.mdx, tutorials/terraform-carve-out.mdx. The per-file counts confirm this branch's own doc edits added none — my two attempts that did add findings, an em dash and then a comma series in guide/ops.mdx, were rewritten rather than baselined.

$ npx vitest run lexicons/terraform/examples/ lexicons/gitlab/src/components/ \
    lexicons/github/src/components/ lexicons/forgejo/src/components/ \
    packages/core/src/op/activities/reconcile.test.ts packages/core/src/op/gate-summary.test.ts \
    packages/core/src/op/composites/reconcile-op.test.ts packages/core/src/op/generate-pipeline.test.ts \
    packages/core/src/op/local-output.test.ts scripts/build-docs.test.ts lexicons/terraform/src/codegen/
 Test Files  14 passed (14)
      Tests  248 passed (248)

Not run, and what someone has to run to verify it

Per the maintainer's instruction, nothing needing a container or a network service ran here.

  • No live GitLab, and no emulator. Every assertion about the API is against a stubbed fetch, so the shapes are pinned but never exercised. What needs a real instance: that POST/PUT /projects/:id/merge_requests/:iid/notes behaves as assumed, that the x-next-page header is what paginates it, that a project access token in PRIVATE-TOKEN posts the note, and — the one I most expect to be wrong — whether any current GitLab lets CI_JOB_TOKEN reach the notes API at all.
  • No pipeline was ever run. The emitted rules: expressions, the id_tokens: audience, the artifacts: upload of a file a green run does not write, and the export-persists-across-script-lines assumption behind the AWS setup line are all reasoned from GitLab's documented behaviour, not observed. A single merge request and a single push on a scratch project would settle all of them.
  • No full test suite, only the targeted set above.

All gates above were re-run after the rebase onto 8244ba0. Head: a4731f35.

@lex00
lex00 force-pushed the feat/2256-gitlab-op-triggers-mr-note branch 2 times, most recently from a4731f3 to 2d8a6a1 Compare September 8, 2026 04:57
…ks on GitLab (#2256)

`reconcilePr`'s `comment` mode posted onto a GitHub pull request and nothing
else: it shelled to `gh`, read the pull request out of the Actions event
payload, and the gitlab and forgejo generators refused the mode by name for
want of anywhere to put the finding.

The mode now also writes a GitLab merge-request note, by the same recipe and
inside the same activity rather than a second one: the hidden marker is the
body's first line, the next run finds the note by that prefix and PUTs it, and
a merge request pushed to five times carries one note holding the current
finding rather than five stale ones.

Which forge a run is on is read off the run's own variables, not configured.
Only a `merge_request_event` pipeline sets `CI_MERGE_REQUEST_IID`, so a run
that has it is unambiguously the GitLab case and a GitHub run never reaches
that branch. A merge request opened from a fork runs its pipeline in the fork,
so the note goes on `CI_MERGE_REQUEST_PROJECT_ID` in preference to
`CI_PROJECT_ID`.

Two token headers, because GitLab reads two credentials from two of them: an
access token in `PRIVATE-TOKEN`, the pipeline's own `CI_JOB_TOKEN` in
`JOB-TOKEN`. The access token is preferred and the job token accepted last —
GitLab's job-token allowlist does not reach the notes API on current
versions, so a project that has not widened it needs a token with `api` scope,
and one that has needs no long-lived credential at all. A run with a merge
request and no token says which variable to set.

Over `fetch` rather than a CLI: `gh` ships on GitHub's hosted runners and is
already this activity's dependency, `glab` ships on no GitLab runner, and a
finding step that needed it would fail on the `node:22-slim` image the
generator emits.

Also: `writeGatedRunSummary` gains a second surface. GitLab has no step
summary at all — a job's surfaces are its log and its artifacts — so
`CHANT_GATE_SUMMARY` names a path the generated job declares under
`artifacts:`. The forge's own variable still wins where both are set.

Refs #2231, #2243, #2084.
…generator (#2256)

The generator was cron-only and refused four things by name. Two of those
refusals were wrong about GitLab rather than about chant.

`GitLab has no pull_request/push event model` was the claim; `$CI_PIPELINE_SOURCE`
distinguishes `merge_request_event` from `push` on every pipeline and `rules:`
selects a job on either. So a `pull_request` trigger becomes a
`merge_request_event` rule with the branch filter mapped to
`$CI_MERGE_REQUEST_TARGET_BRANCH_NAME` — the branch the merge request would
merge into, which is what github's `on.pull_request.branches` filters on too —
and a `push` trigger becomes `$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH
== "<branch>"`, defaulting to the same `main` github's generator assumes. Two
branches are two rule entries, because `rules:` is an OR over its list. A branch
name carrying a quote, a `$` or a backslash is refused rather than interpolated,
since either character silently changes which pipelines match.

`findingMode "comment"` is no longer refused outright: there is a merge-request
note activity to spend it now. What survives is the constraint github already
has — the mode posts onto the merge request that triggered the run, so a cron or
push job carrying it is refused by name at build time rather than emitted to
fail at its Report step.

What remains genuinely absent is in-file cron, so the cron path is unchanged and
the header still says which Pipeline Schedules to create — only for the Ops that
need one, rather than as a blanket instruction on a file that may carry none.

Every job now carries a `resource_group`, GitLab's stand-in for github's per-Op
concurrency group: one run at a time, queued rather than cancelled, which on an
apply job is also what stops two runs racing for the same state lock. All jobs
stay in one file: a GitHub trigger is workflow-scoped, a GitLab one is
job-scoped.

becomes the `id_tokens:` declaration the old refusal already named as the shape
to reach for, audience `$CI_SERVER_URL`. `id-token: read` and every other scope
are still refused, because GitLab has no per-job token-scope mapping and a
dropped scope emits a job that reads as granted and runs with nothing. A `uses`
setup step is still refused for want of any shape to translate it into.

`--gated-exit 0`, so a pending approval is a green run; the human render is
already in the job log, and `CHANT_GATE_SUMMARY` points core at a path the job
also declares under `artifacts:`. No follow-up notice job: that would need a
forge API call and a token a report-mode Op should not have to carry.

Refs #2084, #2231, #2242, #2243.
#2257 pinned the whole emitted document for a cron Op with no `environment`,
to prove its own option is additive. #2256 moves two things inside that pin:
the header's opening paragraph, since the cron setup instructions are now
printed only for the Ops that need a Pipeline Schedule, and `resource_group`,
which every job gains. The pin is rewritten to the new bytes rather than
loosened into a containment check, so it still proves what it was written to
prove. The cron job's rule, script and stage are byte-for-byte unchanged.
…ub one (#2256)

The example shipped one CI shape and a paragraph saying the other forges
refuse it. Both halves now generate for gitlab, and the suite asserts the
emitted document field by field the way it already asserts the two workflows.

Two things about the specs differ, and both are properties of the forge rather
than of the example, which is why the example carries a second setup list
instead of sharing one. The marketplace action becomes a shell line, because a
GitLab job runs `script` and nothing else — and one that needs no AWS CLI:
`id_tokens:` puts the OIDC JWT in an environment variable, and the AWS SDK
inside the terraform provider does the AssumeRoleWithWebIdentity exchange
itself once it has AWS_ROLE_ARN and a file to read the token from. Every
`script` line runs in one shell, so an `export` on one line is still set on the
next, which is exactly what a GitHub Actions `run:` step cannot do.

Asserted: the two rules, one document rather than two, the per-Op
resource_group, the id_tokens declaration and the absence of any
`permissions:` block, the merge-request note mode and its refusal on the push
half, the green gated apply with its log and artifact surfaces, the
environment on the apply and not on the plan, and the refusal of the github
`uses:` step rather than a silent drop.

Also ratchets the docs prose baseline to the value #2257 left it below.

Refs #2084, #2231, #2242, #2243, #2257.
…he comment mode (#2256)

`guide/ops.mdx` said the generators synthesize one cron-triggered CI file per
Op and that gitlab refuses `comment` outright; `lexicon-authoring/ci-integration.mdx`
said gitlab refuses an additive `permissions` map; the terraform lexicon's ops
page said the mode is refused off GitHub. Each now says what the generator
does, including where the note's write access comes from and why the
permission table is a GitHub column.

The lexicon page is authored in `docs/pages/` and regenerated into
`docs/src/content/docs/`; both are committed.

Also ratchets the docs prose baseline to 4084. Six findings left it below its
recorded value across four pages none of this branch touches
(contributing/examples, tutorials/sprites-build-sandbox,
tutorials/sprites-managed-agent-worker, tutorials/terraform-carve-out); the
per-file counts confirm this branch's own doc edits added none.
@lex00
lex00 force-pushed the feat/2256-gitlab-op-triggers-mr-note branch from 2d8a6a1 to f5982d2 Compare September 8, 2026 05:17
@lex00
lex00 merged commit b950b54 into main Sep 8, 2026
6 checks passed
@lex00
lex00 deleted the feat/2256-gitlab-op-triggers-mr-note branch September 8, 2026 05:28
lex00 added a commit that referenced this pull request Sep 9, 2026
…not "scheduled-ops" (#2293) (#2295)

`STAGE = "scheduled-ops"` in the gitlab Op generator dates from when it was
cron-only. Since #2268 the same file also carries merge-request and push
jobs (live-check/live-plan/live-apply/live-adopt on this project), so a
GitLab UI grouped all of them under a stage called "scheduled-ops" and a
consuming project's `include:` named a file (`scheduled-ops.gitlab-ci.yml`)
whose name said the opposite of what it held.

The default is now `"ops"`: the stage every generated job runs in (`stages:`
and each job's `stage:`), and the base of the generated file's name
(`ops.gitlab-ci.yml`). Both are overridable through the same
`ComponentPipelineOptions` every other generator knob (`image`, `variables`,
`beforeScript`, ...) already goes through — `opsStage` renames both by
default, `opsFileName` renames the file independently when a caller wants
the two to differ. GitHub- and Forgejo-only: those generators emit one
workflow file per Op with no shared stage, so the two options do nothing
there. The generated file's own header now names the stage
(`one job per Op under stage "ops"`), so a reader of the YAML alone can see
where "ops" comes from.

BREAKING: this renames every consuming project's generated GitLab file and
`include:` line. `INTENTIUS/choudoufu`'s `examples/ci-pipelines` regenerates
gitlab/ops.gitlab-ci.yml in place of gitlab/scheduled-ops.gitlab-ci.yml;
its README's `include: - local: 'scheduled-ops.gitlab-ci.yml'` and
tests/pipelines.test.ts's GITLAB_FILE constant need the same rename, tracked
at INTENTIUS/choudoufu#1018. `generate.ts` itself needs no change: it writes
whatever `result.files` names.

Part of #2289. Refs #2268, #2256, #2257, #2243, #2242, #2231.


Claude-Session: https://claude.ai/code/session_01KCvXZWJq4nrMCBRe98TX1v

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
lex00 added a commit that referenced this pull request Sep 9, 2026
…onUpgrade (#2297) (#2311)

Found while landing #2292: `reconcilePr`'s `issue` mode shelled to `gh issue
create` unconditionally on GitHub, with no marker and no search, so every run
opened another issue. `lexicon-upgrade.ts`'s `issue` path had the same bug at
both of its call sites. Since #2268 gave `comment` mode a sticky GitLab note
and #2292 gave `issue` mode a sticky GitLab issue, GitHub was the only path
left that did not edit in place — live today on INTENTIUS/choudoufu's
examples/ci-pipelines, whose nightly account sweep reports findingMode
"issue" on GitHub, opening one more issue every night it finds drift.

Both files now share one recipe through a new `postOrUpdateGithubIssue`
(reconcile.ts): a hidden marker as the issue body's first line, a search
among the repo's OPEN issues for one already carrying it, PATCH when found
and POST when not — `postOrUpdateComment`'s issue counterpart, and the
GitHub/GHES/Forgejo sibling of GitLab's own `postOrUpdateIssue` (#2292).
`reconcilePr`'s `issue` mode calls it directly; `lexiconUpgrade` calls it
through a small `postLexiconIssue` wrapper (a per-lexicon marker, since that
activity has one upgrade-status issue per lexicon rather than per env) so the
two activities' injectable `gh` runners — `execAsync`+`signal` on one side,
a plain `GhRunner` on the other — both satisfy the same minimal `GhExec`
shape without duplicating the search/PATCH/POST logic. Every call is built
from `githubApiBaseFrom` the way #2291 did it, so this reaches GitHub
Enterprise Server the same way it reaches github.com. Outside any known CI
job (no GITHUB_REPOSITORY, no CI_PROJECT_ID) both fall back to `gh issue
create`'s own ambient repo detection, unchanged except that the marker is
now written there too, so a later CI run of the same Op finds and edits it.

The search deliberately does not use GitHub's Search API, which the issue
named as a candidate (`gh issue list --search`, or `GET /search/issues`).
Three reasons, in `postOrUpdateGithubIssue`'s own doc comment: GitHub's
search index is documented as eventually consistent, which is exactly the
read-after-write this sticky recipe depends on — a false "not found" right
after this activity's own write is a duplicate, the bug being fixed here.
The hidden marker is deliberately punctuation-heavy so it renders invisibly,
and GitHub's search tokenizer is not documented to preserve that shape
through `in:body` matching. And neither `gh issue list --search` nor
`/search/issues` exists on Forgejo — checked against a live Forgejo
instance's own OpenAPI spec while building this — which would mean forking
this function by forge, exactly what the `comment` path (#2291) deliberately
does not do. So it reuses the recipe `postOrUpdateComment` already proved for
PR comments: list, `--paginate`, filter with `--jq` by an exact `startswith`
prefix match. Correct at any page count; the accepted cost is that a
repository with many thousands of issues pays for every page on every run.

The close-or-not decision the issue asked to be made explicitly: this mode
never closes the issue, on either forge, matching both GitLab paths (which
don't either). The search is scoped to `state=open` rather than `state=all`,
which makes that a concrete decision instead of an implicit one — a human
closing the issue by hand, once whatever it named is actually fixed, is what
tells the *next* run to open a fresh issue for a fresh finding rather than
silently rewrite the closed one back into relevance nobody is watching for.
Reopening on write was considered and rejected: this activity has no
reliable signal for "the last finding got fixed" versus "this run happened
not to check." Documented in both `reconcile.ts`'s doc comments and
docs/src/content/docs/guide/ops.mdx, per the issue's own instruction not to
leave it implied.

Proof: every new assertion shown red by reverting reconcile.ts and
lexicon-upgrade.ts to their pre-fix content with the new tests left in
place, then green after restoring the fix. Red:

  lexicon-upgrade.test.ts (33 tests | 4 failed)
    × deterministic per lexicon, and distinct across lexicons
      TypeError: lexiconUpgradeIssueMarker is not a function
    × on a GitHub Actions job (GITHUB_REPOSITORY set), opens the sticky issue via gh api (#2297)
      AssertionError: expected '' to be 'https://github.com/acme/infra/issues/11'
    × a re-run on a GitHub Actions job PATCHes the issue it already owns (#2297)
      AssertionError: expected '' to be 'https://github.com/acme/infra/issues/11'
  reconcile.test.ts (62 tests | 6 failed)
    × a re-run PATCHes the issue it already owns instead of opening a second one
      AssertionError: expected '' to be 'http://forgejo.example/acme/infra/issues/57'
    × searches only OPEN issues, and never mistakes a pull request for one it owns
      AssertionError: expected 'gh issue create --title ...' to contain 'state=open'
    × postOrUpdateGithubIssue directly
      TypeError: postOrUpdateGithubIssue is not a function
  (10 failed total, 85 passed)

Green after restoring the fix: Test Files 2 passed (2), Tests 95 passed (95).

Gates: `tsc --noEmit -p packages/core/tsconfig.json` exit 0. `npx tsx
scripts/typecheck.ts`: 31 known failures, no regressions (unchanged
baseline). `just lint`: 2 pre-existing warnings in an unrelated file
(packages/core/src/meta/publish-metadata.test.ts), none here. `just
docs-check`: 20 tutorial, 52 how-to, 58 reference, 34 explanation, no
violations. `node scripts/lint-docs-sentences.mjs`: 4084 baselined, no
regressions (an em-dash-heavy first draft of the ops.mdx paragraph did
regress the baseline and was rewritten rather than baselined).
packages/core/src/op/activities/ (10 files): 209 passed. packages/core/src/
op/composites/ (6 files, including reconcile-op.test.ts which builds on
`reconcilePr`): 70 passed.

Not run: one real create-then-re-run against a live repository, which the
issue also asked for since the search shape is the part a mock cannot vouch
for. A throwaway scratch repo under my own account would have made this
safe, but `gh repo create` was refused by this environment's own auto-mode
classifier as a side-effecting action, and working around that was out of
bounds. So the GitHub/GHES REST shapes here (the issues-list filter, the
create/edit fields, `.html_url`) are reasoned from GitHub's documented API
and mirror `postOrUpdateComment`'s already-live-verified shape as closely as
the issue/comment endpoints allow, but are not independently exercised
against a real GitHub instance the way #2291's comment path was. Marking
this the unverified part rather than claiming it, per the issue's own
instruction.

Part of #2289. Refs #2292, #2291, #2268.

Claude-Session: https://claude.ai/code/session_01Ba8bBNoVmfrpiVKnwYLBzM

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

gitlab: pull_request and push triggers on the op-pipeline generator, and a merge-request note activity, so a choudoufu pipeline can plan on an MR

1 participant