Skip to content

ci: real-harness lane proving Claude Code and Copilot CLI load native plugins - #5201

Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-ql-real-harness-pr
Nov 24, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-ql-real-harness-pr

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds a non-required Real Harness lane. It proves that pinned Claude Code and Copilot CLI releases actually load a plugin apm installs natively, not only that apm wrote the files. A fixture plugin (one skill, a SessionStart hook writing a marker, a stdio MCP server logging every JSON-RPC method) is installed with the apm built from the SHA. Then each harness is checked with evidence other than model output:

  • Claude Code: the claude -p --output-format stream-json init event (plugins, skills, MCP servers), the hook marker, and the MCP initialize/tools/list log. It never reaches a model (ANTHROPIC_BASE_URL is a closed local port), and the TUI runs in tmux.
  • Copilot CLI: copilot plugin|skill|mcp list, the hook and MCP markers, and on schedule/dispatch one cheap model turn that calls the plugin's MCP tool.

Cells are harness x environment {TUI, git worktree, -p} x scope {user, project}, plus Claude diagnostic cells: second session, absolute path, no folder trust, native claude plugin install, and two worktree-branch cells. The pins are Claude Code 2.1.326 and 2.1.323, and Copilot CLI 1.0.106, 1.0.113 and 1.0.114-0. COPILOT_AUTO_UPDATE=false keeps Copilot on its pinned version.

scripts/real_harness/expected.json records each cell's expected verdict, including the known bugs #5176 and #5180. The last step, probe.py check, fails on any divergence. BLOCKED (missing credential, rate limit) never fails. The #5176/#5180 fix PR flips its cells to LOADS.

Trust model: contents: read, every action pinned by SHA, persist-credentials: false, no cache saved, no pull_request_target.

  • Copilot token (W3d R1): the environment secret REAL_HARNESS_COPILOT_TOKEN of a GitHub environment real-harness. Copilot jobs enter that environment only for schedule and workflow_dispatch on main. Pull requests, and dispatches of another branch's workflow, get no token; their Copilot session cells report BLOCKED.
  • Harness pins (R2): npm ci from scripts/real_harness/npm/<harness>-<version>/package-lock.json, which pins sha512 integrity for every package, the per-platform binary included. Before install, the step also fails unless npm view <pkg>@<ver> dist.integrity equals the pinned value.
  • Lockfile regeneration (ab0117a): the pins were rewritten by npm 10.9.9, the npm bundled with the pinned Node 22.23.5. The job fails fast unless node --version is v22.23.5 and npm --version is 10.9.9. Integrity continuity against the first lockfiles (85f82cd): every package present in both has the same sha512; only version-less stubs for unpublished platform packages dropped.
Pin Packages in both Same sha512 Changed Dropped (old only) Added (new only)
claude-2.1.326 9 9 none none none
claude-2.1.323 9 9 none none none
copilot-1.0.106 10 10 none none none
copilot-1.0.113 8 8 none copilot-linuxmusl-arm64 (stub, no integrity), copilot-linuxmusl-x64 (stub, no integrity) none
copilot-1.0.114-0 4 4 none copilot-darwin-arm64 (stub, no integrity), copilot-darwin-x64 (stub, no integrity), copilot-linux-arm64 (stub, no integrity), copilot-linuxmusl-arm64 (stub, no integrity), copilot-linuxmusl-x64 (stub, no integrity), copilot-win32-arm64 (stub, no integrity) none
  • Artifacts and summary (R3, F1, F2): the uploaded evidence is staged into one directory and scanned with probe.py scan before upload; a hit fails the job and nothing is uploaded. The public step summary is built from each cell.json verdict and reason only, and is scanned before it is written. The scan matches the token raw and base64-encoded (bare and as x-access-token:<token>) at all three byte alignments, so a prefix such as Bearer or <user>: cannot hide it, and also matches the base64 needles with line breaks removed (wrapped base64). ~/.copilot/config.json is never uploaded.
  • Token scope (R1'): COPILOT_TOKEN is set only on the probe step (which runs the harness) and on the summary and staging steps (which only scan with it). npm ci and uv sync never see it; Copilot pins install with --ignore-scripts.
  • Not a required check: gh api repos/microsoft/apm/rules/branches/main lists one required_status_checks rule, [{"context":"gate","integration_id":15368}]. Classic branch protection is not configured (gh api repos/microsoft/apm/branches/main/protection returns 404), and merge-gate.yml EXPECTED_CHECKS names no Real Harness check.

Admin setup required (not doable from a PR):

  1. Settings > Environments > New environment real-harness.
  2. Deployment branches and tags: Selected branches and tags, rule main only.
  3. Environment secret REAL_HARNESS_COPILOT_TOKEN: a fine-grained token of a dedicated bot account with a Copilot seat, with no repository permissions beyond what Copilot CLI needs (tracked in [FEATURE] Dedicated Copilot token for the real-harness lane #5202).
  4. Do not add it as a repository secret.
    Until this exists, nightly Copilot session cells report BLOCKED; nothing fails.

Issue and approved scope

Issue: Refs #5197

Human scope-approval comment: #5197 (comment)

Does this PR complete the issue, or what remains? It delivers the lane. #5197 is done when the nightly is green and the PR lane catches the #5176/#5180 fix (that PR flips expected.json).

Code-owner: authored under the owner's account; landing requires the owner's explicit admin authorization on this PR.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence:

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

… plugins

Adds .github/workflows/real-harness.yml (nightly, dispatch, path-filtered
pull_request; not required) and scripts/real_harness/probe.py. Pinned harness
releases load a fixture plugin installed by the apm built from the SHA; the
lane asserts the hook fires, the MCP server handshakes and the skill is listed.
expected.json is a red-first oracle: #5176 and #5180 cells are expected to
fail until their fix flips them.

Refs #5197

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Installation failures can be misclassified as exempt blockers and leave broken runs green, while harness packages lack the required integrity verification.

6 open issues
What changed in this PR

Adds a non-required Real Harness CI lane to verify that Claude Code and Copilot CLI load native plugins installed by APM, complementing existing file-deployment tests and tracking regressions from #5176 and #5180.

Changes:

  • Runs pinned harness versions across terminal, worktree, and headless environments at user and project scope.
  • Collects plugin-loading evidence and compares cell verdicts against committed expectations.
  • Adds verdict-gate tests and documents scheduling, credentials, and expected-result handling.
File Description
tests/​unit/​scripts/​test_real_harness_check.py Tests verdict comparisons and expectation validity.
scripts/​real_harness/​probe.py Creates fixtures, runs harnesses, collects evidence, and checks verdicts.
scripts/​real_harness/​expected.json Records expected outcomes, including known plugin-loading bugs.
docs/​src/​content/​docs/​contributing/​integration-testing.md Documents the lane and its evidence model.
.github/​workflows/​real-harness.yml Adds scheduled, manual, and path-filtered PR runs with evidence uploads.
.github/​instructions/​cicd.instructions.md Records the lane’s CI role and credential boundaries.

Review effort: Balanced

Comment thread .github/workflows/real-harness.yml Resolved
Comment thread scripts/real_harness/probe.py Resolved
Comment thread scripts/real_harness/probe.py Resolved
Comment thread scripts/real_harness/probe.py Resolved
Comment thread scripts/real_harness/probe.py Resolved
Comment thread scripts/real_harness/probe.py Resolved
…, evidence scan, polling

- Pin each harness with a committed npm lockfile (sha512 for every package,
  platform binary included) and check the registry integrity before npm ci.
- The Copilot token is the real-harness environment secret, entered only on
  schedule and dispatch on main; evidence is staged and scanned before upload.
- A failed apm install is ERROR, never exempt; MCP tools/list is required;
  Claude TUI cells assert the skill in the slash-command menu; the Agent
  Plugin MCP server runs the deployed copy and the source is removed.
- Marker polling replaces fixed sleeps.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The probe gate can pass with absent or incomplete cell results, allowing missing evidence to produce a green result instead of an error.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Reject missing probe evidence instead of passing the gate

scripts/​real_harness/​probe.py:733

The gate returns success when there are no cell.json files, and also when an expected cell is absent but the remaining cells match. This lets skipped or missing probe evidence produce a green result rather than an error; missing evidence is not a credential-related BLOCKED result. Pass the job's selected harness/cell set into check() and reject missing results, while still permitting explicit BLOCKED cells.

6 resolved since last review
5 files not reviewed
  • scripts/real_harness/npm/claude-2.1.323/package-lock.json: Generated file
  • scripts/real_harness/npm/claude-2.1.326/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.106/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.113/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.114-0/package-lock.json: Generated file

Review effort: Balanced

npm ci on the runner rejected the version-less stub entries that npm 11 writes
for Copilot's unpublished musl binaries.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The artifact scan can miss symlinked token files that the uploader includes, risking credential exposure, while harness checks can pass without required tool-use or run evidence.

No open issues 🎉

3 previously missed issues

In code that hasn't changed since last review

High severity Scan symlink targets and fail on scan errors

.github/​workflows/​real-harness.yml:166

cp -r preserves symlinks, but grep -r skips links encountered during traversal while the pinned uploader follows them. A staged link to a token-containing file can therefore pass this scan and expose the token in the artifact. Follow symlink targets during scanning and reject scan errors rather than treating them as a clean result.

Medium severity Require MCP tool-call evidence for Copilot LOADS

scripts/​real_harness/​probe.py:645

An authenticated Copilot session can finish or time out without calling the requested MCP tool and still receive LOADS, because the verdict requires only startup and skill-list evidence. Require the recorded mcp_tool_called signal for Copilot LOADS so a failed tool-use probe cannot pass, while retaining credential/rate-limit BLOCKED handling.

Medium severity Reject empty harness result sets

scripts/​real_harness/​probe.py:733

If the output directory is missing or contains no cell.json files, this loop performs no comparisons and check returns an empty problem list, so the CLI exits successfully without any harness evidence. Reject an empty result set before comparing verdicts; an absent run is not one of the explicit BLOCKED exemptions.

5 files not reviewed
  • scripts/real_harness/npm/claude-2.1.323/package-lock.json: Generated file
  • scripts/real_harness/npm/claude-2.1.326/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.106/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.113/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.114-0/package-lock.json: Generated file

Review effort: Balanced

…and base64

- COPILOT_TOKEN moves from job env to the probe, summary and staging steps;
  npm ci runs with --ignore-scripts for Copilot pins.
- The public step summary is built from cell.json verdicts only and scanned
  before it is written.
- probe.py scan matches the token raw and base64-encoded (bare and as an
  x-access-token pair); unit-tested.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the gate can overlook missing coverage and new failures in known-bug cells, while the tests leave verdict classification unverified.

No open issues 🎉

5 files not reviewed
  • scripts/real_harness/npm/claude-2.1.323/package-lock.json: Generated file
  • scripts/real_harness/npm/claude-2.1.326/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.106/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.113/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.114-0/package-lock.json: Generated file

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because missing cell results and Claude sessions without initialization can pass the gate without establishing intended coverage or valid runtime observations.

No open issues 🎉

5 files not reviewed
  • scripts/real_harness/npm/claude-2.1.323/package-lock.json: Generated file
  • scripts/real_harness/npm/claude-2.1.326/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.106/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.113/package-lock.json: Generated file
  • scripts/real_harness/npm/copilot-1.0.114-0/package-lock.json: Generated file

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit cec0e22 into main Nov 24, 2026
82 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-ql-real-harness-pr branch November 24, 2026 06:03
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.

2 participants