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
604 changes: 604 additions & 0 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/architecture/hosting-and-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,14 @@ or packaged-startup claim.

## Installation and release boundaries

Publication consumes the candidate's seven original packages and release-assets artifact without
rebuilding, repacking, re-archiving or renaming. A candidate's workflow tree must equal master's at
publication.

NuGet.org repository signing changes the package envelope. Real-channel identity is therefore
established through the running native payload's complete paths and SHA-256 values, not downloaded
package-envelope equality.

The product target includes PowerShell and shell installers, WinGet, Homebrew, suitable deb and rpm
packages, a Windows MSI, and a macOS pkg. Archive-only delivery does not close that target. Each
surface is a separate delivery increment after native and package proof, never a placeholder.
Expand Down
28 changes: 28 additions & 0 deletions docs/engineering/quality-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,34 @@ order. The pull request's hosted `Native` run proves assembly and upload, not pu
behaviour or a live-channel download. Dispatch retention is confirmed on an authorized manual
candidate run.

### Publication pass

Publication is separate from managed, native and local-package acceptance. A publication candidate
is one successful manual Native run on master, identified by its full commit SHA and run ID.
Publication consumes that run's validated package feed and release-assets artifact unchanged.

The manual release workflow checks candidate provenance, evaluated version, workflow-tree equality,
target absence and artifact integrity before publication. A dry run performs those checks without
publication privileges or an environment deployment. Its release-identity check proves absence of
published releases and the tag, not drafts; the `github-release` job checks drafts with
`contents: write` before creating anything.

Publishing requires the `release` environment and the maintainer's separate authorization. The
environment binds NuGet.org publication through its Trusted Publishing policy. For GitHub Packages
and GitHub Releases, the gate is procedural: a branch copy of a workflow can request `packages: write`
or `contents: write` with `GITHUB_TOKEN`. The lane therefore dispatches no workflow but master's
`release.yml` for publication.

Real-channel acceptance requires every manifest RID's verification leg to succeed against the selected
published channel. Feed acceptance uses cold global-tool and DNX acquisition and complete
running-payload path/SHA-256 equality with candidate evidence. NuGet.org's repository-signed package
envelope is not compared with the original package digest. Release acceptance checks downloaded archive
hashes against both the published checksum file and independent candidate receipts before execution.

Secret-bearing channel jobs retain the existing test guards but upload only selected
credential-redacted TRX and process snapshots. Credential files, acquisition stores and memory dumps
are not uploaded. Existing credential-free CI artifact policy is unchanged.

### Linux builder verification

The builder recipe and publication contract are owned by
Expand Down
39 changes: 38 additions & 1 deletion docs/engineering/workflow.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Repository Workflow

Date: 2026-11-05
Date: 2026-11-14

Canonical working agreements for research, implementation, temporary work, verification, and Git
history.
Expand Down Expand Up @@ -73,6 +73,43 @@ alone, and the pull request passes the full gate:
A NuGetAudit advisory fails restore; its remedy is a prompt pin bump through this procedure, never a
suppression or an audit override (`quality-gates.md`).

## Publication procedure

Settings and public identities require the maintainer's approval before the release lane is enabled.
Every feed publication and GitHub Release requires his own word with the exact target, candidate
commit, Native run ID, version, filenames and digests. Approval of a candidate or dry run authorizes
no publication.

Precondition: no `OpenCodeDotNet.Mcp` or `OpenCodeDotNet.Mcp.*` package exists on GitHub Packages
except those `release.yml` published, because the absence check sees only packages this
repository's Actions can access.

Promote GitHub Packages first, make all seven packages public with the maintainer's explicit
irreversible-visibility approval, and verify that channel. Ask separately for NuGet.org publication
with the successful GitHub Packages verification run ID. Ask separately for the GitHub Release with
its tag, asset digests, release-notes text and successful NuGet verification run ID.

The lane dispatches no workflow but master's `release.yml` for publication after the word; the
maintainer approves the waiting `release` job in GitHub. The `release` environment binds NuGet.org
through its Trusted Publishing policy. Its GitHub Packages and GitHub Releases gate is procedural:
a branch copy of a workflow can request `packages: write` or `contents: write` with `GITHUB_TOKEN`.
The lane never approves deployments, publishes releases or changes package visibility with its own
credentials.

A dry run proves published-release and tag absence, not draft absence. The `github-release` job
checks drafts with `contents: write` before creating anything; see the
[publication pass](quality-gates.md#publication-pass).

Hold workflow-tree changes from candidate selection until release publication. Partial publication
blocks promotion. Record push responses and the verified present/missing sets; ask for exactly the
missing-file recovery or abandonment. Never retry a push automatically or reuse rebuilt bytes under
a published version. Expired candidate artifacts require abandonment and a new version. The `files`
input recovers feed pushes only; a partial draft release is left for the maintainer's decision, not
automatically resumed or cleaned up.
The release job creates the tag at the candidate commit before creating the draft. A failure after
tag creation leaves the tag (and possibly a draft) for the maintainer's decision; the next attempt
for that version refuses until he decides. No tag is automatically deleted.

## Documentation sessions

Research and decision sessions end with a documentation pass. Current canon or ADR updates when a
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Globalization;
using OpenCode.Mcp.Tools.Native;
using OpenCode.Mcp.Tools.Tests.Native.Support;

namespace OpenCode.Mcp.Tools.Tests.Native;

public sealed partial class NativeApplicationTests
{
[Test]
[Arguments(false)]
[Arguments(true)]
public async Task RunAsync_Should_Validate_Publication_Without_Changing_The_Candidate(bool refused, CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
if (refused)
{
scenario.Files.File.Delete(scenario.Asset("win-x64.zip"));
}
var before = await scenario.CaptureAsync(token);
var directories = scenario.Files.Directory.GetDirectories(scenario.Candidate.Build.Root, "*", SearchOption.AllDirectories).Order(StringComparer.Ordinal).ToArray();
using var output = new StringWriter(CultureInfo.InvariantCulture);
using var errors = new StringWriter(CultureInfo.InvariantCulture);
var host = scenario.Candidate.Build.Host with { Os = "unsupported", OsArchitecture = "unsupported", ProcessArchitecture = "unsupported" };
var application = new NativeApplication(scenario.Files, scenario.Candidate.Runner, new FixtureHostReader(host), scenario.Candidate.Builder.Native.Modes, output, errors);
var root = host.WorkingDirectory;
var result = await application.RunAsync(["publication", "--receipts", scenario.Files.Path.GetRelativePath(root, scenario.Request.Receipts),
"--feed", scenario.Files.Path.GetRelativePath(root, scenario.Feed), "--assets", scenario.Files.Path.GetRelativePath(root, scenario.Request.Assets),
"--version", scenario.Request.Version, "--commit", scenario.Commit], token);
await Assert.That(result).IsEqualTo(refused ? 2 : 0);
await Assert.That(output.ToString().Replace("\r\n", "\n", StringComparison.Ordinal)).IsEqualTo(refused ? "" : "Publication candidate is complete.\n");
await Assert.That(errors.ToString().Replace("\r\n", "\n", StringComparison.Ordinal))
.IsEqualTo(refused ? "Missing release asset: opencode-mcp-" + scenario.Request.Version + "-win-x64.zip\n" : "");
await scenario.AssertUnchangedAsync(before, token);
await Assert.That(scenario.Files.Directory.GetDirectories(scenario.Candidate.Build.Root, "*", SearchOption.AllDirectories).Order(StringComparer.Ordinal))
.IsEquivalentTo(directories, TUnit.Assertions.Enums.CollectionOrdering.Matching);
await Assert.That(scenario.Candidate.Runner.Calls).IsEmpty();
}
}
28 changes: 27 additions & 1 deletion tests/OpenCode.Mcp.Tools.Tests/Native/NativeArgumentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ namespace OpenCode.Mcp.Tools.Tests.Native;

public sealed class NativeArgumentsTests
{
[Test]
public async Task Parse_Should_Select_Publication_And_Require_All_Inputs()
{
string[] arguments = ["publication", "--receipts", "completed tree", "--feed", "candidate feed", "--assets", "release assets", "--version", "exact version", "--commit", "full commit"];
var command = NativeArguments.Parse(arguments);
await Assert.That(command).IsEqualTo(new NativeCommand("publication", null, null, null, null, "completed tree",
Feed: "candidate feed", Version: "exact version", Assets: "release assets", Commit: "full commit"));
for (var index = 1; index < arguments.Length; index += 2)
{
var name = arguments[index];
await Assert.That(() => NativeArguments.Parse(arguments[..index]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: missing " + name + ".", StringComparison.Ordinal);
await Assert.That(() => NativeArguments.Parse(["publication", name, "one", name, "two"]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: duplicate " + name + ".", StringComparison.Ordinal);
await Assert.That(() => NativeArguments.Parse(["publication", name]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: missing value for " + name + ".", StringComparison.Ordinal);
await Assert.That(() => NativeArguments.Parse(["publication", name, "--feed", "value"]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: missing value for " + name + ".", StringComparison.Ordinal);
}
foreach (var name in new[] { "--rid", "--manifest", "--output", "--unknown" })
{
await Assert.That(() => NativeArguments.Parse(["publication", name, "value"]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: unknown option " + name + " for publication.", StringComparison.Ordinal);
}
}

[Test]
public async Task Parse_Should_Select_Assets_And_Require_All_Four_Inputs()
{
Expand Down Expand Up @@ -60,7 +86,7 @@ await Assert.That(() => NativeArguments.Parse(["pack-child"]))
await Assert.That(() => NativeArguments.Parse(["pack-child", "--rid", "win-x64"]))
.ThrowsExactly<InvalidOperationException>().WithMessage("Arguments: missing --evidence.", StringComparison.Ordinal);
await Assert.That(() => NativeArguments.Parse([])).ThrowsExactly<InvalidOperationException>()
.WithMessage("Arguments: use verify, stage, inspect, validate, matrix, control, prove-linux, pack-child, pack-root, assets or snapshot.", StringComparison.Ordinal);
.WithMessage("Arguments: use verify, stage, inspect, validate, matrix, control, prove-linux, pack-child, pack-root, assets, publication or snapshot.", StringComparison.Ordinal);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using OpenCode.Mcp.Tools.Native;
using OpenCode.Mcp.Tools.Tests.Native.Support;
using TUnit.Assertions.Enums;

namespace OpenCode.Mcp.Tools.Tests.Native;

public sealed class NativePublicationValidatorTests
{
private static readonly string[] Rids = ["win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64"];

[Test]
public async Task ValidateAsync_Should_Bind_Every_Receipt_To_The_Candidate(CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
foreach (var child in scenario.Candidate.Builder.Children)
{
await scenario.Candidate.WriteReceiptAsync(child.Receipt with { SourceStatus = " M development" }, token);
}
var request = scenario.Request with { Version = "different-version", Commit = "different-commit" };
var result = await new NativePublicationValidator(scenario.Files, scenario.Candidate.Builder.Native.Modes).ValidateAsync(request, token);
await Assert.That(result).IsEquivalentTo(Rids
.SelectMany(static rid => new[] { rid + ": Receipt version must be different-version.", rid + ": Receipt source commit must be different-commit.",
rid + ": Candidate receipt source status must be empty." }), CollectionOrdering.Matching);
}

[Test]
[Arguments("native")]
[Arguments("feed")]
public async Task ValidateAsync_Should_Preserve_The_Complete_Native_And_Feed_Refusals(string stage, CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
string[] expected;
if (stage == "native")
{
scenario.Files.File.Delete(scenario.Files.Path.Combine(scenario.Candidate.Directory("win-arm64"), "payload-manifest.json"));
scenario.Files.File.Delete(scenario.Candidate.Archive("win-arm64"));
scenario.Files.File.Delete(scenario.Files.Path.Combine(scenario.Candidate.Directory("osx-x64"), "payload", "LICENSE"));
expected = ["osx-x64: Missing payload file: LICENSE", "win-arm64: Missing payload manifest.", "win-arm64: Missing archive."];
}
else
{
scenario.Files.File.Delete(scenario.Files.Path.Combine(scenario.Feed, scenario.Candidate.Builder.PackageFileName));
await scenario.Files.File.WriteAllTextAsync(scenario.Files.Path.Combine(scenario.Feed, "z-extra"), "extra", token);
await scenario.Files.File.WriteAllTextAsync(scenario.Files.Path.Combine(scenario.Feed, "a-extra"), "extra", token);
scenario.Files.Directory.CreateDirectory(scenario.Files.Path.Combine(scenario.Feed, "extra-directory"));
expected = ["Missing feed file: " + scenario.Candidate.Builder.PackageFileName, "Unexpected feed file: a-extra", "Unexpected feed file: z-extra", "Unexpected feed directory: extra-directory"];
}
scenario.Files.File.Delete(scenario.Checksums);
await AssertRefusalAsync(scenario, expected, token);
}

[Test]
[Arguments("receipt.json")]
[Arguments("payload-manifest.json")]
public async Task ValidateAsync_Should_Require_Byte_Identical_Feed_Evidence(string name, CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
foreach (var rid in new[] { "osx-arm64", "win-x64" })
{
var path = scenario.FeedEvidence(rid, name);
await scenario.Files.File.WriteAllTextAsync(path, await scenario.Files.File.ReadAllTextAsync(path, token) + " \n", token);
}
var description = name == "receipt.json" ? "receipt" : "payload manifest";
await AssertRefusalAsync(scenario, ["win-x64: Feed " + description + " differs from completed evidence.",
"osx-arm64: Feed " + description + " differs from completed evidence."], token);
}

[Test]
public async Task ValidateAsync_Should_Complete_The_Feed_Stage_Before_Refusing(CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
scenario.Files.File.Delete(scenario.Files.Path.Combine(scenario.Feed, scenario.Candidate.Builder.PackageFileName));
scenario.Files.File.Delete(scenario.Checksums);
var retained = scenario.FeedEvidence("win-x64", "receipt.json");
await scenario.Files.File.WriteAllTextAsync(retained, await scenario.Files.File.ReadAllTextAsync(retained, token) + " \n", token);
await AssertRefusalAsync(scenario, ["Missing feed file: " + scenario.Candidate.Builder.PackageFileName,
"win-x64: Feed receipt differs from completed evidence."], token);
}

[Test]
public async Task ValidateAsync_Should_Require_The_Exact_Release_Asset_Set(CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
scenario.Files.File.Delete(scenario.Asset("win-x64.zip"));
scenario.Files.File.Delete(scenario.Asset("linux-arm64.tar.gz"));
scenario.Files.File.Delete(scenario.Checksums);
foreach (var name in new[] { "z-extra", "a-extra" })
{
await scenario.Files.File.WriteAllTextAsync(scenario.Files.Path.Combine(scenario.Request.Assets, name), "extra", token);
}
scenario.Files.Directory.CreateDirectory(scenario.Files.Path.Combine(scenario.Request.Assets, "z-directory"));
scenario.Files.Directory.CreateDirectory(scenario.Files.Path.Combine(scenario.Request.Assets, "a-directory"));
await scenario.Files.File.WriteAllTextAsync(scenario.Files.Path.Combine(scenario.Request.Assets, "a-directory", "nested"), "extra", token);
await AssertRefusalAsync(scenario, ["Missing release asset: opencode-mcp-" + scenario.Request.Version + "-win-x64.zip",
"Missing release asset: opencode-mcp-" + scenario.Request.Version + "-linux-arm64.tar.gz", "Missing release asset: SHA256SUMS",
"Unexpected release asset: a-directory/nested", "Unexpected release asset: a-extra", "Unexpected release asset: z-extra",
"Unexpected release directory: a-directory", "Unexpected release directory: z-directory"], token);
}

[Test]
public async Task ValidateAsync_Should_Compare_Archives_With_Receipts_Not_Only_Checksums(CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
await scenario.ChangeArchiveAndChecksumsAsync(token);
await AssertRefusalAsync(scenario, ["linux-x64: Release archive digest differs from receipt.",
"SHA256SUMS differs from the receipt-ordered release checksums."], token);
}

[Test]
[Arguments("order")]
[Arguments("digest")]
[Arguments("filename")]
[Arguments("BOM")]
[Arguments("CRLF")]
[Arguments("self")]
[Arguments("extra")]
public async Task ValidateAsync_Should_Require_Receipt_Ordered_Checksum_Bytes(string fault, CancellationToken token)
{
var scenario = await NativePublicationScenario.CreateAsync(token);
await scenario.RewriteChecksumsAsync(fault, token);
await AssertRefusalAsync(scenario, ["SHA256SUMS differs from the receipt-ordered release checksums."], token);
}

private static async Task AssertRefusalAsync(NativePublicationScenario scenario, IReadOnlyList<string> expected, CancellationToken token)
{
var before = await scenario.CaptureAsync(token);
await Assert.That(await scenario.ValidateAsync(token)).IsEquivalentTo(expected, CollectionOrdering.Matching);
await scenario.AssertUnchangedAsync(before, token);
}
}
Loading
Loading