ci: the sync runs on the forge, upstream's CI with it (#13) #14

Manually merged
terra merged 4 commits from pluto/13-sync-on-the-forge into main 2026-11-26 05:00:17 +00:00
Member

Purpose (platform): the engine sync's gate is defined without upstream's GitHub CI run, so the sync runs on the forge, once a day, and upstream syncs resume (martha-ai/martha-engine#13, RULED option (c)).

What this does

The forge reads only .forgejo/workflows once it exists (#11), so .github/workflows/martha-engine-sync.yml never runs here and its second gate, upstream's ci.yml dispatched on github.com, cannot run at all. This is the forge's form of the sync.

  • .forgejo/workflows/martha-engine-sync.yml: the sync job. Daily at 04:00 UTC (schedule:) plus workflow_dispatch with resume; the five github.server_url == 'https://github.com' guards are gone. When upstream has not moved, pick_the_upstream_change.sh prints sync= and merge, upstream-ci and pull-request all skip: no dispatch, no pull request.
  • .forgejo/workflows/upstream-ci.yml: upstream's ci.yml job for job, fifteen of them, on workflow_dispatch ONLY, so it runs on the sync branch and nowhere else and cannot undo #11. Forge adaptations carried from the four jobs .forgejo/workflows/ci.yml already runs: the pinned toolchain copy in this tree instead of the marketplace action, no rust-cache, an apt-get step for what a github.com runner image ships (sudo, pkg-config, libclang, cmake, jq, tini). changes answers code=true because a dispatched run exists only to be the gate.
  • upstream-ci dispatches that copy through the forge's API (POST /actions/workflows/upstream-ci.yml/dispatches with return_run_info), so the forge names the run and the job waits on it by id. martha/sync/dispatch_and_watch_the_run.sh; exit 0 green, 1 red or refused, 2 out of time.
  • pull-request reads the branch's tip through the forge's API and prints the forge's own command, in place of gh api and gh pr create. martha/sync/report_the_sync_for_a_pull_request.sh.
  • checks calls ./.forgejo/workflows/martha-engine-checks.yml with the branch as ref; that file gains workflow_call with the ref input its jobs already read.
  • push_the_sync_branch.sh keeps the GitHub fallback text byte for byte and adds the forge's: the forge has no rule that a token push may not touch .github/workflows, so a refused push there is a refused push, and the path it prints is the forge's.

.github is untouched, byte for byte.

Proof

  • martha/sync/dispatch_and_watch_the_run_test.sh against a stub forge: the request (workflow file, ref, return_run_info), every request carrying the token as a header rather than on a command line, a green run, a red run, a refused dispatch (no poll), and a run that outlasts the wait. All pass.
  • The dispatch endpoint on this forge, called with a ref that does not exist: 400 {"message":"reference 'refs/heads/no-such-branch-pluto-probe' does not exist"}. Route and token good; the 201 path is what Done-when 1's run proves.
  • Both .forgejo YAML files parse; upstream-ci.yml has 15 jobs and workflow_dispatch as its only trigger; martha-engine-sync.yml has 5 jobs on schedule and workflow_dispatch.

Not proven yet, and on the issue

Done-when 1 (a real sync end to end, gate green, merged, run ids) and Done-when 2 (the first scheduled run seen firing) are after this lands: both need the files on main.

Refs martha-ai/martha-engine#13

Purpose (platform): the engine sync's gate is defined without upstream's GitHub CI run, so the sync runs on the forge, once a day, and upstream syncs resume (martha-ai/martha-engine#13, RULED option (c)). ## What this does The forge reads only `.forgejo/workflows` once it exists (#11), so `.github/workflows/martha-engine-sync.yml` never runs here and its second gate, upstream's `ci.yml` dispatched on github.com, cannot run at all. This is the forge's form of the sync. - `.forgejo/workflows/martha-engine-sync.yml`: the sync job. Daily at 04:00 UTC (`schedule:`) plus `workflow_dispatch` with `resume`; the five `github.server_url == 'https://github.com'` guards are gone. When upstream has not moved, `pick_the_upstream_change.sh` prints `sync=` and merge, upstream-ci and pull-request all skip: no dispatch, no pull request. - `.forgejo/workflows/upstream-ci.yml`: upstream's `ci.yml` job for job, fifteen of them, on `workflow_dispatch` ONLY, so it runs on the sync branch and nowhere else and cannot undo #11. Forge adaptations carried from the four jobs `.forgejo/workflows/ci.yml` already runs: the pinned toolchain copy in this tree instead of the marketplace action, no `rust-cache`, an `apt-get` step for what a github.com runner image ships (sudo, pkg-config, libclang, cmake, jq, tini). `changes` answers `code=true` because a dispatched run exists only to be the gate. - `upstream-ci` dispatches that copy through the forge's API (`POST /actions/workflows/upstream-ci.yml/dispatches` with `return_run_info`), so the forge names the run and the job waits on it by id. `martha/sync/dispatch_and_watch_the_run.sh`; exit 0 green, 1 red or refused, 2 out of time. - `pull-request` reads the branch's tip through the forge's API and prints the forge's own command, in place of `gh api` and `gh pr create`. `martha/sync/report_the_sync_for_a_pull_request.sh`. - `checks` calls `./.forgejo/workflows/martha-engine-checks.yml` with the branch as `ref`; that file gains `workflow_call` with the `ref` input its jobs already read. - `push_the_sync_branch.sh` keeps the GitHub fallback text byte for byte and adds the forge's: the forge has no rule that a token push may not touch `.github/workflows`, so a refused push there is a refused push, and the path it prints is the forge's. `.github` is untouched, byte for byte. ## Proof - `martha/sync/dispatch_and_watch_the_run_test.sh` against a stub forge: the request (workflow file, ref, `return_run_info`), every request carrying the token as a header rather than on a command line, a green run, a red run, a refused dispatch (no poll), and a run that outlasts the wait. All pass. - The dispatch endpoint on this forge, called with a ref that does not exist: `400 {"message":"reference 'refs/heads/no-such-branch-pluto-probe' does not exist"}`. Route and token good; the 201 path is what Done-when 1's run proves. - Both `.forgejo` YAML files parse; `upstream-ci.yml` has 15 jobs and `workflow_dispatch` as its only trigger; `martha-engine-sync.yml` has 5 jobs on `schedule` and `workflow_dispatch`. ## Not proven yet, and on the issue Done-when 1 (a real sync end to end, gate green, merged, run ids) and Done-when 2 (the first scheduled run seen firing) are after this lands: both need the files on `main`. Refs martha-ai/martha-engine#13
ci: the sync runs on the forge, upstream's CI with it (martha-engine#13)
Some checks failed
CI / Check Rust Code Format (pull_request) Has been cancelled
CI / Build and Test Rust Project (pull_request) Has been cancelled
CI / Lint Rust Code (pull_request) Has been cancelled
martha-engine checks / Build the engine and run the fork's checks (pull_request) Has been cancelled
martha-engine checks / The evidence keeps the model server's log (pull_request) Successful in 3s
CI / changes (pull_request) Successful in 10s
49b1e41f21
The forge reads only .forgejo/workflows once it exists (#11), so the sync's
copy in .github is inert there and its second gate, upstream's ci.yml
dispatched on github.com, cannot run at all. This adds the forge's form:

- .forgejo/workflows/martha-engine-sync.yml: the sync job, daily at 04:00 UTC
  plus workflow_dispatch, with no github.server_url guard. upstream-ci
  dispatches the copy below through the forge's API and waits for its run;
  pull-request reads the tip through the forge's API and prints the forge's
  command; checks calls the fork's checks as a reusable with the branch as ref.
- .forgejo/workflows/upstream-ci.yml: upstream's ci.yml job for job, fifteen
  of them, on workflow_dispatch only, so it cannot run on a pull request or a
  main push and undo #11.
- martha/sync/dispatch_and_watch_the_run.sh: dispatch, then wait, through the
  forge's API (return_run_info names the run). Tested against a stub forge.
- martha/sync/report_the_sync_for_a_pull_request.sh: the tip and the command
  that opens the pull request, on the forge.
- push_the_sync_branch.sh: the forge has no GitHub rule about a token push
  touching .github/workflows, so a refused push there prints the forge's own
  path. The GitHub text is unchanged.
ci: the gate's wait fits fifteen uncached jobs, and no narrowed token (martha-engine#13)
Some checks failed
CI / changes (pull_request) Has been cancelled
CI / Check Rust Code Format (pull_request) Has been cancelled
CI / Build and Test Rust Project (pull_request) Has been cancelled
CI / Lint Rust Code (pull_request) Has been cancelled
martha-engine checks / The evidence keeps the model server's log (pull_request) Has been cancelled
martha-engine checks / Build the engine and run the fork's checks (pull_request) Has been cancelled
4d9218f4c3
Three things my own read of the diff found before review:

- upstream-ci.yml carried `permissions: {}`, which upstream's ci.yml does not.
  A block there can only narrow what the forge hands a job, and these jobs
  need to read the repository: drop it.
- The gate dispatches fifteen upstream jobs with no cargo cache on a runner
  that carries three at a time, so it is hours rather than minutes: the
  upstream-ci job times out at 300 minutes and the wait gives up at 285,
  a quarter of an hour earlier, so a stuck gate says so itself.
- report_the_sync_for_a_pull_request.sh no longer insists on a run id: a
  provider that sets no GITHUB_RUN_ID would otherwise fail the report rather
  than print the branch.
ci: the report reads the sync branch's tip from the branches route (martha-engine#13 review r1)
Some checks failed
CI / changes (pull_request) Has been cancelled
CI / Check Rust Code Format (pull_request) Has been cancelled
CI / Build and Test Rust Project (pull_request) Has been cancelled
CI / Lint Rust Code (pull_request) Has been cancelled
martha-engine checks / The evidence keeps the model server's log (pull_request) Has been cancelled
martha-engine checks / Build the engine and run the fork's checks (pull_request) Has been cancelled
e13d3de05b
GET /git/commits/sync/<sha> answers 404 on the forge (a branch name with a slash is not a commit ref there), so a
green gate's report died under --fail-with-body and the run ended red. /branches/sync/<sha> answers 200 with
.commit.id, measured on sync/927005e14358.
ci: a cancelled gate is red, and a lost poll is asked again (martha-engine#13 review r1 notes)
Some checks were skipped
CI / changes (pull_request) Has been skipped
CI / Check Rust Code Format (pull_request) Has been skipped
CI / Build and Test Rust Project (pull_request) Has been skipped
CI / Lint Rust Code (pull_request) Has been skipped
martha-engine checks / The evidence keeps the model server's log (pull_request) Has been skipped
martha-engine checks / Build the engine and run the fork's checks (pull_request) Has been skipped
0d55f316e6
Both are the reviewer's non-blocking notes on r1, folded in behind his own fix:

- The test pins a cancelled run as red. Only `failure` was covered, so a script
  that read `cancelled` as anything but a red gate would have passed the suite.
- A poll the forge does not answer is asked again rather than ending the run:
  one transient 500 should not decide a merge, and the deadline already bounds
  the wait. Every curl now carries --max-time 60, so a hung connection cannot
  eat the job's timeout either.

The test's stub grows a GET_FAILS knob for the lost-poll case, and the suite is
19 cases green.
terra manually merged commit 27d48e8db5 into main 2026-11-26 05:00:17 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha-engine!14
No description provided.