Skip to content

Tests

PiSharp’s tests are console programs, not xUnit or NUnit projects. Each suite under tests/ is an executable that runs its cases, prints a JSON report and exits with 0 when no case failed and 1 otherwise. The suites are offline: they use fake HTTP handlers, scripted models and fixtures, and need no provider keys.

Run a suite with dotnet run from the repository root. Pass the restore settings from Build from source the first time, while your NuGet cache is still empty:

Terminal window
dotnet run --project tests/PiSharp.InteractiveParity.Tests -c Release -p:RestoreSources=https://api.nuget.org/v3/index.json -p:RestoreLockedMode=false

The report goes to standard output. Most suites also take --report <path> after --, and write the same report to that file:

Terminal window
dotnet run --project tests/PiSharp.Codemode.Tests -c Release -- --report artifacts/codemode.json

The report path must not exist yet: the suites create the file and fail if it is already there. Each report lists every case with its id and status, plus counts such as cases, failures and skips. Some suites add fields of their own, such as the upstream source commit their expectations come from.

Each case has a time limit, from 10 seconds in AzureResponses to 240 seconds in ExtensionParity. A case that hangs fails at its limit instead of stopping the run.

Every case has a stable id, such as changelog.sync.generated-from-website or harness.callers.…. How you select cases depends on the suite:

Suites How to select Match
Codemode, McpParity, SessionParity, Durable, DurableCli, CustomAgents -- --only <prefix> Case ids that start with the prefix. You can pass --only or --report, not both.
InteractiveParity INTERACTIVEPARITY_FILTER environment variable Case ids that contain the text. Separate several with |.
CliParity CLIPARITY_FILTER Case ids that contain the text.
ExtensionParity EXTPARITY_FILTER Case ids that contain the text.
ProviderApis PROVIDERAPIS_FILTER Case ids that contain the text.
Rpc, Sessions, Tools, ExtensionHost, Extensions.ContractTests, Tui -- --filter <text> Case names that contain the text, ignoring case.
Transport -- --filter <prefix> Case names that start with the prefix.
CodingAgent -- --filter <text> or -- --exact-name <name> Contains, or one exact case.

The remaining suites run all their cases. All matching is ordinal, so case matters except where the table says otherwise.

Terminal window
dotnet run --project tests/PiSharp.Durable.Tests -c Release -- --only storage.sqlite
$env:INTERACTIVEPARITY_FILTER = 'changelog.'; dotnet run --project tests/PiSharp.InteractiveParity.Tests -c Release
Status Meaning
PASS_AUTHORED_NATIVE_ONLY The case passed. Its expectation was written by reading the pinned Pi source, not captured from an upstream run. Most suites report this.
PASS_UPSTREAM_CAPTURE The case passed against output that upstream Pi produced. The compat.* cases of Durable report this.
PASS, passed The case passed. CustomAgents uses PASS; the older suites use passed.
FAIL, failed The case failed. The suite exits with 1.
SKIPPED InteractiveParity: a Unix-only case on Windows.
SKIPPED_PLATFORM CliParity: a case for another platform.
SKIPPED_NO_UPSTREAM Durable: the case needs a Pi checkout that PISHARP_DURABLE_UPSTREAM doesn’t name.
SKIP_NO_NODE, SKIP_NO_NPM, SKIP_NO_GIT, SKIP_NO_PI_RUNTIME ExtensionParity: the case needs Node.js, npm, Git or the installed Pi packages, and they are missing.
SKIP, skipped CodingAgent: a native extension case, and artifacts/extensions/published-fixtures doesn’t exist.
HUNG, hung CodingAgent: the case was still running after 10 minutes. The run stops there and exits with 1.

A skip is not a failure. Check the skip counts when you expect a case to run.

The release and the macOS workflow run these. Each covers one area of Pi, with expectations written from the pinned Pi source unless the row says otherwise.

Suite Covers
PiSharp.AzureResponses.Tests The Azure OpenAI Responses provider (azure).
PiSharp.MistralConversations.Tests The Mistral Conversations streaming transport, replayed from fixtures.
PiSharp.AnthropicAuthSync.Tests Anthropic authentication from the Pi v1.1.0 sync: identity federation and token exchange, reverified at Pi v1.2.0.
PiSharp.McpSync.Tests MCP server names, tool exposure and prompts, OAuth, and pisharp mcp.
PiSharp.ProviderSync.Tests Provider wire behavior: inline tools, strict keywords, sampling parameters, retries, overflow, estimates and catalog shards.
PiSharp.WireSync.Tests The wire, extension and tool rows of the Pi v1.1.0 sync.
PiSharp.CliSync.Tests The CLI, hidden-tools prompt and TUI rows of the Pi v1.1.0 sync.
PiSharp.ToolSearch.Tests The built-in tool_search tool and deferred MCP exposure.
PiSharp.Classifiers.Tests The classifier and image generation APIs.
PiSharp.Models.Tests Model catalogs and model selection. --tarball <pi-ai package> also compares the embedded catalog shards with a published pi-ai package, byte for byte.
PiSharp.Schema.Tests JSON Schema validation of tool arguments, ported from Pi’s pi-schema: the JSON-Schema-Test-Suite for drafts 2020-12 and 7 with pi-schema’s known failures, coercion, formats and unresolved references.
PiSharp.Telemetry.Tests The telemetry port of Pi v1.5.0’s pi-telemetry (PiSharp.Telemetry) and pi-ai’s request tracing, with expectations written from the pinned upstream tests.
PiSharp.Codemode.Tests Code mode on Jint, with declaration goldens from the upstream packages. It is also the code mode worker process its cases start.
PiSharp.ProviderApis.Tests Provider APIs and authentication: Bedrock, Codex, Copilot, Cloudflare and AWS signing.
PiSharp.CliParity.Tests The CLI, configuration and resources, and session file goldens in SessionFormat/*.scenario.json, captured from Pi v1.1.0.
PiSharp.McpParity.Tests MCP configuration and completion.
PiSharp.SessionParity.Tests Events, session features, export and extension events.
PiSharp.InteractiveParity.Tests Interactive mode, slash commands, and the CHANGELOG.md sync.
PiSharp.ExtensionParity.Tests Extensions, the Node bridge and packages. It builds and loads the sample extensions and needs Node.js 22.19 or later and npm for the current 1.6.0 release. Use the committed tools/NodeBridge/runtime-fixture-160 manifest/lock with npm ci and set PISHARP_TEST_PI160_NODE_MODULES to its installed node_modules (the default is artifacts/node-runtime-160/node_modules). The runtime-fixture-150 and runtime-fixture-152 fixtures are preserved for the earlier releases. CI directly verifies that runtime’s ABI before running the suites. Ordinary sandbox startup does not install packages. The separate production installer provenance case requires PISHARP_TEST_INSTALL_PI_RUNTIME=1 and a fresh private runtime cache.
PiSharp.Durable.Tests The durable port, with cases ported from upstream’s tests. The compat.* cases read sessions upstream wrote.
PiSharp.DurableCli.Tests pisharp durable, including the device server commands.
PiSharp.CustomAgents.Tests Custom agents, from 1.2.0.2. See Custom agents.

The macOS workflow runs all of them except Durable and DurableCli, which the durable workflow runs on every OS, and CustomAgents, which the custom agents workflow runs on every OS.

Project Purpose
PiSharp.CustomAgents.Tests Case tables for custom agents (experimental).
PiSharp.CustomAgents.PluginFixture.V1, .V2 Two versions of a plugin the tests load, reload and unload. V2 answers differently and adds a tool.
PiSharp.CustomAgents.ExtensionFixture A native extension the tests load as an agent plugin.

Most of these test one library each. core.yml runs all ten as Windows console jobs, including the Tools process fixtures and TUI ConPTY cases. It builds the CLI child host for CodingAgent and publishes all ten native extension fixtures for CodingAgent and Extensions.ContractTests. Build/fixture failure, missing reports, incomplete execution and skipped core cases fail the lane. Each job uploads the raw report, prerequisite stage results and a current-checkout manifest.

This hosted source-build lane uses the exact SDK from global.json and explicitly restores from nuget.org. It is separate from tools/test-native.ps1, whose reviewed source manifest, pinned products, Node-absent launch boundary and companion admission remain required for that native qualification workflow. Hosted CI does not issue those admission receipts.

The current-source checks target Pi 1.6.0 and verify the complete frozen inventory, applicability map, acceptance record and Durable overlay. The 1.5.2 source and applicability checks run as preserved checks against target.v1.5.2.lock.json, and separate historical checks retain the v1.5.0/v1.2.0 source objects and the preserved durable-port-map.v1.5.0.json; they do not relabel old acceptance as 1.6.0 coverage. The published 1.6.0 and 1.5.2 releases each have separate exact-tag qualification and publication evidence; historical receipts retain their original scope.

Suite Covers
PiSharp.Compatibility.Tests Provider requests and wire formats against the frozen fixtures. Takes --repo, --report and --require-node-absent.
PiSharp.Agent.Tests The agent loop, tool calls, queues and cancellation.
PiSharp.Transport.Tests The HTTP and SSE transports. Also takes --require-node-absent and --strict-completions-lifecycle, which can’t be combined with --filter.
PiSharp.Sessions.Tests Session files, branches, context and compaction.
PiSharp.Tools.Tests The built-in tools. Its process and shell fixtures are Windows-only.
PiSharp.CodingAgent.Tests The coding agent runtime. Requires --dotnet-host <path> --cli <path>, the built src/PiSharp.Cli DLL. Its native extension cases load the packages that tools/publish-native-extension-fixtures.ps1 publishes to artifacts/extensions/published-fixtures. Without that folder they skip and give the reason. Once it exists, a missing package fails its cases.
PiSharp.Rpc.Tests The JSONL RPC mode.
PiSharp.Tui.Tests Terminal input, rendering and leases. Requires --dotnet-host <path>.
PiSharp.Extensions.ContractTests The extension contracts. Consumer/PublishedConsumer.csproj is a native extension built against them, as a third-party extension would be.
PiSharp.ExtensionHost.Tests The extension worker protocol.

These start real child processes and need explicit paths:

Suite Arguments
PiSharp.ExtensionHost.ProcessTests --dotnet-host, --node, --repo, optional --report
PiSharp.Compatibility.Node.ProcessTests --dotnet-host, --node, --repo, --oracle, --jiti, --reference-repo, --run-parent, --report, all required

tools/native-companion-targets.json lists 32 companion targets, each a narrow suite from the v0.99.1 port. Most read fixtures captured from Pi v0.99.1 in fixtures/reference/, and several also need a prepared receipt.

Projects Cover
CompletionsAnchored, CompletionsGrammar, CompletionsSimple, CompletionsThinking (each with Controls or Agent projects) The OpenAI Completions provider: anchored tools, grammars, simple options and thinking.
OpenRouterBinding, OpenRouterCacheProfile, OpenRouterReasoning (each with Controls) OpenRouter routing, caching and reasoning.
AnthropicSimple, GoogleGenerativeAI, PiMessages, Authentication The Anthropic, Google and Pi messages providers, and credential handling.
AzureResponses, MistralConversations The two release suites above, also listed as companions.
Tui.LockModifiers, Tui.Keypad, Tui.ModifyOtherKeys, Tui.Focus, Tui.IndicConjunct, Tui.KittyAlternate, Tui.Keybindings, Tui.SelectList Terminal key protocols, focus, text shaping, keybindings and the select list.
Terminal.SelectList.Integration, Terminal.Ownership The select dialog and terminal ownership in the full terminal.
tools/NodeCommandInputBridge/NativeAdmissionTests Node extension loadout metadata.

These projects are not in PiSharp.slnx, and no workflow runs them. They are controls and slices kept from the v0.99.1 port. Three Node package suites have their own scripts in tools/: test-native-node-package.ps1, test-native-hello-package.ps1 and test-native-command-input-package.ps1.

Projects Purpose
AnthropicProfile, AnthropicResolved, AzureSimple, VertexSimple Provider controls derived from the Pi v0.99.1 source.
AnthropicSdkBeta Native cases paired with captured Anthropic SDK beta requests.
MistralOriginalOptions Mistral option mapping.
OpenAIResponsesHooks, OpenAIResponsesOriginalParity, ResponsesGrammarFallback, ResponsesOrphan, ResponsesPublicMetadata The OpenAI Responses provider: hooks, grammar fallback, orphaned tool results and metadata.
ProviderOfflineDifferential Native observations against values derived from the v0.99.1 source.
ProviderComparison.Tests A paired comparison with the original SDK, gated by PISHARP_ROOT_ANTHROPIC_* variables.
PiMessagesAgentContinuation A library the Pi messages suites share.
DurableMessages Coding agent session messages and the native initializer loader.
NativeModelCatalog, NativeRegistrationInstallation, ProfileInitializer, PublishedFixture.ProfileInitializer, RegistrationModelFacade, TypedSdkTool, SdkEventBus, SdkAsyncEventBus, SdkPluginEcho (with PluginA, PluginB, Qualification), PublicSdkConsumer.R511 Slices of the native extension SDK: model catalogs, registration, initializers, typed tools, event buses and plugins.
McpAuthorizationCode, McpOAuthHost, McpOAuthOrchestration, DefaultOAuthHostQualification, McpTuiOriginalQualification MCP OAuth flows and their hosts.
NodePackage, NodeHelloPackage, NodeCommandInputPackage, NodeLifecycleSourceIdentity, NodeUi, OriginalUiQualification Node bridge packages, commands and UI.
OriginalGrammarQualification, OriginalProviderQualification.Shared Shared qualification harness code.
Terminal.Default, Tui.Editor The default terminal and the editor component.

tests/fixtures/extensions/native/ holds native extensions the extension tests load, such as plugins that fail, import system assemblies or target a future ABI. tests/packaging/ and tests/release/ hold PowerShell tests of the packaging and legacy release scripts.

A test’s expected values are either authored or captured, and the reports keep the two apart:

  • An authored expectation is written by reading the pinned Pi source. Its case reports PASS_AUTHORED_NATIVE_ONLY.
  • A captured expectation is output an upstream Pi run produced, kept as a file. Its case compares PiSharp’s output with that file.

The captures live in several places:

Location Contents Made by
fixtures/pi-v0.99.1/ The v0.99.1 fixtures, with a manifest.json that records each fixture’s kind and source. The v0.99.1 port.
fixtures/reference/ Provider request captures the companion suites read. The v0.99.1 port.
tests/PiSharp.Durable.Tests/Fixtures/ Upstream durable captures (*.upstream.json) for Pi v1.1.0, and in v1.2.0/ for Pi v1.2.0 with a manifest.json and index.json. tools/DurableFixtures/capture-all.mjs
tests/PiSharp.CliParity.Tests/SessionFormat/ Session file scenarios captured from Pi v1.1.0. Recorded runs of Pi.
tests/PiSharp.Codemode.Tests/Declarations/ Code mode declaration goldens. gen-declaration-goldens.mjs beside them.
tests/PiSharp.Tools.Tests/ToolValidation/ Tool argument validation goldens. gen-tool-validation-goldens.mjs beside them.
InteractiveParity’s Mermaid goldens Diagram rendering goldens from the original library. tools/GrokMermaid/gen-goldens.mjs

To capture the durable fixtures again, run capture-all.mjs against a clean Pi checkout at the pinned commit. It needs Node.js 22.5 or later and takes --check, which captures twice and fails if the runs differ. Its header comment explains how to set up the checkout.

Terminal window
node --no-warnings tools/DurableFixtures/capture-all.mjs <pi checkout> --commit <sha> [--out <directory>] [--check]
Variable Suite Effect
PISHARP_WRITE_CHANGELOG=1 InteractiveParity The case changelog.sync.generated-from-website rewrites CHANGELOG.md from the website instead of failing when it differs. See Releasing.
INTERACTIVEPARITY_FILTER, CLIPARITY_FILTER, EXTPARITY_FILTER, PROVIDERAPIS_FILTER As named Run only the matching cases. See Run one case.
PI_DURABLE_DOCUMENT_RETENTION_MS Durable The default document retention of every session, in milliseconds. CI runs the suite a second time with 0, as upstream’s npm test does.
PISHARP_DURABLE_UPSTREAM Durable A Pi v1.2.0 checkout with its node_modules, and node on your PATH. Turns on the case where upstream reads sessions PiSharp wrote. Without it, the case reports SKIPPED_NO_UPSTREAM.
PISHARP_DURABLE_UPSTREAM_V110 DurableCli A Pi v1.1.0 checkout with its node_modules, for the session interop case. Skipped when unset.
PISHARP_PI_COMPARISON=1 InteractiveParity The streaming benchmark case also prints a timing record.
SESSFMT_DIR CliParity Replay the session format scenarios from another directory.
SESSFMT_DUMP=<dir> CliParity Write PiSharp’s session files, events.jsonl and stderr for each scenario to the directory.
PISHARP_TERMINAL_DEFAULT_REPLAY_REPORT CodingAgent Where to write the terminal replay report.

Other PISHARP_* variables you may see in the test code are plumbing between a suite and the child processes it starts. Don’t set them yourself.

On macOS, CI resolves TMPDIR before it runs a suite, because /var/folders is a symlink to /private/var/folders and the tests compare resolved paths. Do the same on a Mac:

Terminal window
export TMPDIR="$(cd "$TMPDIR" && pwd -P)/"

The compatibility and inventory tools have their own node:test files, such as tools/CompatibilityReport/*.test.mjs and tools/SurfaceInventory/*.test.mjs. Run one with node --test <file>. core.yml runs the applicability tests and validation-manifest tests, plus check-worklist.mjs --offline for shape, row, dependency, wave and local-path checks. It then fetches immutable upstream objects, verifies the frozen audit checkout 7d073328e44337d3292a7db9b0f0308f679c5e97, and runs the release applicability, worklist and port-map checks against their exact historical objects. PI_REQUIRE_UPSTREAM=1 makes a missing upstream checkout a failure in this second phase. The explicitly offline phase can report its upstream-only case as skipped; that is not upstream validation.

The workflows live in .github/workflows. The .NET jobs install the SDK from global.json and restore from nuget.org with lock-file checking off.

Workflow Triggers Runs on What it runs
core.yml Every pull request, pushes to main, manual, reusable Windows; Ubuntu for applicability Ten core console suites with build/fixture prerequisites and case manifests; offline and immutable-upstream applicability checks.
gap-regressions.yml Pull requests, pushes to main, manual, reusable Windows, Ubuntu, macOS Registered core/Chord/Env console projects, bounded owned processes and actual case ledgers. A required Ubuntu job separately tests the production Pi runtime installer and provenance in a fresh cache.
env-native.yml Pull requests, pushes to main, manual, reusable Windows, Ubuntu, macOS NativeAOT daemon publish, verified notice bundle, single-executable protocol smoke and platform terminal behavior.
macos.yml Pull requests and pushes to main; manual macos-15 (Apple Silicon) The 19 release suites other than Durable, DurableCli and CustomAgents, one job each with Node.js 22. Then it packs every package, installs the PiSharp.Cli tool from them, and checks pisharp --version and --help.
durable.yml Pushes and pull requests to main and feature/pi-durable; manual Windows, Ubuntu and macos-15 Durable, Durable again with PI_DURABLE_DOCUMENT_RETENTION_MS=0, and DurableCli. A second job publishes Durable.Tests for win-x64, linux-x64, linux-musl-x64 and osx-arm64 and checks that each carries its SQLite native library, byte for byte. A third fetches Pi and checks that compatibility/durable-port-map.json matches it.
custom-agents.yml Pushes and pull requests to main and feature/custom-agents; manual Windows, Ubuntu and macos-15 CustomAgents, then the research sample on scripted models, checking that it writes a report.
release.yml A pushed v* tag; manual dry run Ubuntu All 22 release-list suites, then packing. Publication additionally requires reusable core, Durable, gap regression (including production installer) and native Env validation jobs checked out at the same release SHA; their failure blocks NuGet and GitHub publication. See Releasing.
website.yml Pushes to main that touch website/** or compatibility/**; manual Ubuntu Builds and deploys the site. See The website.

core.yml also runs on every pull request and pushes to main, and can be called with an exact source_sha. Release calls durable.yml at that same SHA for its three-OS matrix, both retention modes, hosting/server cases, SQL Server container and four SQLite publish RIDs. Its optional web and browser jobs stay enabled for standalone Durable CI and are excluded from this release gate.

Core, Durable and release-list runs upload manifests generated by tools/ci/write-validation-manifest.mjs. Core runs also convert each manifest into standard Visual Studio TRX XML and a GitHub Actions Step Summary Markdown table via tools/ci/manifest-to-trx.mjs for immediate PR failure inspection. A manifest records the executing checkout SHA/tree, local tracked changes, platform, run identity, prerequisite requirements, each suite and each actual case result/reason. Core also records the observed build/fixture/run stages. The report’s original sourceSha is kept as oracleSourceSha; it is never relabeled as the checkout revision. Missing reports are failed receipts, and skips remain explicit passed-with-skips rather than unqualified passes. Core and SQL Server reject skips. Historical IMPLEMENTATION_STATUS.md entries and preparation receipts do not establish current-head test success.

The reports of the macOS, durable and custom agents runs are uploaded as workflow artifacts. Their matrices set fail-fast: false, so one failing OS or suite doesn’t cancel the others.

A new suite follows the same shape:

  • A console project under tests/, with its own committed packages.lock.json.
  • Case ids that are unique and stable, a --report <fresh path> option, and an exit code of 1 when a case fails.
  • An entry under /tests/parity/ in PiSharp.slnx.
  • To run it in CI, add it to the list in release.yml and to the matrix in macos.yml. The release runs only the suites its list names.

The Chord legacy codec interoperability tests require Node.js 22 or later (node on PATH, or PISHARP_NODE_EXECUTABLE). They use Node’s standard zlib decoder without installing packages; the production Chord library does not require Node. Native platform results come from the matching OS lane. A passing Windows group with an unavailable symlink fixture does not qualify that branch: console skip observations remain in the manifest and fail the core no-skip gate.

The dedicated gap projects are registered in tools/ci/gap-suites.json. Its per-platform policies name required cases and the few exact platform skips; the bounded runner rejects empty selections, missing cases, truncated output and unrecognized skips. Each stage retains its checkout and source hashes, raw stdout/stderr, prerequisite results and case ledger. A planned or interrupted run is not a passing result.