Revision: 1 Last modified: 2026-12-04T17:48:16Z
The risk-free, fast-forward-only update of the constitution submodule inside a consuming project.
Run it when: you want the constitution in a project brought up to date, and you want a guarantee that nothing can be rewritten. It refuses anything that is not a fast-forward. Never force, never reset, never rebase, never push.
Its design promise in one sentence: a gitlink the project records is only ever replaced by a DESCENDANT of it.
How this differs from update.sh — the most common confusion, stated plainly:
update_constitution.sh |
update.sh |
|
|---|---|---|
| Scope | only the constitution submodule | the checkout and every submodule, recursively |
| Integration method | fast-forward only — a diverged HEAD is refused | rebase, with local commits replayed on top |
| Default target | newest remote helixconstitution-v* release tag, else origin/main |
the branch's upstream tip |
| Local commits | must be absent (refused as "unpushed work") | kept, rebased |
| Project effect | stages the new gitlink (commits only with --commit) |
nothing beyond the repos it updates |
| Hook | runs the project's post_update_hook.sh |
runs the constitution checkout's hook when its HEAD moved |
If you have local constitution commits you want to keep, update_constitution.sh will refuse you (exit 3) — that
is by design, and update.sh is the tool for that case.
bash,git.- The script must live inside the constitution submodule it updates.
- The submodule must have no local changes (else exit
3). - Network access to at least one remote for the fetch;
--checkand--dry-runare not offline — they still fetch. sshwithBatchMode=yes -o ConnectTimeout=10always. Put keys/ports in~/.ssh/config, notGIT_SSH_COMMAND: inherited git variables are dropped from the environment, with only the config-file selection, author/committer identity, CA bundle and protocol limits carried through.- Optional: nothing. No env vars are read.
# From a consuming project (standard layout)
bash submodules/constitution/scripts/update_constitution.sh
# Legacy layout works identically
bash constitution/scripts/update_constitution.sh
# Am I behind? Prints UPDATE_AVAILABLE=yes|no; moves nothing
bash submodules/constitution/scripts/update_constitution.sh --check
# Print the plan, change nothing (still fetches)
bash submodules/constitution/scripts/update_constitution.sh --dry-run
# Pin to a specific ref
bash submodules/constitution/scripts/update_constitution.sh --ref helixconstitution-v9.4.0
# Update, skip the post-update hook, and commit the gitlink bump
bash submodules/constitution/scripts/update_constitution.sh --no-hook --commit
# Update and let the Jev decision-layer hook run (it is off by default)
bash submodules/constitution/scripts/update_constitution.sh --jev-hook
# A non-standard layout
bash submodules/constitution/scripts/update_constitution.sh --project-root /path/to/projectWhat you should see: the before/after sha, the changelog delta, and — depending on mode — UPDATE_AVAILABLE=yes|no
(--check) or already up to date (exit 0). With --commit it also commits the gitlink; without it the new
gitlink is staged and left for you.
| Code | Meaning |
|---|---|
0 |
Updated, or already up to date (--check: printed UPDATE_AVAILABLE=yes|no) |
1 |
The post-update hook or the checkout failed |
2 |
Usage error |
3 |
Blocked — dirty submodule, unpushed work, diverged history, network failure, not a submodule, or --project-root equal to the submodule itself |
- Dirty submodule → exit
3, before any fetch. - Every fetch fails (offline) → exit
3. There is no offline mode for this script. - Unpushed work. Refused (exit
3) whenHEADis not on any remote branch nor in a tag the REMOTE has. A tag that exists only locally does not count: remote tags are read withgit ls-remote --tags. - Diverged history → refused (exit
3). Onlytarget == HEAD(already up to date) ortargetbehindHEADis accepted; nothing is forced. - Pre-release tags such as
-rc1are never chosen by the defaulthelixconstitution-v*selection. Version ordering is numeric, sov9 < v10 < v100. - A recorded gitlink that is NEWER than the checkout, names a commit not in the checkout, or has diverged
from it → exit
3, nothing staged, on every path including--checkand--dry-run. Rungit submodule update -- <path>first. Only a recorded gitlink that is an ancestor of the checkout counts as an update that was cut off. - A STAGED gitlink differing from both the committed gitlink and the checkout (something somebody staged) is
never overwritten — exit
3on every path, unless the pending marker is honoured: it names the checkout and itsstaged-beforefield equals the gitlink staged now, so a change staged after a cut-off run of this script is never mistaken for it. - An interrupted run (killed, or
git addfailed because the project's.git/index.lockwas held) is finished by the next run, never reported as "already up to date": the run compares the submoduleHEADwith the recorded gitlink, stages it, and re-runs the post-update hook if the marker.git/helix-update-pendingsays the earlier hook never finished.--checkthen printsUPDATE_AVAILABLE=yes.- Limit: the hook is re-run only while that marker exists — not when
--no-hookwas used. - Limit: a submodule
HEADahead of the target with an older recorded gitlink is only reported (NOTE), never staged.
- Limit: the hook is re-run only while that marker exists — not when
--check/--dry-runare not offline. They still rungit fetch --quiet --tagsper remote, updating the submodule's remote-tracking refs and tags. They never moveHEADor a local branch, never touch the working tree, and never change the project.--project-rootequal to the submodule itself → exit3.
- Find the submodule it lives in and the project that records it (both layouts).
- Refuse (exit
3) if the submodule has local changes. - Fetch every remote, tags included. All fetches failing → exit
3.HEADon no remote branch and no remote tag → exit3(unpushed work). - Choose the target:
--ref, else the newest release tag on a remote (helixconstitution-vN(.N)*, numeric order, pre-releases never), elseorigin/main. - Accept only a fast-forward: equal or behind → "already up to date" (exit
0); diverged → refuse (exit3). - Check the target out detached, run
scripts/post_update_hook.shfrom the project root withCONSTITUTION_JEV_HOOK=off(unless--jev-hook; skipped with--no-hook), print the before/after sha and the changelog delta, and stage the new gitlink in the project. It commits only with--commit.
The pending marker (.git/helix-update-pending in the project) is written before the checkout and removed
after the hook, which is what lets the next run tell a finished update from a cut-off one.
scripts/update.sh— the rebase-everything recursive updater (docs/scripts/update.md). Reads local commits instead of refusing them.scripts/install_constitution.sh— install/update with the upstream table, agent wiring and backups.scripts/setup.sh— hook wiring, bootstrap mode.scripts/post_update_hook.sh— the hook this script invokes and whose absence on--no-hookit documents.docs/guides/update_script.md.
2026-12-04 — source read (689 lines), bash -n clean, flags and exit codes read from the script's header contract and
argument handling:
$ bash -n scripts/update_constitution.sh && echo PARSE-OK
PARSE-OKNot executed in this pass: it moves a submodule checkout. To verify safely, run
bash scripts/update_constitution.sh --check inside a throwaway clone — it prints UPDATE_AVAILABLE=yes|no and
moves nothing (but does fetch).