Skip to content

feat(tooling): maintained live-proxy deploy and rollback scripts (#80) - #81

Merged
anuzzolilli-oss merged 5 commits into
masterfrom
2026-11-18_live-deploy-scripts
Nov 18, 2026
Merged

anuzzolilli-oss merged 5 commits into
masterfrom
2026-11-18_live-deploy-scripts

Conversation

@anuzzolilli-oss

@anuzzolilli-oss anuzzolilli-oss commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Scope

Closes #80. Adds maintained deploy and rollback scripts for the live proxy, a sandbox test for them, and the matching documentation. No change under src/, kernel/ or pi-subagents/; no config or env surface; nothing is shipped in the npm package.

Nothing in this PR was run against the live proxy. No deployment took place, port 8787 was not contacted, and nothing was written under %APPDATA%\CindyGlobal\billion-context-proxy. The scripts have only ever run against throw-away sandboxes.

Area Files
Scripts scripts/live-deploy/Deploy-LiveProxy.ps1, Rollback-LiveProxy.ps1, LiveProxy.Common.ps1
Test tests/live-deploy-scripts.test.ts, tests/fixtures/live-deploy/ (stand-in launcher, stand-in proxy, file-backed task driver)
CI registration scripts/live-files.mjs (appended last), scripts/ci-shard-weights.json
Docs reference/cindy-project.md + .zh-CN.md, one sentence in reference/testing.md

What the scripts do

Deploy-LiveProxy.ps1 follows the documented steps 3–9 in the sanctioned order (owner decision 2026-11-16, #78): preflight checks, backup and deployment record, hold (inhibit, task disabled, supervisor stopped), launcher edit, lift, the supervisor starts the new release, success test, receipts. Rollback-LiveProxy.ps1 undoes one deployment from the deploy-record.json that the deploy wrote into its backup folder.

  • Nothing about a release is written into the scripts. Version, commit, source commit, bundle hash, port, task name and the expected configuration hash are parameters; the previous release is read from the launcher.
  • -PreflightOnly runs every check and changes nothing.
  • A failed deployment rolls back. A failed rollback ends as step 8 describes: hold back in place, proxy left as it is, nothing further attempted, exit 4, evidence written to the backup folder.
  • A launcher or inhibit changed by someone else during the run is never overwritten.
  • Only one deploy or rollback runs per runtime root at a time (exclusive operation lock, released when the process ends).
Exit Meaning
0 deployed / restored / preflight passed
2 refused before anything changed
3 deployment failed and the previous release is back
4 rollback failed; hold in place, owner must look
5 deployed and healthy, but a receipt could not be written
6 error before the hold; nothing in the live state changed

Step 7's functional checks (a real request through the proxy) stay manual, as agreed in the spec.

How it is tested

One test file, 28 tests, Windows only (skipped elsewhere). Each scenario builds its own sandbox in the temp folder: a stand-in launcher run by Windows PowerShell as supervisor, a stand-in proxy answering the health endpoint, and a file-backed stand-in for the scheduled task.

  • Static rules: no release identity, port, task name or profile path in the scripts; exactly the documented parameters.
  • Refusals: about 30 input and preflight refusals, each for its own reason and each leaving the sandbox untouched, after a positive control that the same sandbox passes.
  • Deployments: success with receipts and supervision proven, then standalone rollback; rebuild of the same commit; candidate never healthy; client connecting after the hold; failed rollback and retry; launcher restore error; hold that cannot be re-applied; hold that cannot be applied; foreign inhibit; foreign launcher edit during the hold and during the rollback; healthy candidate whose supervision report does not match; second run refused while one is running; unwritable receipt; deploy process killed mid-run; standalone rollback killed mid-run and retried; rollback against the wrong backup.

The test-only seam (-TestTaskDriver) works only when the runtime root contains sandbox.marker, and is refused anywhere under the roaming CindyGlobal folder. The real task driver is refused when the marker is present.

Local evidence on the PR head, Windows 11, Node 24, with the files in the line endings a Windows checkout gives them (CRLF; the first two commits were also run with LF):

  • tests/live-deploy-scripts.test.ts: 28 pass, 0 fail, about 4.5 minutes, no sandbox folder or process left behind.
  • npm run typecheck, check-unused-exports, check-test-import-graph, check-architecture-docs, tests/ci-shard-weights.test.ts, git diff --check: pass.
  • Docs: ten steps in each language, sentence-for-sentence parity for the changed text.

Local verification is targeted; CI on the pushed head is the authority.

Departures from the spec in #80

  1. Receipts are edited as JSON trees, not re-serialised with ConvertTo-Json, so fields the script does not own keep their exact text.
  2. "Client" is defined as a loopback connection to the proxy port whose owning process is neither the script nor the supervisor. The spec left the definition open.
  3. The standalone rollback accepts a disabled task in one case (spec AC-13 required an enabled task always): when this deployment's own hold is in place, or its record stopped inside the hold window (holding, held, cut, rolling-back, rollback-failed). A deploy killed between "inhibit removed" and "task enabled" leaves exactly that state, and the rollback must be usable there. A disabled task that the deployment does not explain is still refused. This changes an accepted acceptance criterion and needs the owner's yes.
  4. A deploy killed at stage held has no test of its own. Kills at the stages before and after it are covered, and the rollback treats held like holding.
  5. Fault injection in the test driver uses its own small vocabulary (failOn, onCall) instead of the names sketched in the spec.

Automated review

The first review on b04db286b raised 15 findings. They are fixed in 209793c6a; two re-reviews left six and then three, fixed in the two commits after it. See the three reply comments for each one. Additions beyond the spec as a result:

  • an operation lock file (live-deploy.lock, present only while a run is in progress);
  • a record stage rolling-back, written by the standalone rollback before it changes anything;
  • PowerShell 7.2 as the minimum;
  • fail-closed recognition of the task action and the supervisor: powershell.exe, only -NoProfile, -NonInteractive, -NoLogo, -ExecutionPolicy, -WindowStyle before -File, spelled in full. Checked read-only against the real scheduled task and the running processes on the deployment machine: the task is accepted, one supervisor and one proxy are matched, and the neighbouring installation is not;
  • an inhibit-ownership check before the launcher edit and again before the lift. If someone else replaced the inhibit, the run ends with exit 4, the foreign file kept and the running proxy never stopped.

Not in this PR

  • The live receipt's deployedConfigSha256 is stale since the 2026-11-15 config change. The script takes the expected hash as a parameter and neither trusts nor rewrites that field.
  • The kept Deploy-Master.ps1 / Rollback-MasterDeploy.ps1 in the backup folder are untouched.

Assisted-by: Cindy (https://cindy.app)

Add scripts/live-deploy with Deploy-LiveProxy.ps1 and Rollback-LiveProxy.ps1,
which follow the documented cutover order: preflight, hold supervision, edit
the launcher, let the supervisor start the new release, verify, write receipts.
A failed deployment rolls back; a failed rollback puts the hold back, leaves
the proxy as it is and exits 4. Nothing about a release is hardcoded: identity,
port, task name and the expected config hash are parameters, and the rollback
reads the deployment record written by the deploy.

The scripts are exercised only against throw-away sandboxes (stand-in launcher,
stand-in proxy, file-backed task driver behind a marker-gated seam that is
refused inside the live installation area). The test is registered as a
process-spawning suite and weighted for sharding.

Docs: reference/cindy-project (en + zh-CN) describe the scripts, their step
coverage and exit codes; reference/testing.md names the right registration file.

Assisted-by: Cindy (https://cindy.app)
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

📦 Built Package Artifact

Branch: 2026-11-18_live-deploy-scripts (6ac461e)

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr81.tgz
npm install -g package

Install instructions are refreshed on each push.

…nt explains it (#80)

The standalone rollback refused nothing about the task's enabled state. It now
accepts a disabled task only when this deployment's own hold is in place or its
record stopped inside the hold window; otherwise it refuses, since someone else
may be doing maintenance. Covered by a new refusal in the sandbox test.

Also give the "candidate never healthy" scenario a wait that is not tight: the
same wait bounds the previous release coming back.

Assisted-by: Cindy (https://cindy.app)
@anuzzolilli-oss
anuzzolilli-oss marked this pull request as ready for review November 18, 2026 04:57
Write-LpEvent 'STEP' 'launcher already is the pre-deployment launcher'
} else {
if (-not (Test-LpSameHash (Get-LpSha256OfBytes $RestoreLauncherBytes) $Ctx.Record.launcherSha256Before)) { throw 'the saved launcher does not match the deployment record' }
Write-LpBytesAtomic $Ctx.LauncherPath $RestoreLauncherBytes

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

CRITICAL: Rollback overwrites launcher edits made after the initial check

If someone edits the launcher while an unhealthy candidate is being checked, automatic rollback reaches this write and silently discards that edit. The branch at line 496 accepts every live hash other than launcherSha256Before; line 499 verifies only the backup, never that the current launcher still matches launcherSha256After. Standalone rollback has the same gap after its preflight check. Revalidate the live launcher under the rollback hold before destructive work, and preserve it with a failed-rollback result when its hash matches neither recorded version. Add a foreign-edit case during rollback, not only during the initial deploy hold.

Stop-LpProcessVerified $listenerProcess
if (-not (Wait-LpUntil { @(Get-LpListenerPids $Port).Count -eq 0 } $StopWaitSeconds 'waiting for the port')) { throw 'the port was not released' }
Write-LpEvent 'STEP' 'current release stopped, port released'
Remove-LpHold $ctx

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Deployment ownership ends before receipt finalization

After this removes the inhibit, another deployment can pass preflight while the first is still checking health or writing receipts. For example, A can prepare P1 receipt bytes at lines 367-368, B can deploy P2, and A can then overwrite B's receipts at lines 369-373 with P1 metadata. B can also back up P1's launcher alongside the still-old P0 receipts. The supervisor lock serializes supervisors, not these scripts. Hold a separate per-runtime exclusive operation lock, shared by deploy and rollback, from snapshot/preparation through final receipt and record writes.

}

try {
Invoke-LpRollback $ctx $backupLauncher $receipts $false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: An interrupted standalone rollback cannot resume

Starting from healthy or receipts-written, terminate this rollback after Remove-LpHold removes the inhibit but before it enables the task (LiveProxy.Common.ps1:351-353). The candidate has been stopped, the task remains disabled, and the record still has the original completed-deploy stage because this script journals nothing until line 139. A retry is then refused by line 119 as unexplained foreign maintenance, leaving the service down. Persist a rollback-in-progress stage before mutation and recognize it during recovery; add the standalone equivalent of the existing deploy-killed-during-enable test.

function Get-LpProcesses([string]$ImageName, [string]$QuotedPath) {
$token = '"' + $QuotedPath + '"'
return @(Get-CimInstance Win32_Process -Filter "Name='$ImageName'" -OperationTimeoutSec 15 -ErrorAction Stop |
Where-Object { $null -ne $_.CommandLine -and $_.CommandLine.IndexOf($token, [System.StringComparison]::OrdinalIgnoreCase) -ge 0 })

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: A bundle path used as data identifies an unrelated process for termination

A process such as node.exe "C:\tools\watcher.mjs" "<candidate bundle path>" matches this predicate even though it is not running the candidate. Invoke-LpRollback force-stops every result of Get-LpProxies at line 489, so a watcher or inspector receiving the bundle as an argument is killed; the creation-time recheck cannot distinguish it. The supervisor matcher has the analogous problem with a launcher path passed as data. Match the actual Node entrypoint or PowerShell -File target, not a quoted token anywhere in the command line.

$now = Get-CimInstance Win32_Process -Filter "ProcessId=$($Process.ProcessId)" -OperationTimeoutSec 15 -ErrorAction Stop
if ($null -eq $now) { return }
if ($now.CreationDate -ne $Process.CreationDate) { throw "pid $($Process.ProcessId) now belongs to a different process; not stopping it" }
Stop-Process -Id $Process.ProcessId -Force -ErrorAction Stop

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Termination reopens a PID after verifying its identity

If the target exits after the CIM creation-time comparison and Windows reuses its PID before Stop-Process -Id opens it, this kills the replacement process. The CIM snapshot does not retain a process handle, and neither the deploy nor rollback callers pin one. Acquire and retain the target's process handle, verify the identity/start time of that handle-backed process against the captured identity, and terminate that same object rather than looking up the PID again.

} catch [LpStop] {
Complete-Lp $ctx $_.Exception 'rollback-result.json'
} catch {
Complete-Lp $ctx ([LpStop]::new(4, 'rollback-failed', "rollback stopped unexpectedly: $($_.Exception.Message). Check by hand that maintenance.inhibit is present, the task is disabled and no supervisor runs.", 'rollback-error', 'report to the owner; no release is confirmed live')) 'rollback-result.json'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Record-write failure returns exit 4 without applying the failure hold

With a readable but read-only deploy-record.json, Invoke-LpRollback can successfully restore and supervise the previous release, then Set-LpStage at line 139 fails while persisting rolled-back. This catch reports exit 4 without invoking Stop-LpRollbackFailed: the inhibit is absent, the task is enabled, the supervisor is running, and no failure evidence is collected. Deploy-LiveProxy.ps1:325,332-333 has the same path. Route exceptions after rollback through the hold/evidence failure routine before emitting the documented exit-4 result.

@@ -0,0 +1,381 @@
#requires -Version 7.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Accepted PowerShell versions lack the receipt API

PowerShell 7.0 and 7.1 satisfy this requirement, but their .NET runtimes do not provide System.Text.Json.Nodes.JsonNode, introduced with .NET 6/PowerShell 7.2. The first executed use is at line 345, after preflight and cutover, so an accepted runtime deploys the candidate but necessarily fails to produce either pending receipt. Raise the minimum and keep the documented prerequisite consistent, or check the required API during preflight.

Suggested change
#requires -Version 7.0
#requires -Version 7.2

assert.match(r.out, / NEXT run the step 7 checks now\. If they fail, roll back with: pwsh .*Rollback-LiveProxy\.ps1/);

// Supervision: the supervisor, not the script, runs the new release.
const livePid = await waitSupervised(sb, CAND.version, CAND.commit);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The supervision identity gate has no negative test

The success case observes valid supervision, but no scenario keeps candidate health valid while reporting an incorrect childPid or healthMatch=false. The launcher stand-in always writes the real child PID and measured health (Start-BillionContextProxy.ps1:68); existing unhealthy-candidate cases fail the earlier health gate. Consequently, deleting the individual status checks in LiveProxy.Common.ps1:378,380 would not be detected. Add a healthy candidate with independently invalid supervision status and assert deployment rejection plus the safe rollback/hold outcome, alongside the positive case required by AGENTS.md's gate-test rule.

assert.equal(fs.existsSync(releaseDir(sb)), false, "no release directory may be created");
assert.equal(backups(sb).length, 0, "no backup folder may be created");
assert.equal(launcher(sb), launcherBefore, "the launcher must be unchanged");
assert.equal(getTask(sb).enabled, true, "the task must stay enabled");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Refusal assertions do not prove that live services were untouched

This helper accepts a preflight/refusal that disables and re-enables the task, or restarts a service, provided the selected files and final enabled value match. The driver already records disable, enable and start calls, but none are checked here, nor are the original proxy/supervisor identities. The roughly 30 refusal cases therefore do not prove their stated no-live-mutation guarantee. Snapshot mutating task-call counters and process identities before each run and assert they remain unchanged, rather than checking only final enablement.

Comment thread tests/live-deploy-scripts.test.ts Outdated
describe("live-deploy scripts: deployment and rollback", { skip: SKIP, concurrency: 4 }, () => {
test("deploys, proves supervision, rewrites receipts; the standalone rollback restores everything", async () => {
// A second sandbox whose name is a prefix-sibling of the first proves the scripts never touch another installation.
const other = await makeSandbox("a10");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The prefix-sibling isolation test creates unrelated roots

makeSandbox("a10") and withSandbox(..., "a1") at line 688 each generate an independent random stem at line 108. Their directory names are therefore not prefix siblings, so the assertions at lines 682-687 do not exercise the boundary case claimed here and would pass a matcher that mistakes one prefix-sibling installation for another. Generate both roots from one shared random stem and assert the prefix relationship before running the isolation scenario.

@kilo-code-bot

kilo-code-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Reviewed the incremental changes from 3fb4a72e6f97bafa98c5c905a4c13a7edb318f3e to 6ac461eeaae17309af7cb6d16b69f7351d2c784f: two files, 77 changed lines, covering PowerShell process matching and process-identity/hold-lift regressions. Default depth; Light pass not used; no sub-agents. No unresolved CRITICAL, WARNING or SUGGESTION findings.

Files Reviewed (2 files)
  • scripts/live-deploy/LiveProxy.Common.ps1
  • tests/live-deploy-scripts.test.ts

Static review only: no files modified and no code or tests executed. Windows execution and exact-head CI were not independently verified. Merge remains subject to required CI and human approval; owner approval for the declared disabled-task acceptance change is not established by the available discussion.

Previous Review Summaries (3 snapshots, latest commit 3fb4a72)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 3fb4a72)

(ai: kilo/openai/gpt-6-astra)

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0

Reviewed the incremental process-identity, hold-recovery and sandbox-test changes from 209793c6 to 3fb4a72e6f97bafa98c5c905a4c13a7edb318f3e: four files, 135 changed lines. Default depth with one independent process-safety review; Light pass not used. Two new inline findings were published and verified; one existing finding remains without a duplicate comment.

Issue Details (click to expand)

WARNING

File Line Issue
scripts/live-deploy/LiveProxy.Common.ps1 248 The matcher skips PowerShell's valid -f abbreviation, so a later script-data -File can identify an unrelated process for termination or approve the wrong task action.
scripts/live-deploy/LiveProxy.Common.ps1 278 The tightened creation-time gate has no negative regression proving that a mismatched snapshot leaves the process alive.
scripts/live-deploy/LiveProxy.Common.ps1 427 The final hold-lift ownership gate still has no independent negative regression.

The retained hold-lift finding is narrower than the new early-hold coverage: the first-disable injection at tests/live-deploy-scripts.test.ts:949 now fails at Deploy-LiveProxy.ps1:308 and takes SkipHoldAndRestore, never reaching Remove-LpHold:427. Removing the final-lift guard would therefore still pass that test. Inject a foreign marker during rollback's second disable, then assert exact marker preservation and no subsequent enable/start calls. The existing comment at line 427 covers this gap and was not duplicated.

Files Reviewed (4 files)
  • scripts/live-deploy/Deploy-LiveProxy.ps1 - 0 issues
  • scripts/live-deploy/LiveProxy.Common.ps1 - 3 issues
  • tests/fixtures/live-deploy/TestTaskDriver.ps1 - 0 issues
  • tests/live-deploy-scripts.test.ts - 0 additional issues

Static review only: no code or tests executed and no files modified. Windows execution and exact-head CI were not independently verified. Owner approval for the declared disabled-task acceptance change remains unestablished in the available discussion.

Previous review (commit 209793c)

(ai: kilo/openai/gpt-6-astra)

Code Review Summary

Status: 6 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 6
SUGGESTION 0

Reviewed the incremental deployment/rollback changes, sandbox regressions, executable stand-ins, and English documentation from b04db286 to 209793c6a80dfbaa0f4dbcfc37a90ab55559cd38. Default-depth review with six independent areas; Light pass not used. Five inline findings were published and verified; one existing inhibit-initialization finding remains and was not duplicated.

Issue Details (click to expand)

WARNING

File Line Issue
scripts/live-deploy/LiveProxy.Common.ps1 235 Command-line matching still selects unrelated scripts for termination; the same pattern also accepts an invalid task action at line 315.
scripts/live-deploy/LiveProxy.Common.ps1 255 The one-second creation-time tolerance can accept and terminate a replacement process after PID reuse.
scripts/live-deploy/LiveProxy.Common.ps1 377 A disposal exception skips failed-inhibit cleanup, leaving an orphaned maintenance hold despite exit 6.
scripts/live-deploy/Deploy-LiveProxy.ps1 284 The new task-drift guard lacks the required negative regression after successful preflight.
scripts/live-deploy/LiveProxy.Common.ps1 400 The new hold-ownership guard lacks a negative regression that replaces an already-owned inhibit.
tests/live-deploy-scripts.test.ts 924 Backup existence does not guarantee overlapping deployments, making the lock-refusal test timing-dependent.

The retained inhibit defect occurs when flushing buffered owner text fails and Dispose() retries that flush and throws before removal. Put disposal in a nested try/finally so failed-marker cleanup is attempted even on disposal failure. The existing active comment at Deploy-LiveProxy.ps1:286 covers this defect.

Files Reviewed (7 files)
  • reference/cindy-project.md - 0 issues
  • scripts/live-deploy/Deploy-LiveProxy.ps1 - 1 issue
  • scripts/live-deploy/LiveProxy.Common.ps1 - 4 issues
  • scripts/live-deploy/Rollback-LiveProxy.ps1 - 0 issues
  • tests/fixtures/live-deploy/Start-BillionContextProxy.ps1 - 0 issues
  • tests/fixtures/live-deploy/TestTaskDriver.ps1 - 0 issues
  • tests/live-deploy-scripts.test.ts - 1 issue

Static review only: no code or tests executed and no files modified. The Chinese counterpart exists and was excluded under the translation skip rule. Owner approval for the declared disabled-task acceptance change remains unestablished in the available discussion.

Previous review (commit b04db28)

(ai: kilo/openai/gpt-6-astra)

Code Review Summary

Status: 15 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 14
SUGGESTION 0

Reviewed deployment/rollback safety, sandbox tests and executable stand-ins, CI registration, and English documentation at b04db286b81267308af4b9fb86856504694a743a. Default-depth review with six shards; Light pass not used. All 15 inline findings were published and verified on the unchanged head.

Issue Details (click to expand)

CRITICAL

File Line Issue
scripts/live-deploy/LiveProxy.Common.ps1 500 Rollback silently overwrites launcher edits made after the initial identity check.

WARNING

File Line Issue
scripts/live-deploy/Deploy-LiveProxy.ps1 313 No operation lock protects receipt finalization from overlapping deployments.
scripts/live-deploy/Rollback-LiveProxy.ps1 138 Interrupted standalone rollback can leave a disabled task and refuse its own retry.
scripts/live-deploy/LiveProxy.Common.ps1 232 Command-line token matching can select unrelated processes for termination.
scripts/live-deploy/LiveProxy.Common.ps1 242 PID reuse between identity verification and termination can kill a replacement process.
scripts/live-deploy/Deploy-LiveProxy.ps1 169 Task validation accepts launcher-path substrings rather than the actual executable action.
scripts/live-deploy/Deploy-LiveProxy.ps1 280 An unchecked task refresh discards the validated baseline before cutover.
scripts/live-deploy/LiveProxy.Common.ps1 351 Hold removal deletes a marker replaced by another maintenance operation.
scripts/live-deploy/Deploy-LiveProxy.ps1 282 Failed marker initialization leaves supervision inhibited despite the exit-6 result.
scripts/live-deploy/LiveProxy.Common.ps1 505 Missing live receipts block restoration from intact backups after stopping the candidate.
scripts/live-deploy/Rollback-LiveProxy.ps1 144 Record-write failures report exit 4 without the required hold or failure evidence.
scripts/live-deploy/Deploy-LiveProxy.ps1 1 PowerShell 7.0/7.1 are accepted although receipt generation requires the newer JsonNode API.
tests/live-deploy-scripts.test.ts 599 Supervision identity checks lack an independent negative case with healthy proxy health.
tests/live-deploy-scripts.test.ts 356 Refusal assertions do not detect task cycling or service restarts.
tests/live-deploy-scripts.test.ts 580 Independent random stems prevent the claimed prefix-sibling isolation test.
Files Reviewed (11 files)
  • reference/cindy-project.md - 0 issues
  • reference/testing.md - 0 issues
  • scripts/ci-shard-weights.json - 0 issues
  • scripts/live-deploy/Deploy-LiveProxy.ps1 - 5 issues
  • scripts/live-deploy/LiveProxy.Common.ps1 - 5 issues
  • scripts/live-deploy/Rollback-LiveProxy.ps1 - 2 issues
  • scripts/live-files.mjs - 0 issues
  • tests/fixtures/live-deploy/Start-BillionContextProxy.ps1 - 0 issues
  • tests/fixtures/live-deploy/TestTaskDriver.ps1 - 0 issues
  • tests/fixtures/live-deploy/stand-in-proxy.mjs - 0 issues
  • tests/live-deploy-scripts.test.ts - 3 issues

Static review only: no code or tests executed and no files modified. The Chinese workflow counterpart exists and was excluded under the translation skip rule. Owner approval for the PR's declared disabled-task acceptance change was not established from the available discussion.


Reviewed by gpt-6-astra · Input: 36 · Output: 4.3K · Cached: 828K

Review guidance: REVIEW.md from base branch master

…#80)

Scripts
- Rollback never overwrites a launcher that is neither the saved nor the
  deployed one: it stops with the hold in place (foreign-launcher-edit).
- One deploy or rollback per runtime root: an exclusive operation lock is held
  from before the checks until the process ends.
- The standalone rollback journals stage rolling-back before it changes
  anything, so an interrupted run can be retried.
- Processes are matched by how they were started (node entry point, PowerShell
  -File script), not by a path appearing anywhere in the command line.
- A process is stopped through one handle whose start time was verified.
- The task action must be powershell.exe with this launcher as -File; the task
  is compared with the validated one before the hold instead of re-read.
- Lifting the hold removes only this run's inhibit; a half-written inhibit is
  removed again; a missing live receipt is restored from the backup.
- A record that cannot be updated after a successful rollback no longer reads
  as exit 4; an unexpected error after rollback re-applies the hold first.
- Minimum PowerShell is 7.2 (JsonNode).

Tests: foreign edit during rollback, healthy candidate with supervision that
does not match, second run refused, interrupted standalone rollback retried,
task action look-alikes, refusals now assert no task operation and unchanged
processes, and the prefix-sibling sandbox really shares a name prefix.

Assisted-by: Cindy (https://cindy.app)
@anuzzolilli-oss

Copy link
Copy Markdown
Owner Author

(ai: anthropic/claude-fable-5-2)

Reply to the automated review on b04db286b. Fixes are in 209793c6a; the sandbox test file now has 23 tests and passes locally with both LF and CRLF checkouts.

# Finding Outcome
1 Rollback overwrites a launcher edited after the initial check (critical) Fixed. Before restoring, the live launcher must be the saved or the deployed one; anything else stops with the hold in place, reason foreign-launcher-edit, launcher left as found. New test: edit injected after the rollback has started.
2 No operation lock across deploy and rollback Fixed. Exclusive live-deploy.lock held from before the checks until the process ends; a second run is refused with exit 2. -PreflightOnly takes no lock and creates no file. New test.
3 Interrupted standalone rollback refuses its own retry Fixed. The rollback journals stage rolling-back before it changes anything, and a disabled task is accepted for that stage. New test: rollback killed in its lift, then retried.
4 Command-line token matching can select unrelated processes Fixed for the cases described. A proxy must have the bundle as node's entry point followed by start; a supervisor must have the launcher as PowerShell's -File script. A process that embeds that exact text inside another argument would still match; that is not closed.
5 PID reuse between verification and termination Fixed. One process handle is opened, its start time compared with the matched process, and the same handle used to stop it.
6 Task check accepts launcher-path substrings Fixed in both scripts. The action must be powershell.exe with -File "<launcher>" including the closing quote. New refusals for a look-alike path and for another executable.
7 Unchecked task refresh replaces the validated baseline Fixed. The task is compared with the validated one before the hold; a change stops the run before anything is touched.
8 Hold removal deletes a marker replaced by someone else Fixed at the lift: only this run's inhibit is removed, otherwise the run fails and the foreign marker stays. Ownership is not re-read between hold and cutover.
9 Failed marker initialization leaves supervision inhibited Fixed. A marker this run created but could not finish writing is removed again.
10 Missing live receipt blocks restoration Fixed. A missing receipt is restored from the backup. Covered in the retry test.
11 Record-write failure reports exit 4 without the hold Fixed. After a successful rollback a record that cannot be updated is a note, not a failure. An unexpected error after rollback goes through the hold-and-evidence routine before exit 4.
12 PowerShell 7.0/7.1 accepted Fixed. #requires -Version 7.2; docs updated in both languages.
13 No negative test for the supervision identity checks Fixed. New test: the candidate answers health correctly while the supervisor reports healthMatch=false, then a wrong childPid; both are rolled back for that reason.
14 Refusal assertions do not detect task cycling or restarts Fixed. Every refusal now asserts zero disable/enable/start calls and the same supervisor and proxy processes.
15 Prefix-sibling test used unrelated roots Fixed. Both sandboxes share one random stem and the test asserts the prefix relationship.

The reviewer's closing note is correct: the change to acceptance criterion 13 (a disabled task accepted when the deployment's own hold or stage explains it) still needs the owner's decision.

Where-Object { $null -ne $_.CommandLine -and $_.CommandLine.IndexOf($Needle, [System.StringComparison]::OrdinalIgnoreCase) -ge 0 })
}
# The supervisor is Windows PowerShell running the launcher as its -File script.
function Get-LpSupervisors($Ctx) { return @(Get-LpProcesses 'powershell.exe' ('-File "' + $Ctx.LauncherPath + '"')) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Command-line substrings still select unrelated scripts

powershell.exe -File "C:\tools\Inspect.ps1" -File "<launcher>" executes Inspect.ps1, with the second -File passed to that script, but this matcher identifies it as the supervisor. Likewise, node.exe "C:\tools\inspect.mjs" "<candidate bundle>" start --port <port> passes lines 238-239: with an unquoted executable, the first quote-space-quote boundary separates the script from its data argument. Standalone rollback terminates these unrelated matches at lines 393 and 544 without requiring them to own the listener.

The same substring test in Get-LpTaskActionGap at line 315 also approves the PowerShell example as a scheduled-task action, allowing cutover to stop the working service before discovering that the task cannot restart it. Validate the actual host-level -File operand and Node entrypoint rather than later arguments, sharing that validation with the task check; add negative cases for paths passed as script data.

if ($p.HasExited) { return }
throw
}
if ([Math]::Abs(($started - $Process.CreationDate.ToUniversalTime()).TotalSeconds) -ge 1) { throw "pid $($Process.ProcessId) now belongs to a different process; not stopping it" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The one-second tolerance accepts a replacement process

If a matched process exits and its PID is reused before SafeHandle is acquired, a replacement created less than one second after the original passes this comparison and is killed at line 256. For example, creation times ending in 00.100 and 00.600 differ by only 0.5 seconds; neither enumeration nor the termination callers impose a minimum process age that excludes this state. Holding the handle fixes reuse after acquisition, but does not establish that the acquired handle belongs to the snapshot. Compare creation times at the actual CIM timestamp precision instead of accepting a full one-second window, while retaining same-handle termination.

Write-LpEvent 'BACKUP' $backupRoot
$r = Invoke-LpLauncherDryRun $editedBytes $root
if ($r.ExitCode -ne 0 -or $r.Action -ne 'conflict') { throw "with the new release in place the edited launcher decided '$($r.Action)' (exit $($r.ExitCode)); expected 'conflict' while the current release is still serving" }
if (-not (Test-LpSameTask (Get-LiveProxyTaskInfo $TaskName) $ctx.TaskBaseline)) { throw 'the scheduled task was changed after preflight' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The new task-drift gate has no negative regression

The task-action refusals in tests/live-deploy-scripts.test.ts:528-532 change the action before preflight, while the second-info-call injection at line 851 changes only the inhibit file. No scenario changes the task between the validated baseline and this comparison, so restoring the old baseline-overwrite assignment would not be caught by a task-drift assertion. AGENTS.md requires both directions of each gate. Inject an action change on the second task-info call and require error-before-hold with the task-changed diagnostic, zero disable/enable/start calls, and unchanged launcher and running process identities.


function Remove-LpHold($Ctx) {
Assert-LpNoSupervisor $Ctx 'before the hold is lifted'
if (-not (Test-LpOwnInhibit $Ctx)) { throw 'maintenance.inhibit is no longer the one this run created; it was left as found' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The new hold-ownership gate has no negative regression

All foreign-inhibit scenarios create the marker before preflight or before this deployment's New-LpInhibit; the second-info-call injection at tests/live-deploy-scripts.test.ts:851 is rejected by CreateNew, not by this new check. None replaces an already-owned marker during the hold, so removing this guard leaves the foreign-marker deletion regression undetected. To satisfy AGENTS.md's positive/negative gate rule, reuse writeForeignInhibit on the first disable call and assert ownership-loss failure, exact preservation of the foreign contents, a disabled task, and zero enable/start calls; the successful deployment supplies the owned-marker control.

Comment thread tests/live-deploy-scripts.test.ts Outdated
test("a second deploy is refused while one is running", async () => {
await withSandbox(async (sb) => {
const first = deploy(sb);
await waitFor("the first run to write its backup", () => backups(sb).length === 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Backup existence does not guarantee concurrent deployments

The backup remains after the first deploy exits, so this wait can succeed after its operation lock has already been released; the second deploy can then legitimately succeed and fail the expected refusal. This is reachable when the Node runner is delayed, including by another scenario's synchronous teardown at line 236 under this suite's concurrency: 4, while the first PowerShell process continues independently. Use a ready/release handshake in the test driver to keep the first run paused while it owns the lock, assert the second refusal, then release and await the first run in finally.

- Supervisor, proxy and task action are recognised from parsed arguments: the
  host's own -File operand and node's entry point, not a path that appears
  later as data for another script.
- Process identity is compared at millisecond precision before the same
  handle is used to stop it.
- A half-written inhibit is removed also when closing the file is what failed.
- The deploy re-checks that the inhibit is still its own before it changes
  anything; a foreign inhibit is kept and supervision is not restarted.

Tests: task changed after preflight, inhibit replaced during the hold, a
launcher passed as data to another script, and the lock scenario now pauses
the first run while it owns the lock (deploy and rollback are both refused).

Assisted-by: Cindy (https://cindy.app)
@anuzzolilli-oss

Copy link
Copy Markdown
Owner Author

(ai: anthropic/claude-fable-5-2)

Reply to the re-review on 209793c6a. All six are addressed in the next commit on this branch; the sandbox test file now has 25 tests and passes locally.

Finding Outcome
Command-line matching still selects unrelated scripts; same pattern in the task check Fixed. Command lines are split into arguments. A supervisor is PowerShell whose own -File operand is the launcher (nothing before it hands control to a command); a proxy is node whose entry point is the bundle, followed by start; the task action uses the same rule. New refusal: the launcher passed as data to another script. The splitter handles blanks and double quotes only; a command line that needs more than that does not match.
One-second creation-time tolerance Fixed. The comparison is at millisecond precision; termination still uses the same verified handle.
Disposal exception skips failed-inhibit cleanup Fixed. Cleanup runs in an outer finally.
No negative regression for the task-drift guard Added. The task action changes on the second task read; the run ends with error-before-hold, zero disable/enable/start calls, unchanged launcher and processes.
No negative regression for the hold-ownership guard Added, and the guard moved earlier. The deploy re-checks ownership before it edits anything; when the inhibit was replaced, the foreign file is kept byte for byte, supervision is not restarted, the launcher is not edited and the running proxy is not stopped. The run ends with exit 4.
Lock test was timing-dependent Fixed. The first run is paused by the test driver while it owns the lock; a second deploy and a rollback are both refused; the first run is then released and completes.

for ($i = 0; $i -lt $HostArgs.Count; $i++) {
$a = $HostArgs[$i]
if ($a -match '^-(c|command|e|ec|encodedcommand)$') { return $false }
if ($a -ieq '-File') { return ($i + 1 -lt $HostArgs.Count -and $HostArgs[$i + 1] -ieq $LauncherPath) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: Abbreviated host options still select unrelated scripts

Windows PowerShell accepts -f as -File, so powershell.exe -NoProfile -f "C:\tools\Watch.ps1" -File "C:\runtime\Start-BillionContextProxy.ps1" runs Watch.ps1 with the launcher path as script data. This loop ignores -f and accepts the later -File; standalone rollback then kills that unrelated watcher through Get-LpSupervisors and Set-LpRollbackHold at line 420. The shared task-action check at line 338 also incorrectly approves this action.

Fail closed on unsupported host syntax before the launcher operand, or parse host options and execution boundaries including abbreviations. Add a negative case with an abbreviated first -File; the existing test covers only the unabbreviated form.

throw
}
# Both values come from the same kernel timestamp; they differ only by rounding below a millisecond.
if ([Math]::Abs(($started - $Process.CreationDate.ToUniversalTime()).TotalMilliseconds) -ge 1) { throw "pid $($Process.ProcessId) now belongs to a different process; not stopping it" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ai: kilo/openai/gpt-6-astra)

WARNING: The tightened creation-time gate has no negative regression

No test supplies a process snapshot whose creation time differs from the process currently owning its PID, so reverting this comparison to the unsafe one-second window would still pass the suite. Successful deploy/rollback scenarios exercise only the matching-identity direction; AGENTS.md and reference/development-contract.md:131-133 require both directions of safety gates.

Add a deterministic case using a disposable process and a snapshot with its PID but a creation time 500 ms earlier. Assert the identity-mismatch diagnostic and that the process remains alive, then use its genuine snapshot as the positive control. This proves the changed threshold without depending on actual PID reuse.

- The supervisor and task-action check accepts only the host options this
  installation uses, spelled in full, before -File; abbreviated or unknown
  options do not match.
- Tests: host-argument cases (including -f and the launcher passed as data),
  a stale process snapshot is refused and the process stays alive, and an
  inhibit replaced during the rollback is kept with no further lift.

Assisted-by: Cindy (https://cindy.app)
@anuzzolilli-oss

Copy link
Copy Markdown
Owner Author

(ai: anthropic/claude-fable-5-2)

Reply to the re-review on 3fb4a72e6. All three are addressed in the next commit; the test file now has 28 tests and passes locally.

Finding Outcome
Abbreviated -f skipped by the matcher Fixed by failing closed. Before -File only -NoProfile, -NonInteractive, -NoLogo, -ExecutionPolicy <value> and -WindowStyle <value> are accepted, spelled in full; anything else does not match. New test with nine argument lists, including -f, -Command, the launcher passed as data and a look-alike path.
No negative regression for the creation-time gate Added. A disposable process and a snapshot with its PID but a creation time 500 ms earlier: the stop is refused and the process stays alive; its genuine snapshot then stops it.
No independent negative regression for the final hold-lift guard Added. A foreign inhibit is written during the rollback's own hold: the rollback restores the launcher, refuses to lift, keeps the foreign file exactly, and makes no further enable or start call.

@anuzzolilli-oss
anuzzolilli-oss merged commit f5ef090 into master Nov 18, 2026
42 checks passed
@anuzzolilli-oss
anuzzolilli-oss deleted the 2026-11-18_live-deploy-scripts branch November 18, 2026 17:20
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.

Tooling: maintained live-proxy deploy and rollback scripts that follow the documented procedure

1 participant