Service cutover runbook
Executed 2026-10-31; kept as the record of the cutover. Do not re-run.
This was the procedure that moved the events-domain services from core
(spec-kitty/spec-kitty) into this repository with their git history
(ADR-0002). Mission
events-domain-services-home-01M64MSB work packages WP07 (import and build) and WP08 (first
release and handshake) followed it step by step.
Nothing here runs without the operator’s go-signal (spec constraint C-001): no import, no tag, no issue move, no layout-changing PR before it. Steps marked [operator] need a separate, explicit approval each. Every step that changes GitHub carries that marker: each
git push(branch or tag), each PR opened, merged or closed, each remote branch deleted, and eachghcall that writes. Local commands in scratch or in a local checkout do not. Never pushmain, never force-push anything, and never delete or reset the mission branch.
The commands use these names. Write their values into the import PR description as you go.
| Name | Value |
|---|---|
FROZEN_SHA | the 40-hex core commit the freeze pins (step 1) |
FROZEN_TREE | 99c06d1dba366c65c1260342c3e6370c8233953e, the git tree of core services/ the freeze gate pins |
SCRATCH | an empty scratch directory outside every checkout; nothing in it is ever pushed |
CORE | a local core checkout (read-only here: nothing is fetched into it, nothing is written to it) |
WATCH | $SCRATCH/core-watch, an unfiltered full clone of core made in step 1; it holds FROZEN_SHA and origin/main for the breach checks |
EVENTS | this repository’s checkout |
MISSION_BRANCH | issue-147-events-services-home, the mission branch: WP01 to WP06 and the spec-kitty status history. This runbook never deletes, resets or force-pushes it. |
IMPORT_BRANCH | issue-147-service-import, the dedicated branch the import runs on (step 3), and its own PR to main. Rollback before merge deletes only this branch and its PR. |
PRE_IMPORT | the commit IMPORT_BRANCH is cut from, recorded before the merge (step 3) |
IMPORTED_PATHS | the core paths the import takes, exactly as in the filter-repo command (step 2.3) |
IMPORTED_PATHS=( services/mission-status-api/ contracts/mission-status/ contracts/mission-write/ contracts/_shared/ contracts/tools/ contracts/gradle/ contracts/lint/ contracts/README.md contracts/build.gradle contracts/settings.gradle docs/architecture/event-ledger-writers-and-readers.md)1. Preconditions
Stop unless every line holds.
-
The operator’s go-signal is recorded in the mission (status history or the session), with its date.
-
The active core missions that touch
services/mission-status-api/or the service contracts are merged in core. -
The events-side freeze checks are the binding line. Steps 1.6 (the object-id table) and 1.7 (the breach log) decide whether the cutover goes ahead. Run both whatever state core’s gate is in; if both pass, go ahead. Core’s own gate is core PR spec-kitty/spec-kitty#6782, with
tests/architectural/test_events_import_frozen.py. It pins all eleven imported paths (services/at treeFROZEN_TREE, and the ten others) to the same object ids as the table in 1.6, and it runs on every core PR. Core’scontracts/fixtures/stays in core and is not frozen. Confirm with the core session that #6782 has merged, and record the answer. Core’s session confirmed on 2026-10-29 that the gate covers every imported path. Do not hold the cutover for #6782 if 1.6 and 1.7 both pass: the events-side checks bind either way. -
The frozen SHA is chosen and written down. Core’s session sends it when #6782 merges. Record it as
FROZEN_SHA. -
Make the watch clone. A full, unfiltered clone of core in scratch.
FROZEN_SHAis fetched into it, never intoCORE, and pinned by a branch so the extraction clone in step 2 receives it.Terminal window FROZEN_SHA=<the sha core sent>FROZEN_TREE=99c06d1dba366c65c1260342c3e6370c8233953emkdir -p "$SCRATCH" && cd "$SCRATCH"git clone --no-local --no-checkout "$CORE" core-watchWATCH="$SCRATCH/core-watch"git -C "$WATCH" remote set-url origin https://github.com/spec-kitty/spec-kittyif [ "$(git -C "$WATCH" rev-parse --is-shallow-repository)" = true ]; thengit -C "$WATCH" fetch --unshallow origin mainfigit -C "$WATCH" fetch origin main "$FROZEN_SHA"git -C "$WATCH" branch -f frozen "$FROZEN_SHA"git -C "$WATCH" rev-parse --is-shallow-repository # expected: falsegit -C "$WATCH" merge-base --is-ancestor "$FROZEN_SHA" origin/main && echo "frozen sha on main: OK"filter-reporewrites only the history it has, so a shallow clone silently drops commits (a shallow local core gave 34 commits instead of 141 in the dry run). The watch clone is never filtered: the breach checks need core’s real history. -
Verification 1: every imported path is the frozen object. At
FROZEN_SHA, each path must have the git object id core’s freeze gate pins:Object id Path 99c06d1dba366c65c1260342c3e6370c8233953eservices(FROZEN_TREE)a09d96532581d244b5dd0f295a23cf3705d0cd00contracts/mission-status3f52fa137ee62aa48469c3e0cdbea4efb0f65be3contracts/mission-writefa7cc44678491c5b0d87eb4b1441f0945a375ed4contracts/_shared6235043e87c4ba3b77f7708e80052b843dcb14c5contracts/toolsafea11080e3f206cddf9212e472ac56b047224c7contracts/lint4a5e2c489b274718b7c0bdd9bc2a2ef009474e93contracts/gradle79436249bde4a84af4467d0b2fb180104e6417c4contracts/README.md2ebf317f01cdce199eaef571c7a6c1febb3be3becontracts/build.gradlec4b8720e271103c957b5a02253b99f6e815f155bcontracts/settings.gradlec2943d4997a19d10ffd1289e70220ec602f4e3acdocs/architecture/event-ledger-writers-and-readers.mdTerminal window bad=0while read -r id path; dogot="$(git -C "$WATCH" rev-parse "$FROZEN_SHA:$path")"if [ "$got" = "$id" ]; then echo "OK $path"; else echo "DIFF $path ($got)"; bad=1; fidone <<'EOF'99c06d1dba366c65c1260342c3e6370c8233953e servicesa09d96532581d244b5dd0f295a23cf3705d0cd00 contracts/mission-status3f52fa137ee62aa48469c3e0cdbea4efb0f65be3 contracts/mission-writefa7cc44678491c5b0d87eb4b1441f0945a375ed4 contracts/_shared6235043e87c4ba3b77f7708e80052b843dcb14c5 contracts/toolsafea11080e3f206cddf9212e472ac56b047224c7 contracts/lint4a5e2c489b274718b7c0bdd9bc2a2ef009474e93 contracts/gradle79436249bde4a84af4467d0b2fb180104e6417c4 contracts/README.md2ebf317f01cdce199eaef571c7a6c1febb3be3be contracts/build.gradlec4b8720e271103c957b5a02253b99f6e815f155b contracts/settings.gradlec2943d4997a19d10ffd1289e70220ec602f4e3ac docs/architecture/event-ledger-writers-and-readers.mdEOFtest "$bad" = 0 && echo "frozen ids: OK"Expected: eleven
OKlines, thenfrozen ids: OK. AnyDIFF: stop. Core’s paths at that SHA are not what the freeze pinned; ask core for the right SHA. (At the dry-run commit4eecb124all eleven match.) -
Verification 2: no freeze breach since
FROZEN_SHA. No core commit onmainafterFROZEN_SHAmay touch an imported path. A commit to, say,contracts/mission-write/would otherwise be lost without anyone noticing.Terminal window git -C "$WATCH" fetch origin maingit -C "$WATCH" log --oneline "$FROZEN_SHA"..origin/main -- "${IMPORTED_PATHS[@]}"Expected: no output. Any line is a breach: stop and go to section 9. This check runs again as the last gate before the operator merges the import PR (step 5). (At
4eecb124against coremaind68c95a4it printed nothing; with the range moved to start just before0d8c32ba, it printed that commit.)
2. Extraction (scratch)
-
The extraction clone, from the watch clone, so it is full and holds
FROZEN_SHA(branchfrozen):Terminal window cd "$SCRATCH"git clone --no-local --no-checkout "$WATCH" core-extractcd core-extractgit rev-parse --is-shallow-repository # expected: falsegit checkout -q -B extract "$FROZEN_SHA"Do not delete other branches: whatever core’s default branch is called, filter-repo rewrites every ref and drops the
originremote, and onlyextractis fetched and merged in step 3. The clone also carries core’s tags; step 3 fetches with--no-tagsso none of them reaches this repository. -
Install filter-repo (2.47.0 was used in the dry run):
Terminal window python3 -m pip install --user git-filter-repo==2.47.0git filter-repo --version # 2.47.0 prints a40bce548d2c -
Filter (research R-2). The
--patharguments areIMPORTED_PATHS.--forceis needed because the clone is no longer fresh after the checkout; it is a throwaway scratch clone.Terminal window git filter-repo \--path services/mission-status-api/ \--path contracts/mission-status/ --path contracts/mission-write/ --path contracts/_shared/ \--path contracts/tools/ --path contracts/gradle/ --path contracts/lint/ \--path contracts/README.md --path contracts/build.gradle --path contracts/settings.gradle \--path docs/architecture/event-ledger-writers-and-readers.md \--path-rename services/mission-status-api/:service/ \--forceExpected:
Completely finished after <n> seconds. -
Verify the history.
Terminal window git rev-list --count extract # 141 at 4eecb124; at least 141 at a later FROZEN_SHAgit rev-list --merges --count extract # 0git ls-tree -r --name-only extract | wc -l # 1904 at 4eecb124git log -1 --format='%s' extract # the last core commit that touched an imported path -
Verify the content against core at the frozen SHA, read from the watch clone:
Terminal window mkdir -p "$SCRATCH/src"git -C "$WATCH" archive "$FROZEN_SHA" services/mission-status-api contracts \docs/architecture/event-ledger-writers-and-readers.md | tar -x -C "$SCRATCH/src"diff -r service "$SCRATCH/src/services/mission-status-api" && echo "service: clean"for p in mission-status mission-write _shared tools gradle lint README.md build.gradle settings.gradle; dodiff -r "contracts/$p" "$SCRATCH/src/contracts/$p" >/dev/null && echo "contracts/$p: clean" || echo "contracts/$p: DIFF"donediff docs/architecture/event-ledger-writers-and-readers.md \"$SCRATCH/src/docs/architecture/event-ledger-writers-and-readers.md" && echo "doc: clean"Expected: every line ends in
clean. Core’scontracts/fixtures/is not imported, on purpose, so compare per path, not the wholecontracts/directory. AnyDIFF: stop.
3. Merge (on the dedicated import branch)
The import never runs on MISSION_BRANCH. Cut IMPORT_BRANCH from main once the mission
PR with WP01 to WP06 has merged (preferred), or, if it has not, from the tip of
MISSION_BRANCH; either way MISSION_BRANCH itself is left as it is. Record the base as
PRE_IMPORT:
cd "$EVENTS"git status --porcelain # expected: no output (a clean tree)git fetch origingit switch --no-track -c issue-147-service-import origin/main # or: origin/issue-147-events-services-homePRE_IMPORT="$(git rev-parse HEAD)" # write it into the import PR descriptiongit remote add core-extract "$SCRATCH/core-extract"git fetch --no-tags core-extract extractgit merge --allow-unrelated-histories --no-ff --no-commit core-extract/extract--no-track keeps IMPORT_BRANCH from tracking its base. With tracking set, a bare
git push could target main under some push.default settings. Nothing is pushed in this
step; step 5 pushes the branch with an explicit
git push -u origin issue-147-service-import [operator].
Expected: exactly one conflict, CONFLICT (add/add): Merge conflict in contracts/README.md.
Any other conflict: git merge --abort and stop.
-
Resolve
contracts/README.md. Keep this repository’s prose as it is (git show :2:contracts/README.md), then add a## Service contractssection that holds core’s README (git show :3:contracts/README.md) without its title and with every heading one level down. Fix its relative links if they now point elsewhere.git add contracts/README.md. -
Commit with the frozen SHA in the subject and the command in the body. Write the message to a file in scratch (the shell fills in
$FROZEN_SHA), then commit with it:Terminal window cat > "$SCRATCH/import-msg.txt" <<EOFImport events-domain services from spec-kitty/spec-kitty@$FROZEN_SHA (#147)History extracted with git filter-repo 2.47.0 from a full clone at $FROZEN_SHA:git filter-repo --path services/mission-status-api/ --path contracts/mission-status/ \\--path contracts/mission-write/ --path contracts/_shared/ --path contracts/tools/ \\--path contracts/gradle/ --path contracts/lint/ --path contracts/README.md \\--path contracts/build.gradle --path contracts/settings.gradle \\--path docs/architecture/event-ledger-writers-and-readers.md \\--path-rename services/mission-status-api/:service/ --forcecontracts/README.md: kept the events prose, added a "Service contracts" section.EOFgit commit -F "$SCRATCH/import-msg.txt"git log -1 --format='%s | parents %p' # the subject, then PRE_IMPORT and the extract tip -
Verify the merge and drop the remote.
Terminal window git rev-list --count HEAD^2 # same count as step 2.4diff -r service "$SCRATCH/src/services/mission-status-api" && echo "merged service/: clean"git log --follow --format='%ad' --date=short service/build.gradle.kts | tail -1 # a date in 2026-10git remote remove core-extractgit tag --points-at HEAD^2 # expected: no output (no core tag came along)
The imported commits stay as they are: no rebase, squash or amend across them. [operator] The operator merges the import PR with a merge commit, never squash or rebase, or the history is lost.
4. Post-import edits (WP07)
Each edit is its own commit after the merge commit.
-
Path fixes (research R-1):
service/build.gradle.kts:72: thecontractRootdefault../../contractsbecomes../contracts.service/src/test/java/org/speckitty/missionstatus/adapter/in/http/contractdoc/ContractDocumentTest.java:38:../../contractsbecomes../contracts.ArchitectureControlsTest.java:174builds a syntheticfile:/w/services/mission-status-api/...URL; check it still passes and leave it.grep -rn 'services/mission-status-api' service contracts: fix real paths, leave historical comments.
-
Root Gradle integration (WP07 T032): the root
settings.gradle.ktsincludes:mission-status-api(service/),:domain-modeland:event-log; the service’s own settings file and wrapper go; its catalog merges into the root catalog and its verification metadata into the rootgradle/verification-metadata.xml.contracts/joins the same root build as the project:contracts(its Groovybuild.gradlestays), so./gradlew verifyAllruns its checks too;contracts/tools/pins.jsonandgradle_pin_check.pymove from Gradle 8.14.5 to the root wrapper’s 9.8.1 (ADR 0003). -
The core pin. Add
service/core-pin.json:{"repository": "spec-kitty/spec-kitty", "sha": "<FROZEN_SHA>", "purpose": "CI-only peers: lock interop and the nightly corpus oracle (ADR 0002 D4)"}With
service/build.gradle.ktsand the pin present,service.yml’sdetectjob turns the guarded jobs on (contract-bundle,native,lock-interop,nightly-corpus) with no edit to the workflow. -
The lock-interop peer.
service.yml’slock-interopjob already setsSPEC_KITTY_LOCK_INTEROP_PEER(the peer script in the pinned core checkout,core/scripts/ci/lock_interop_peer.py) andSPEC_KITTY_LOCK_INTEROP_PYTHON. MakePythonPeer(service/event-log/src/test/java/org/speckitty/missionstatus/spike/lockinterop/PythonPeer.java) readSPEC_KITTY_LOCK_INTEROP_PEERfirst and fall back to its old relative walk forscripts/ci/lock_interop_peer.py. Without it the test throwsIllegalStateExceptionhere, because the walk never reaches the core checkout. -
The launcher contract. Add the launcher-to-write-service process contract to
contracts/mission-writeas a launcher section. Its text is the one the operator accepted on 2026-10-29, in write-service protocol, “Process lifecycle”; copy it from there, and keep/shutdownmarked provisional. (Done at cutover;/shutdownwas settled later, whencommand-cliwas built, #156.) -
The writers-and-readers page. Keep its history:
git mv docs/architecture/event-ledger-writers-and-readers.md docs/architecture/services/event-ledger-writers-and-readers.md, then add DocKitty frontmatter and link it fromdocs/architecture/services/README.md. -
CI follow-ups. Decide each and record the decision in the PR:
- Core’s cross-leg native digest comparison (
scripts/ci/mission_status_gate_checks.py digests) andnativePerf: wire them through the core-pin checkout, or record them as deliberately omitted. Thedigest-<target>artifacts are already uploaded by thenativejob. - Lock interop: it runs on PRs and
mainpushes but not inside a release run, because it executes core’s Python (service.ymlguards it withinputs.release-version == ''). Decided 2026-10-31: it stays a hard need ofservice-gate(blocking on PRs andmain). - Reachability metadata: upload the metadata the native tests generate as a
nativejob artifact for review (ADR 0003, Risks). make test-full(what the CI agent runs) reaches the Java build only throughtest-java(:java-binding:check). Point it at./gradlew verifyAll, with the contract-bundle exports from section 5, so the CI agent’s suite covers the services.
Decisions recorded for the import PR (WP07, 2026-10-30):
- Reachability metadata: done. The
nativejob uploadsreachability-metadata-<target>(Spring AOT’sMETA-INF/native-imagehints for the image and the test image, and any the Native Build Tools copied from the GraalVM metadata repository) withif-no-files-found: warn, for review only. - Cross-leg digest comparison and
nativePerf: deliberately omitted forservice-v0.1.0-rc.1; follow-up. Neither is wired through the core-pin checkout. Thedigest-<target>artifacts are still uploaded, so the comparison can be run by hand and wired in a later PR without a workflow-shape change. Core’s third native guard, thenative-tag-floorcheck (at least 3 executed native tests per leg), is ported:scripts/ci/mission_status_gate_checks.py(verbatim from core) runs in eachnativeleg. - Lock interop: blocking on PRs and
main(operator decision, 2026-10-31). It is a hard need ofservice-gate, so a red run fails the gate; it never runs inside a release run (it executes core’s Python). Core treated it as evidence only; this repository keeps it blocking, and a tag is cut only from amaincommit whoseservice-gateis green. make test-full: done. It runsscripts/verify_all.shthroughmake test-gradle(the bundle exports, then./gradlew verifyAll), so the CI agent’s suite covers the services andcontracts/.
- Core’s cross-leg native digest comparison (
-
The guides. Flip
doc_statusof this page, running the service and service protocol and releases fromdrafttoactive, and their citations from core4eecb124to the paths here. Do the same for the services architecture pages, whose banners now say the code lives here, and pointservice/README.mdat theservice-v*line (ADR 0003).
5. Verification
Record each command and its counts in the PR. verifyAll runs :mission-status-api:check,
whose bundleContract task needs the contract bundle, so build it first, outside the
repository, exactly as service.yml’s contract-bundle and gradle jobs do:
export LC_ALL=C.UTF-8out="$(mktemp -d)"uv run --frozen python contracts/tools/bundle.py --root contracts --out "$out" --bundle-onlyexport CONTRACT_BUNDLE="$out/bundle/mission-status/openapi.yaml"export CONTRACT_BUNDLE_SHA256="$(sha256sum "$CONTRACT_BUNDLE" | cut -d' ' -f1)"
./gradlew --no-daemon verifyAll # per module; about 883 @Test + 66 parameterized + 6 factories, more at run timemake test-fastuv run pytest --pyargs spec_kitty_events.conformanceruff check . && ruff format --check .node ../doc-kitty/src/scripts/validate-frontmatter.mjs docsnode ../doc-kitty/src/scripts/check-links.mjs docsWithout CONTRACT_BUNDLE and CONTRACT_BUNDLE_SHA256 (or -PcontractBundle and
-PcontractBundleSha256), bundleContract fails and names what is missing.
Expected: all green, with the ArchUnit and contract conformance tests passing.
[operator] Push IMPORT_BRANCH only (no tag), with an explicit upstream, and open its PR to
main:
git push -u origin issue-147-service-importservice.yml’s guarded jobs must run green on the PR.
Last gate, just before the operator merges the import PR: re-run Verification 2 (step 1.7) in the watch clone:
git -C "$WATCH" fetch origin maingit -C "$WATCH" log --oneline "$FROZEN_SHA"..origin/main -- "${IMPORTED_PATHS[@]}"Expected: no output. Any line: do not merge; go to section 9. No line: [operator] the operator merges the import PR with a merge commit (step 3).
6. First release and core handshake (WP08)
After the import PR is merged:
- [operator] Approve the version, then cut
service-v0.1.0-rc.1(or the version the operator names) as service protocol and releases describes. - Verify every asset (
sha256sum --check --strict SHA256SUMS,gh attestation verify <asset> --repo spec-kitty/spec-kitty-events --signer-workflow spec-kitty/spec-kitty-events/.github/workflows/service-release.yml --source-ref refs/tags/<tag>) and record the native binary sizes. - Send core’s session the tag, the asset names and their sha256 sums. Core pins them.
7. Issue moves
What happened at the 2026-10-31 cutover. No issue was transferred. The core session had no write access to this repository, so the operator approved re-filing instead: every “transfer” row below was re-filed here as a new issue linking its core original, and the eight originals 6159, 6194, 6196, 6197, 6198, 6199, 6268 and 6409 were closed
not_planned. 6117 was split, not moved: its events half is #163 and the core epic stays open. 6159 was not in the plan below and moved too. The labels did not carry over (#207).
Core # Events # 6117 (epic, split) #163 6194 #160, #161 6196, 6197, 6198, 6199 #165, #166, #167, #168 6409, 6268 #169, #170 6159 #164 6195, 6676, 5528, 957, 6609 (split) #155, #156, #157, #158, #159 The table and steps below are the plan as written before the cutover; keep them for a future move where transfer is possible.
[operator] Every move below needs the operator’s approval first. Transferred issues get new numbers here; record the old-to-new map in the PR.
| Core # | Method | Events side | Core side keeps |
|---|---|---|---|
| 6117 (epic) | transfer | epic | — |
| 6194, 6196, 6197, 6198, 6199 | transfer, together with 6117 | children | — |
| 6409, 6268 | transfer | issues | — |
| 6195 | split | Java cut-over half | binding the CLI client, deleting the Python appenders |
| 6676 | split | native build of the command-cli binary the launcher starts | CLI launcher, fail-closed codes |
| 5528 | split | read-API service/contract work | dashboard consumers |
| 957 | split | Java route | Python oracle |
| 6609 | split | Java reducer ordering | Python CLI reducer |
| 6692 | close as done, link ADR 0002 | — | — |
| 6608 | stays; link the moved issues | — | epic |
-
[operator] Create the labels first. For each issue to transfer, list its labels and create any that this repository lacks, with the same name and colour:
Terminal window gh api repos/spec-kitty/spec-kitty/issues/6117 --jq '.labels[] | [.name, .color] | @tsv'gh api repos/spec-kitty/spec-kitty-events/labels -f name='<name>' -f color='<color>' -
[operator] Transfer the epic and its children together, in one sitting, so the sub-issue links survive. On exe.dev VMs use
gh api:Terminal window repo_id="$(gh api repos/spec-kitty/spec-kitty-events --jq .node_id)"for n in 6117 6194 6196 6197 6198 6199 6409 6268; doissue_id="$(gh api "repos/spec-kitty/spec-kitty/issues/$n" --jq .node_id)"gh api graphql -f query='mutation($i:ID!,$r:ID!){transferIssue(input:{issueId:$i,repositoryId:$r}){issue{number url}}}' \-f i="$issue_id" -f r="$repo_id"doneThen check the epic’s sub-issues here (
gh api repos/spec-kitty/spec-kitty-events/issues/<new epic>/sub_issues) list the five children. -
[operator] Split the rest. For each split row, file an events issue and leave the core issue open with the core half:
- Title:
[from spec-kitty#<n>] <the events half, as in the table> - Body: first line
Split from spec-kitty/spec-kitty#<n> at the services cutover (ADR 0002)., then the events half of the work, and what stays in core. - Forward link: comment on the core issue:
The <events half> moved to spec-kitty/spec-kitty-events#<new>; this issue keeps <core half>.
- Title:
-
[operator] #6692 is closed by the core session, as completed, with a link to ADR-0002.
-
[operator] #6608 stays in core; comment on it with the list of moved and split issues.
8. Rollback
Rollback never touches MISSION_BRANCH (issue-147-events-services-home): it is not
deleted, reset or force-pushed. Nothing is force-pushed anywhere.
-
Before the import PR merges: [operator] close the import PR and delete only
IMPORT_BRANCH. Closing the PR and deleting the remote branch change GitHub, and after step 4 the branch also holds the WP07 commits, so the operator approves this first:Terminal window git switch issue-147-events-services-home # or main; anything but the import branchgit branch -D issue-147-service-importgit push origin --delete issue-147-service-import # [operator]; only if it was pushed; a delete, not a force-pushNothing reached
main. To try again, cutIMPORT_BRANCHafresh fromPRE_IMPORT(git switch -c issue-147-service-import "$PRE_IMPORT") and redo step 3. -
After it merges: revert the merge commit on a new branch (
git revert -m 1 <merge sha>). [operator] Pushing that branch and opening its PR need the operator’s approval, and the operator merges the revert PR after review. Never force-pushmain. A publishedservice-v*release is not deleted. [operator] Editing its notes to mark it withdrawn is a GitHub write; then tell core to keep its old pin. -
Re-importing after that revert: merging the same extraction again is a no-op (
Already up to date.): its commits are already inmain’s history, soservice/stays deleted. A fresh filter-repo run gives the same rewritten commits (it is deterministic: the dry runs both ended at95e201f), so it does not help on its own either. Instead revert the revert (git revert <revert sha>) on a new branch. [operator] Pushing it and opening its PR need the operator’s approval, and the operator merges that PR after review. If core has moved since, then merge a fresh extraction from the newFROZEN_SHAon top: only its newer commits come in.
9. If the freeze is breached
If core commits to any of IMPORTED_PATHS after FROZEN_SHA (step 1.7 or the last gate in
step 5 prints a line), the import is stale.
- Before the import PR merges: take the new SHA from core and repeat from step 1 (both
verifications, with the object ids core’s gate now pins). Then [operator] close the import PR and delete
IMPORT_BRANCHas in section 8 (the operator approves both), cut it afresh fromPRE_IMPORTand redo steps 2 and 3 on it.MISSION_BRANCHis untouched. Never cherry-pick core commits across: they would carry no link to their history. - After it merges: this repository is canonical. Ask core for the change and re-make it here on a new branch. [operator] Pushing it and opening its PR need the operator’s approval, and the operator merges it after review. Again, no cherry-pick.
10. Repairing a torn status log
Use this section when a write answers 500 STATUS_EVENT_PERSISTENCE_VERIFICATION_FAILED and the
Mission’s status.events.jsonl does not end in a newline. A write never repairs the log. The
explicit repair operation does, and an operator runs it. The operation is
POST /api/v1/missions/{missionId}/status-log-repairs (#222).
[operator] Check the log first. The command prints \n when the log ends in LF:
GCD="$(git rev-parse --path-format=absolute --git-common-dir)"MISSION_DIR="kitty-specs/<mission-slug>" # the Mission's directory, relative to the checkouttail -c 1 "$MISSION_DIR/status.events.jsonl" | od -An -cThen check that no writer holds the log. The repair takes the same Mission lock a write takes, but a writer outside the service (a stray core process, an editor) is not bound by it. The command must print nothing:
fuser "$MISSION_DIR/status.events.jsonl" 2>/dev/null || lsof "$MISSION_DIR/status.events.jsonl" 2>/dev/nullIf it lists a process, wait for it or stop it, and check again before you call the operation.
Call the operation with curl
Until core’s repair verb ships (spec-kitty/spec-kitty#7482, linked to spec-kitty/spec-kitty#6195),
call the operation directly. The write service keeps its port and token in endpoint.json, in
<git common dir>/spec-kitty-write-service/ (LAUNCHER.md, “Single instance”). The file holds
host (always 127.0.0.1), port, token, instance_id and pid. Read port and token from
it, and never paste the token into a log or a chat.
EP="$GCD/spec-kitty-write-service/endpoint.json"PORT="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["port"])' "$EP")"TOKEN="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["token"])' "$EP")"MISSION_ID="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["mission_id"])' "$MISSION_DIR/meta.json")"
# The token goes in on stdin as a curl config, so it never appears in the process list.printf 'header = "Authorization: Bearer %s"\n' "$TOKEN" | curl -sS --config - -X POST \ "http://127.0.0.1:$PORT/api/v1/missions/$MISSION_ID/status-log-repairs" \ -H "Spec-Kitty-Write-Protocol: 1" \ -H "Content-Type: application/json" \ -d "{\"context\": {\"actor\": \"<your-actor>\", \"checkout\": \".\", \"missionDirectory\": \"$MISSION_DIR\", \"writeSurface\": \"checkout_append\", \"destinationRef\": null}}"unset TOKENThe request body has one member, context. Its actor is any non-empty string. checkout is .
for the repository root checkout, and destinationRef is null. The missionId in the path is the
mission_id in the Mission’s meta.json.
A 200 answer has one of three actions. The fields are repaired, action, movedBytes,
quarantinedFile and readableAfterRepair:
action | What happened | Answer |
|---|---|---|
none | The log was missing, empty or ended in LF. Nothing was touched, and no file was created. | repaired: false, movedBytes: 0, quarantinedFile: null |
completed | The tail was exactly one status row, with an event_id no earlier row has, that folds after the log’s prefix. One LF was appended. | repaired: true, movedBytes: 0, quarantinedFile: null |
quarantined | Any other tail. The fragment was moved to status.events.jsonl.torn beside the log, and the log was cut to its last LF. | repaired: true, movedBytes is the fragment’s length, quarantinedFile: "status.events.jsonl.torn" |
Other answers:
401 WRITE_TOKEN_INVALID: the token is wrong. Read the endpoint file again.404 MISSION_NOT_FOUND: nometa.jsonhas thismission_id.409 STATUS_LOCK_HELD: the Mission lock was not free within the 10 s budget. Retry later.422 WRITE_LOCATION_UNVERIFIED: a coordination-routed Mission. See the limit below.503 SERVICE_BUSY(retry after 1 s), or503 SERVICE_DRAINING(read the endpoint file again; the service is stopping).500 STATUS_EVENT_PERSISTENCE_VERIFICATION_FAILED: the repair failed, and no byte was lost. The repair may have taken effect, so run it again.
After the repair
quarantined. The fragment is in$MISSION_DIR/status.events.jsonl.torn. Read it, and keep it until the cause of the tear is understood: it is the only copy of those bytes. The file is untracked, inside a tracked Mission directory, so core’s dirty-tree checks may notice it. The contract and this repository do not say how core’s checks treat it. Checkgit statusbefore the next lifecycle command, and if a check stops on the file, state that uncertainty and ask.readableAfterRepair: false. The log still does not fold as the next write would, so writes fail for another reason. Stop, do not run the repair again, and escalate.- A torn multi-row unit, after a
quarantinedrepair. The rows that landed before the tear stay in the log. Retrying the same unit then answers409 EVENT_ID_CONFLICT, because some of itsevent_ids are present and some are not. Re-issue the unit with newevent_ids.
Limit: coordination-routed Missions
Until migration step 4 serves the coordination ref, the operation answers
422 WRITE_LOCATION_UNVERIFIED for a coordination-routed Mission. For such a Mission the remedy is
manual.
[operator] First find the log core actually writes for this Mission. A coordination-routed
Mission’s status is written through its coordination worktree (ADR-0007: today under
.worktrees/<mission>-coord/), so the authoritative file is
<coordination worktree>/<missionDirectory>/status.events.jsonl, not the copy under the root
checkout’s kitty-specs/. Confirm it is the file core’s last write touched (its last line is the
torn one) before you change anything. If you cannot tell which file is authoritative, stop and ask.
Stop the write service with POST /api/v1/shutdown, or let it exit on its idle timeout. Make sure no
core writer is running for that Mission. This guide does not verify which lock file core takes for
a coordination-routed Mission, and it does not show a command that takes the lock. Be sure no other
process is running before you cut.
Core’s remedy text (src/kernel/event_log_append.py on core main) says to inspect the file and
cut the bytes after its last newline. The script below also keeps a copy of the cut bytes in
status.events.jsonl.torn, so no byte is lost. That copy is this guide’s addition, not core’s
text.
LOG="<coordination worktree>/<missionDirectory>/status.events.jsonl" # the file you confirmed abovepython3 - "$LOG" <<'EOF'import os, syspath = sys.argv[1]with open(path, "rb+") as log: data = log.read() cut = data.rfind(b"\n") + 1 if cut == len(data): sys.exit("the log ends in LF; nothing to cut") with open(path + ".torn", "ab") as torn: torn.write(data[cut:] + b"\n") torn.flush() os.fsync(torn.fileno()) log.truncate(cut) log.flush() os.fsync(log.fileno())# As the service does, sync the directory too, so the new .torn entry survives a crash.dir_fd = os.open(os.path.dirname(os.path.abspath(path)), os.O_RDONLY)try: os.fsync(dir_fd)finally: os.close(dir_fd)EOFThen start the service again with the launcher, as core does for any write.