Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v0.3.1 · 2026-11-25

- `plan` writes no plan when its branch is already the head of an open pull request in the target, so formcompiler's `adaptor.yml` starts no `propose` job, and asks for no approval, while a proposal waits for a merge.
- `apply` does not push a branch the target already has, and goes straight to opening the pull request. A run that was refused the pull request no longer blocks the next one.
- The token reaches git through its environment and is in no argument list.
- docs/OWNER_SETUP.md step 4 says what the fine-grained token needs when formcompiler's `release` environment holds it instead of the App.
- 82 tests in 5 files.

## v0.3.0 · 2026-11-26

- formadaptor holds no secret. Proposing moves to formcompiler's `adaptor.yml`, with formcompiler's release App from its `release` environment; hourly.yml now builds and publishes the spec only, and propose.yml is gone.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ python3 -I scripts/propose.py changed --plans plans
python3 -I scripts/advisory.py --family family.json
```

Version 0.3.0. Licence: GPL-3.0-only (see LICENSE and NOTICE).
Version 0.3.1. Licence: GPL-3.0-only (see LICENSE and NOTICE).
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.3.1
2 changes: 1 addition & 1 deletion docs/OWNER_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Nothing here has run on GitHub yet. In order:
1. Create the empty public repository `nodemode-dev/formadaptor`. Push `main` once, then push `feat/first-build-0.1.0` and open its pull request. Merge with a merge commit (no squash) so each commit and its signature stay.
2. Settings, Actions, General: allow GitHub Actions; Workflow permissions "Read repository contents" (the workflows widen it per job). Do not allow Actions to create or approve pull requests here; formadaptor opens none; formcompiler's `adaptor.yml` opens them in the targets.
3. formadaptor holds no secret: add none here, and create no App for it. Proposing is formcompiler's `adaptor.yml`, which signs in with formcompiler's release App from formcompiler's `release` environment. Its plan job runs each target's generator with `scripts/propose.py plan` and holds no secret and no environment; its apply job holds the token, runs no target code, and re-checks every planned file with `scripts/propose.py apply`.
4. On formcompiler's release App: add the Repository permission "Pull requests: read and write" beside Contents, and install it on each target repository in targets.json: formMCP, formskills, form.ext and formai-templates (step 11) now; .github when the profile target is switched on (step 6). Not on formtray: it is not a target (its app list is your dated release schedule, kept by hand). Each run mints a token for one target repository at a time.
4. On formcompiler's release App: add the Repository permission "Pull requests: read and write" beside Contents, and install it on each target repository in targets.json: formMCP, formskills, form.ext and formai-templates (step 11) now; .github when the profile target is switched on (step 6). Not on formtray: it is not a target (its app list is your dated release schedule, kept by hand). Each run mints a token for one target repository at a time. When formcompiler's `release` environment holds the fine-grained token `FORMCOMPILER_WRITE_TOKEN` instead of the App, `adaptor.yml` uses that token: give it "Pull requests: read and write" beside Contents and add the same target repositories to it.
5. In each target: if `main` has a ruleset, make sure it does not stop that App from pushing `bot/*` branches (a branch ruleset that restricts creation must list the App as a bypass actor for `bot/**`). Pull requests opened with the App token start the target's checks, unlike those opened with the built-in token.
6. Merge the target changes (docs/TARGETS.md) in formMCP, formskills and form.ext, each with its generated files regenerated from the current spec and its copy of that spec committed beside them (`setup/family.spec.json` in all three), so the first proposal finds nothing to change. The profile target (.github) is disabled in `targets.json`: it is switched on when the page's listing rule is chosen. The page lists apps whose registry `state` is `live`; six apps formai.studio shows as live are `public` or `prelaunch` in the registry, so decide first which is right (fix the registry's `catalog.state`, or change the page's listing rule in .github), make .github's generator write its copy at `scripts/family.spec.json`, regenerate the page, then set `"enabled": true` for `profile` here and install the App on .github.
7. Run `hourly` by hand once (Actions, hourly, Run workflow). It creates the `spec` branch with `family.json`. Then run formcompiler's `adaptor` by hand to see every enabled target answer "in step".
Expand Down
19 changes: 17 additions & 2 deletions scripts/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

Living log of all comment content, explainers, rationale, TODOs and removed code for the adaptor (the scripts and the workflows). The source files stay comment-free per dev-rules `sub-skills/hashout-log/SUB-SKILL.md`; everything they would have said lives here, indexed. Read this first, then edit code surgically.

Current build version: v0.3.0
Last updated: 2026-11-26 · plan, changed and apply; no secret in this repository (v0.3.0)
Current build version: v0.3.1
Last updated: 2026-11-25 · a proposal that is already open starts nothing, a branch already on the target is not pushed again, the token reaches git through its environment (v0.3.1); 2026-11-26 · plan, changed and apply; no secret in this repository (v0.3.0)

### propose.py · an open proposal starts nothing; a pushed branch is not pushed again; the token goes to git through the environment
- refers-to: scripts/propose.py :: already_open, plan_command, push
- kind: fix
- logged: v0.3.1 · 2026-11-25

The first run of formcompiler's `adaptor.yml` (25 November, evening): three plans were made and the three `propose` jobs waited for the owner's approval, because formcompiler's `release` environment has a required reviewer. Every later hour would have asked again for as long as a proposal stayed unmerged, since only `apply` looked for the open pull request.

`plan` now asks GitHub for the target's open pull requests before it writes a plan (`already_open`, through `open_bot_pulls`; the targets are public, so the run's own read-only `GH_TOKEN` or no token at all is enough). When the proposal's branch is already the head of an open pull request, `plan` writes no plan, says which pull request waits for a merge, and sets `changed=false`, so no `propose` job starts. When GitHub cannot be asked, `plan` goes on as before and `apply` makes the same check with the target's token.

`push` asks the target for the branch first (`git ls-remote --heads`) and does not push when it is there. The branch name carries the first 10 characters of the change hash, so a branch of that name holds the same files. Before, a run that pushed the branch and was then refused the pull request (a credential without Pull requests: read and write) left the branch behind, and the next run's push was rejected as not a fast-forward; now the next run finds the branch and goes straight to opening the pull request.

The token reaches git through its environment (`GIT_CONFIG_COUNT`, `GIT_CONFIG_KEY_0`, `GIT_CONFIG_VALUE_0`) so it is in no argument list. `GIT_TERMINAL_PROMPT=0` keeps git from asking for a name when the token is refused.

Rehearsed against a local repository and a local stand-in for the API: `plan` with the branch open as #7 wrote no plan and `changed=false`; `plan` with the API unreachable planned as before; `apply` with the branch already on the target printed "is already on nodemode-dev/formX, not pushed again" and opened the pull request; `apply` against a repository that does not exist stopped with git's own message.

### propose.py · plan, changed and apply; no secret in this repository
- refers-to: scripts/propose.py :: plan_command, write_plan, changed_plans, checked_plan, apply_plan, apply_command; .github/workflows/hourly.yml; tests/test_workflows.py :: test_no_workflow_holds_a_secret
Expand Down
19 changes: 18 additions & 1 deletion scripts/propose.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ def open_bot_pulls(gh, target):
and ((p.get("head") or {}).get("repo") or {}).get("full_name", "").lower() == target["repository"].lower()]


def already_open(target, branch):
try:
pulls = open_bot_pulls(GitHub(), target)
except (ApiError, ValueError, KeyError, TypeError):
return None
return next((p.get("number") for p in pulls if (p.get("head") or {}).get("ref") == branch), None)


def push(checkout, target, proposal, token):
env = dict(os.environ, GIT_AUTHOR_NAME=IDENTITY[0], GIT_AUTHOR_EMAIL=IDENTITY[1], GIT_COMMITTER_NAME=IDENTITY[0], GIT_COMMITTER_EMAIL=IDENTITY[1])
git(checkout, "checkout", "-q", "-b", proposal["branch"])
Expand All @@ -263,7 +271,11 @@ def push(checkout, target, proposal, token):
basic = base64.b64encode(f"x-access-token:{token}".encode("utf-8")).decode("ascii")
base = os.environ.get("FORMADAPTOR_GIT_BASE", "https://github.com").rstrip("/")
url = f"{base}/{target['repository']}.git"
git(checkout, "-c", f"http.{base}/.extraheader=AUTHORIZATION: basic {basic}", "push", "-q", url, f"HEAD:refs/heads/{proposal['branch']}")
signed = dict(os.environ, GIT_TERMINAL_PROMPT="0", GIT_CONFIG_COUNT="1", GIT_CONFIG_KEY_0=f"http.{base}/.extraheader", GIT_CONFIG_VALUE_0=f"AUTHORIZATION: basic {basic}")
if git(checkout, "ls-remote", "--heads", url, proposal["branch"], env=signed).strip():
print(f"{target['name']}: {proposal['branch']} is already on {target['repository']}, not pushed again")
return
git(checkout, "push", "-q", url, f"HEAD:refs/heads/{proposal['branch']}", env=signed)


def propose(gh, checkout, target, proposal, token):
Expand Down Expand Up @@ -482,6 +494,11 @@ def plan_command(target, args):
if proposal["warning"]:
print(f"::warning::{proposal['warning']}")
summary(f"Warning: {proposal['warning']}. The proposal is not held back.\n")
waiting = already_open(target, proposal["branch"])
if waiting is not None:
summary(f"{target['name']}: {proposal['branch']} is already proposed in #{waiting} and waits for a merge; nothing new to propose\n")
output("changed", "false")
return 0
doc = write_plan(target, checkout, proposal, base, args.out)
print(f"{target['name']}: planned {proposal['branch']} on {base[:10]}, {len(doc['files'])} files")
output("changed", "true")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def test_every_version_site_agrees():
match = re.search(pattern, (REPO / name).read_text(encoding="utf-8"), re.M)
assert match, name
found[name] = match.group(1)
assert set(found.values()) == {"0.3.0"}, found
assert set(found.values()) == {"0.3.1"}, found