Skip to content

test: keep leftover log handlers out of the harness-parity context pin - #37478

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/build-watcher/harness-parity-log-sinks
Nov 15, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/build-watcher/harness-parity-log-sinks

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: test_harness_parity.py::test_config_load_never_reads_the_platform_context passes whatever test ran before it in the same worker.

The test failed on macOS shard 3 in run 43664027179 with config normalization reached the platform context: ['installed_context', 'installed_context']. It is order-dependent: it fails only when a test that starts the dashboard server ran earlier in the same xdist worker, so a change in shard layout (as in #37422) turns it red.

Why it matters

A red macOS shard blocks the Nightly publish and PRs that run macOS tests, with no product defect behind it.

Not a goal

  • Changing _normalize_acp_backend, the log ring handler, or its redaction.
  • Detaching handlers suite-wide (the conftest floor explains why it does not).

What changed (motivation → approach → change)

Symptom: two installed_context reads, one for each unselectable value ('byo-harness', 7), i.e. one per logger.warning. Root cause: #29423 (abf107a) made the dashboard's _RingLogHandler.emit run _stream_safe, which calls security.redact, which reads installed_context(). dashboard/server.py installs that handler on the kiro_crew logger once per process and it is never removed, so any later warning in that worker reaches the platform context through the log sink. The normalization itself does not read the context: the spy saw no current_context call, and installed_context never loads config, so there is no recursion risk. Change: the test detaches the kiro_crew logger's handlers for its own duration (monkeypatch restores the list), so it pins the normalization and not leftover sinks.

Backwards compatibility

Compatible: test-only change.

Removes nothing: the test still spies both context entry points; only leftover log handlers are detached for the test's duration.

Tests

test/test_harness_parity.py::test_config_load_never_reads_the_platform_context no longer depends on test order.
Proof: not provable -- test-only change

Manual verification

N/A — test-only; the PR's macOS CI run (ci:macos) is the check.

Related Issues

Order-dependent since #29423.

Sibling sweep

Swept: git grep -n "installed_context", lambda" -- test/
Siblings: none -- the other installed_context stubs return a fake context; this is the only one that counts calls and asserts there are none

Pattern harvest

Not generalizable: one spy-based test seeing a process-wide log handler another test installed; the conftest floor already documents why handlers are not restored.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 15, 2026 03:19
@CrysisDeu CrysisDeu added the ci:macos Run the on-demand macOS suite against this PR head label Nov 15, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 106d9342b0b1d0aa652dce535ef3c423fcedcc53 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 106d9342b0b1d0aa652dce535ef3c423fcedcc53 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 106d9342b0b1d0aa652dce535ef3c423fcedcc53 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: a test-only change that removes order-dependence in the test, leaves the behaviour it pins unchanged, and is reverted cleanly if wrong.

Notes

  • When the dashboard is running, _normalize_acp_backend warnings still reach installed_context() through the ring handler's redaction. The PR's statement that installed_context never loads config is the only thing ruling out recursion there. A short assertion of that, next to the spy, would protect it if that code changes later.

[DESIGN-REVIEWED] 106d934

Description read

[DESCRIPTION-READ] 92445efe46740262df22874fd6084e035e8847e6f6c09fbf01ccaa2bff03ef75

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 106d9342b0b1d0aa652dce535ef3c423fcedcc53 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 106d934

Verdict parsed from the review's SHA-scoped output markers for commit 106d9342b0b1d0aa652dce535ef3c423fcedcc53.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 106d9342b0b1d0aa652dce535ef3c423fcedcc53 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 106d9342b0b1d0aa652dce535ef3c423fcedcc53 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 106d934

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 106d9342b0b1d0aa652dce535ef3c423fcedcc53 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 4% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

This is a test-only fix for an order-dependent failure. A dashboard server test leaves _RingLogHandler on the kiro_crew logger for the rest of the process. Its emit runs _stream_safe → redact → installed_context(), so the normalization warnings were counted as reaching the platform context. The fix empties the kiro_crew logger's handler list for the test via monkeypatch, which restores the original list afterwards. I verified that installed_context() is a bare read of _ACTIVE and never loads config, so the recursion hazard the test guards against (current_context loading config) is not hidden. The spy still records both entry points. No product code changed.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 106d9342b0 · 6 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 15, 2026 05:04

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: isolates one harness-parity test from log handlers an earlier test left installed, test file only.

@KiroCrewCaptain
KiroCrewCaptain merged commit 932e28e into main Nov 15, 2026
110 of 119 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/build-watcher/harness-parity-log-sinks branch November 15, 2026 05:21
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:macos Run the on-demand macOS suite against this PR head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants