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
47 changes: 45 additions & 2 deletions .github/workflows/scient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,49 @@ jobs:
path: release/
if-no-files-found: error

# What a shipped Scient Desktop needs from this build, checked against the
# latest published release: live RPC v2 negotiation, and the threads that release
# wrote resumed and continued. Version numbers carry no compatibility rule;
# this job is the rule, and a release waits for it.
compatibility:
name: Check compatibility with the latest release
needs: [build, natives-linux]
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v7

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.4

- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts

- uses: actions/download-artifact@v8
with:
name: natives-linux-x64
path: packages/natives/native

- uses: actions/download-artifact@v8
with:
name: scient-agent-linux-x64
path: candidate

- name: Download the latest published release
env:
GH_TOKEN: ${{ github.token }}
run: gh release download --repo "$GITHUB_REPOSITORY" --pattern scient-agent-linux-x64 --dir previous

- name: Check
run: |
candidate="$PWD/candidate/scient-agent-linux-x64"
previous="$PWD/previous/scient-agent-linux-x64"
chmod +x "$candidate" "$previous"
# Scient Desktop drives a release that names itself and offers RPC v2.
"$candidate" --runtime-info | bun -e 'const info = JSON.parse(await Bun.stdin.text()); if (info.product !== "scient-agent" || !info.rpcProtocolVersions.includes(2)) { console.error(info); process.exit(1); }'
bun scripts/scient/capability-check.ts "$candidate" "$previous"

# Oh My Pi's own tests, run as its CI runs them, on Scient's tree: a change
# Scient makes must not break what upstream's tests hold.
natives-linux:
Expand Down Expand Up @@ -598,7 +641,7 @@ jobs:
name: Draft release
# Job conditions cannot read workflow env, so this repeats RELEASE.
if: github.event_name == 'workflow_dispatch' && inputs.release
needs: [release-version, build, verify-macos, compress, divergence, upstream-tests]
needs: [release-version, build, verify-macos, compress, divergence, upstream-tests, compatibility]
runs-on: ubuntu-24.04
permissions:
contents: write
Expand Down Expand Up @@ -698,7 +741,7 @@ jobs:
passed:
name: CI passed
if: always()
needs: [release-version, build, natives-linux, upstream-tests, divergence, sign-macos, verify-macos, compress]
needs: [release-version, build, natives-linux, upstream-tests, divergence, sign-macos, verify-macos, compress, compatibility]
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
Expand Down
4 changes: 2 additions & 2 deletions SCIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ Decisions:
| Daemon and Desktop's process reaping | Desktop stops what an agent's process tree left running when a thread stops. On macOS the daemon was seen with PID 1 as its parent and a session of its own while the agent that started it still ran, so it is not in that tree; the brokers it replaces were started the same way. |
| Not adopted | `SCIENT_AGENT_DAEMON_DIR` and `SCIENT_AGENT_DAEMON_TCP` can still point outside a host's root: Desktop drops every inherited `SCIENT_AGENT_*` variable and sets only the root and its own switches (`SCIENT_AGENT_HOST_PAGES`, `SCIENT_AGENT_ENABLE_SOURCES`), and a `.env` outside the root cannot set them, as for the broker overrides before. `mcp.evalNamespaces` (off by default) would move Scient's service catalog into eval namespaces; Desktop does not turn it on. The WebKit engine stays in `~/.o2/lib/abkit`, which upstream shares with Tern on purpose. |

**RPC changes for Desktop.** Protocol versions stay 1 and 2. `cache_warming_start` and `cache_warming_end` carry `method` (`prewarm` or `replay`). `handoff` now runs as background compaction and answers with empty data, without the `savedPath` it returned before; Desktop does not send it. **Desktop compatibility needs a Desktop change**: every shipped Desktop refused this build, because its Scient Agent target required the stock Oh My Pi provider's major, 18. [Scient Desktop #1034](https://github.com/ScientFactory/scient-desktop/pull/1034) gives Scient Agent its own upstream range (18.2.8 or newer on 18 or 19) and accepts product majors 0 and 1. This build is released as **1.0.0**: older Desktops stop below 1.0.0, so they keep 0.1.13 instead of installing a release they would refuse. The release check now enforces it (see Release).
**RPC changes for Desktop.** Protocol versions stay 1 and 2. `cache_warming_start` and `cache_warming_end` carry `method` (`prewarm` or `replay`). `handoff` now runs as background compaction and answers with empty data, without the `savedPath` it returned before; Desktop does not send it. **Desktop compatibility needs a Desktop change**: every shipped Desktop refused this build, because its Scient Agent target required the stock Oh My Pi provider's major, 18. [Scient Desktop #1034](https://github.com/ScientFactory/scient-desktop/pull/1034) gives Scient Agent its own upstream range (18.2.8 or newer on 18 or 19) and accepts product majors 0 and 1. This build is released as **1.0.0**: older Desktops stop below 1.0.0, so they keep 0.1.13 instead of installing a release they would refuse. The release check now enforces it (see Release). *Superseded on 2026-11-24:* Scient Desktop now accepts any Scient Agent release that offers RPC v2 and passes its test run, with no Oh My Pi major and no version ceiling, and the release check no longer maps Oh My Pi majors to product majors; the `compatibility` job checks what Desktop needs instead (see Release).

**Known failures.** A probe (branch `probe/pristine-1901`, [run 44643479068](https://github.com/ScientFactory/scient-agent/actions/runs/44643479068)) ran each bucket on untouched 19.0.1 and on the replay `7ca5ec2110`, on Scient's runner type, concurrency and per-test ceiling: `coding-agent-native` 8 times each, the other five twice each. Its logs were read test by test with `upstream-tests.ts`'s own judge.

Expand Down Expand Up @@ -1165,7 +1165,7 @@ The macOS builds are signed by upstream's `scripts/ci-macos-sign.sh`, unchanged,

A release follows Scient Desktop's order: the version is the run's input, it is checked first, and the tag comes last. No pull request bumps a version.

1. Run the workflow manually on `main` with `release` set: `gh workflow run scient.yml --repo ScientFactory/scient-agent --ref main -f release=true`. Leave `version` blank to release the next patch after the latest published release, when that patch stays in the product major below, or give the next minor or major (`-f version=1.1.0`). The first release on Oh My Pi 19 is `-f version=1.0.0`. A build on a new Oh My Pi major starts a new product major, released only once a Scient Desktop that accepts it is out: a Desktop installs nothing past its own ceiling, the next product major, so older Desktops keep the release they can run. The check maps them (`PRODUCT_MAJOR_BY_UPSTREAM_MAJOR` in `scripts/scient/release-version.ts`: Oh My Pi 18 is 0.x, 19 is 1.x) and refuses any other version, a blank run's next patch included.
1. Run the workflow manually on `main` with `release` set: `gh workflow run scient.yml --repo ScientFactory/scient-agent --ref main -f release=true`. Leave `version` blank to release the next patch after the latest published release, or give the next minor or major (`-f version=0.2.0`). The version is the product's own: it follows no Oh My Pi number and carries no compatibility rule. What a shipped Scient Desktop needs is checked by the `compatibility` job, which every run and every release waits for: the build names itself `scient-agent` and negotiates RPC v2, and `capability-check.ts` resumes and continues a thread the latest published release wrote. Scient Desktop accepts any Scient Agent release that passes this (from Scient Desktop 0.6.34; 0.6.33 and earlier still check the Oh My Pi major). A release keeps everything a shipped Desktop uses, and adds features as capabilities a host may ignore (`hostCommands`, `enableSources`), so a Desktop that is not updated keeps a working agent and only lacks the new features.
2. Its first job (`scripts/scient/release-version.ts`) refuses a version that does not come right after the latest published release, or that a tag carries already, before any build starts. Each build writes the version into its own checkout's `scient.json` (`--stamp`) and checks that the binary reports it. The run signs the macOS builds with the Developer ID, notarizes them and refuses an ad-hoc signature. Only when every job passed does it check the version again and draft a GitHub release with every binary, its zstd copy (`<binary>.zst`) and the SHA-256 of each, targeting the commit it built.
3. A person publishes the draft. Publishing creates the `v<version>` tag on that commit; a draft has no tag.

Expand Down
31 changes: 28 additions & 3 deletions scripts/scient/capability-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import * as fs from "node:fs";
import * as path from "node:path";
import * as os from "node:os";
import { strict as assert } from "node:assert";
import { RpcClient } from "../../packages/coding-agent/src/modes/rpc/rpc-client";
import { ptree, readJsonl } from "@oh-my-pi/pi-utils";
import type { RpcReadyFrame, RpcResponse } from "../../packages/coding-agent/src/modes/rpc/rpc-types";
import { RpcClient, type RpcClientOptions } from "../../packages/coding-agent/src/modes/rpc/rpc-client";

const candidate = process.argv[2];
const previous = process.argv[3];
Expand Down Expand Up @@ -129,9 +131,10 @@ const env = {
NO_PROXY: "127.0.0.1,localhost,::1",
};
let active: RpcClient | undefined;
const client = (binary: string, extra: string[] = []) =>
const client = (binary: string, extra: string[] = [], spawn?: RpcClientOptions["spawn"]) =>
new RpcClient({
command: [binary],
spawn,
cwd,
env,
provider: "alignment-proof",
Expand All @@ -153,12 +156,33 @@ try {
await active.stop();
fs.cpSync(state, path.join(root, "pre-upgrade-state"), { recursive: true });
phase = "upgrade";
active = client(candidate, ["--session", oldState.sessionFile]);
// RpcClient keeps the negotiated version private. Keep a copy of this short session's wire exchange.
let handshake!: ReadableStream<Uint8Array>;
active = client(candidate, ["--session", oldState.sessionFile], args => {
const child = ptree.spawn([candidate, ...args], { cwd, env: { ...Bun.env, ...env }, stdin: "pipe" });
const [stdout, copy] = child.stdout.tee();
handshake = copy;
return {
stdin: child.stdin,
stdout,
exited: child.exited,
peekStderr: () => child.peekStderr(),
kill: (signal, graceMs) => child.kill(signal, graceMs),
};
});
await active.start();
assert.ok(JSON.stringify(await active.getMessages()).includes("OLD_SESSION_PROOF"));
await active.promptAndWait("Continue the restored session", undefined, 30000);
assert.ok(JSON.stringify(await active.getMessages()).includes("UPGRADED_SESSION_PROOF"));
await active.stop();
let negotiatedV2 = false;
for await (const frame of readJsonl<RpcReadyFrame | RpcResponse>(handshake)) {
if (frame.type === "ready")
assert.ok(frame.supportedProtocolVersions?.includes(2), "candidate ready frame must offer RPC v2");
if (frame.type === "response" && frame.command === "negotiate_protocol" && frame.success)
negotiatedV2 = frame.data.protocolVersion === 2;
}
assert.ok(negotiatedV2, "candidate must negotiate RPC v2");
// Verify only a clean pre-upgrade snapshot rollback, never claim reverse-schema migration.
phase = "rollback";
active = new RpcClient({
Expand Down Expand Up @@ -196,6 +220,7 @@ try {
console.log(
JSON.stringify({
passed: [
"candidate-rpc-v2-negotiation",
"old-session-resume-and-continue",
"pre-upgrade-snapshot-rollback",
"native-skill-text",
Expand Down
10 changes: 1 addition & 9 deletions scripts/scient/release-version.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { nextVersions, releaseRefusal, releaseVersion, stampedManifest, upstreamRefusal } from "./release-version";
import { nextVersions, releaseRefusal, releaseVersion, stampedManifest } from "./release-version";

describe("release version", () => {
it("follows the latest published release by one patch, minor or major step", () => {
Expand Down Expand Up @@ -48,12 +48,4 @@ describe("release version", () => {
expect(JSON.parse(stamped)).toEqual({ ...JSON.parse(manifest), version: "0.1.9" });
expect(stamped).toBe(manifest.replace('"version": "0.1.8"', '"version": "0.1.9"'));
});

it("releases each Oh My Pi major as its own Scient Agent major", () => {
expect(upstreamRefusal("0.1.14", "18.22.0")).toBeUndefined();
expect(upstreamRefusal("1.0.0", "19.0.1")).toBeUndefined();
// A blank run's next patch on a new Oh My Pi major: every older Desktop would install it.
expect(upstreamRefusal("0.1.14", "19.0.1")).toContain("1.0.0");
expect(upstreamRefusal("2.0.0", "20.0.0")).toContain("no Scient Agent major yet");
});
});
26 changes: 1 addition & 25 deletions scripts/scient/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,6 @@ export function releaseRefusal(version: string, state: ReleaseState): string | u
return `The latest published release is v${latest}, so the next release is ${next.join(", ")} (patch, minor or major), not ${version}.`;
}

/**
* The Scient Agent major each Oh My Pi major ships as. Scient Desktop accepts a product major only once
* it is qualified against that Oh My Pi major, and a Desktop from before then installs nothing past its
* own ceiling, the next product major: a build on a new Oh My Pi major released in the old product
* major would be installed by every such Desktop and then refused. An alignment to a new Oh My Pi
* major adds its row once Scient Desktop accepts it.
*/
export const PRODUCT_MAJOR_BY_UPSTREAM_MAJOR: Readonly<Record<number, number>> = { 18: 0, 19: 1 };

/** Why `version` may not be released for a build on Oh My Pi `upstream`, or undefined when it may. */
export function upstreamRefusal(version: string, upstream: string): string | undefined {
const upstreamMajor = Number(upstream.split(".")[0]);
const productMajor = PRODUCT_MAJOR_BY_UPSTREAM_MAJOR[upstreamMajor];
if (productMajor === undefined) {
return `This build is on Oh My Pi ${upstream}, whose major has no Scient Agent major yet; add it to PRODUCT_MAJOR_BY_UPSTREAM_MAJOR once Scient Desktop accepts it.`;
}
if (Number(version.split(".")[0]) === productMajor) return undefined;
return `This build is on Oh My Pi ${upstream}, which Scient Agent releases as ${productMajor}.x, not ${version}; give the run the first ${productMajor}.x version after the latest published release (${productMajor}.0.0 when that starts the major).`;
}

/** `scient.json`'s text with `version` as the product version, its layout unchanged. */
export function stampedManifest(manifest: string, version: string): string {
const scient = JSON.parse(manifest) as { version: string };
Expand Down Expand Up @@ -127,11 +107,7 @@ async function check(): Promise<void> {
return;
}
const tagExists = (await ghOrNotFound(["api", `repos/${repo}/git/ref/tags/v${version}`, "--jq", ".ref"])) !== null;
const scient = (await Bun.file(path.resolve(import.meta.dir, "..", "..", "scient.json")).json()) as {
upstream: { version: string };
};
const refusal =
releaseRefusal(version, { latestPublished, tagExists }) ?? upstreamRefusal(version, scient.upstream.version);
const refusal = releaseRefusal(version, { latestPublished, tagExists });
if (refusal) {
console.log(`::error::${refusal}`);
process.exitCode = 1;
Expand Down
Loading