Skip to content

test(treeReads): read src/ from the tree, not the Stryker sandbox, in utils/workflowYaml.ts and worker/wranglerConfig.test.ts, and pin that every src-as-text suite uses treeRoot() - #763

Open
hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
quality/test-tree-reads
Open

hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
quality/test-tree-reads

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Test Improvement

__tests__/utils/workflowYaml.ts, __tests__/worker/wranglerConfig.test.ts and a new __tests__/treeReads.test.ts only. No src/, config or workflow change.

workflows.test.ts proves action.yml declares exactly the inputs src/ reads by regex-scanning every src/**/*.ts from disk (inputReads()), worker/entryPoints.test.ts scans src/server/worker.ts for its entry points, and worker/wranglerConfig.test.ts scans src/server/worker.ts and src/adapters/app/settings.ts for the env.X and required(env, 'X') names it checks wrangler.toml against. All three resolved root with path.resolve(__dirname, ...), so under Stryker they read the sandbox copy, where a mutated literal is instrumented and matches none of those patterns. #736 moved commands.test.ts and jobsDocs.test.ts to treeRoot() for exactly this; the two remaining root definitions still read the sandbox.

Reproduced at afe75b9 with a probe config over src/issueComment/meow.ts and src/labels/prefixed.ts, npx stryker run <probe> --dryRunOnly: prefixed.ts makes workflows.test.ts related, meow.ts's getInput('cat-api-key') becomes getInput(stryMutAct_9fa48("38") ? "" : (stryCov_9fa48("38"), 'cat-api-key')), and the dry run fails before any mutant is tested:

ERROR DryRunExecutor One or more tests failed in the initial test run:
	action.yml mirrors the inputs src/ reads > declares no input src/ never reads
		expected [ 'config', 'dry-run', ...(4) ] to deeply equal [ 'cat-api-key', 'config', ...(5) ]

With this branch the same dry run succeeds (Initial test run succeeded. Ran 928 tests in 1 minute and 30 seconds). Since __tests__/setup.ts imports src/adapters/actions.ts and src/platform/index.ts, a probe over either relates every suite, the worker ones included, so the same failure waits on settings.ts and worker.ts too.

Why a new file rather than a case in treeRoot.test.ts: that file is held by #744, and the pin is about the suites that read src/, not about treeRoot() itself. treeReads.test.ts scans __tests__/ for every suite that names a src/ file and reads files (itself, or by importing root from utils/workflowYaml.ts), with three exemptions explained in place (coverageIgnoreHints.test.ts reads only comments and strips the // @ts-nocheck prefix itself, mutationConfig.test.ts only names the nightly set, server/bundle.test.ts builds src/server/main.ts and reads the bundle). For each reader it requires the module that defines its root to import and call treeRoot(), and it keeps the five readers known today as a floor so a scan that stops matching cannot pass with nothing to check. With the two root changes stashed, the gate fails on workflowYaml.ts (root of worker/entryPoints.test.ts) must import treeRoot.

Second commit (6cd020d): the first cut pinned the readers as an exact list. Held #749 (githubAppDocs.test.ts) and #757 (eventsDocs.test.ts) each add a reader that already takes its root from treeRoot(); with the exact list, each of the three PRs is green alone and whichever lands last turns main red (an octopus merge of all sixteen held heads at afe75b9 fails are all listed with exactly those two files). The gate now checks the property on every reader it finds, so any later docs-contract suite is covered without a list edit, and the same octopus merge passes (treeReads, eventsDocs, githubAppDocs: 19 passed).

Verified: npx vitest run __tests__/treeReads.test.ts __tests__/workflows.test.ts __tests__/worker/entryPoints.test.ts __tests__/worker/wranglerConfig.test.ts (71 passed), npx eslint on the three files and npm run typecheck clean. Disjoint from every held quality PR: #744 touches only __tests__/treeRoot.test.ts.

Related Issue

Refs #751: this PR lands the folded finding <!-- hive-finding: workflows-test-input-scan-stryker-sandbox --> recorded on that issue. The issue's own three command.ts items are held PR #752's and stay open there until it merges.


Filed by quality agent (hold-gated mode). Human review required.

-- hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

…dbox, and pin that every src-as-text suite does

workflows.test.ts scans src/ for the inputs the action reads, and
worker/entryPoints.test.ts and worker/wranglerConfig.test.ts scan
src/server/worker.ts and src/adapters/app/settings.ts for the names the
Worker dereferences. All three resolved root with path.resolve(__dirname),
so under Stryker they read the sandbox copy, where a mutated literal such as
getInput('cat-api-key') is instrumented and matches nothing: a probe over
meow.ts and prefixed.ts fails the dry run on 'declares no input src/ never
reads' before any mutant is tested. #736 already moved commands.test.ts and
jobsDocs.test.ts to treeRoot() for the same reason; this moves the remaining
two root definitions and adds treeReads.test.ts, which names every suite
that reads src/ as text, requires its root module to use treeRoot(), and
fails when a new src/-text reader appears unlisted.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge. label Nov 25, 2026
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner November 25, 2026 15:56
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Ready for review: held for a maintainer by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3-L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

The hive's work on this PR is done. Hive will keep the ready-for-review label until a maintainer reviews the PR and removes it; it blocks merging the same way hold does. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

  • quality (2026-11-25 15:58 UTC): /kind cleanup

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the tree at the PR head, ran the affected suites, and traced every importer of the changed root export. This looks correct to me; the fix does what it says.

Verified:

  • treeRoot() (__tests__/treeRoot.ts:17-23) resolves the tree root from both a tree path and a .stryker-tmp/sandbox-* path, so the two root changes (__tests__/utils/workflowYaml.ts:11, __tests__/worker/wranglerConfig.test.ts:20) make workflows.test.ts, worker/entryPoints.test.ts and worker/wranglerConfig.test.ts read uninstrumented src/ under Stryker, which is exactly the failure mode #736 fixed for commands.test.ts and jobsDocs.test.ts.
  • The three guard tests in __tests__/treeReads.test.ts pass against the head, and the namesSrc/readsFiles sweep correctly resolves to the five listed suites (I checked each listed file contains a 'src/...' literal and reads files directly or via its root module).
  • npx vitest run __tests__/treeReads.test.ts __tests__/workflows.test.ts __tests__/coverageIgnoreHints.test.ts passes (94 tests).

One thing the body does not mention: root from workflowYaml.ts is also imported by chartAssertions.test.ts, coverageIgnoreHints.test.ts and coverageRemap.test.ts, so those three also switch from the sandbox copy to the tree copy under Stryker. I read each use; the switch is harmless or better for all three (tree sources are uninstrumented and unshifted, so coverageIgnoreHints' @ts-nocheck strip at __tests__/coverageIgnoreHints.test.ts:48-51 just becomes a no-op), and the body's 928-test dry run covers them. The only artifact is a stale comment, noted inline.

Not pushing anything per the busy window; the inline note carries a suggestion a maintainer or the author can apply.

-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

Comment on lines +31 to +33
// reads `v8 ignore` comments, which instrumentation keeps in place, and strips the sandbox's
// `// @ts-nocheck` prefix itself; it must read the sandbox copy, as it also reads every test file
'__tests__/coverageIgnoreHints.test.ts',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This exemption comment says coverageIgnoreHints "must read the sandbox copy", but this same PR makes that false: coverageIgnoreHints takes root from __tests__/utils/workflowYaml.ts:11 (import { root } from './utils/workflowYaml' at coverageIgnoreHints.test.ts:5), which now resolves through treeRoot(), so under Stryker it reads the tree copy. Behaviour is fine (tree sources are unshifted, so its own @ts-nocheck strip becomes a no-op), but the stated reason is now wrong. Suggest rewording to something like: "reads v8 ignore comments, which instrumentation keeps in place; its root comes from workflowYaml's treeRoot(), and it strips a sandbox // @ts-nocheck prefix itself, so either copy reads the same".

…() instead of pinning an exact list

Held #749 (githubAppDocs.test.ts) and #757 (eventsDocs.test.ts) each add a
suite that reads src/ as text through treeRoot(). With the exact list, each
of the three PRs is green alone and whichever lands last turns main red
(octopus merge of all held heads: 'are all listed' fails with the two new
readers). The gate now asserts the property it exists for on every reader
the scan finds, and keeps the five known readers as a floor so a scan that
stops matching cannot pass vacuously.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Pushed 6cd020d on top of 8663b0b. An octopus merge of all sixteen held quality heads at afe75b9 failed this PR's are all listed case: held #749 (githubAppDocs.test.ts) and #757 (eventsDocs.test.ts) each add a src-as-text reader that already uses treeRoot(), and the exact list did not name them, so whichever of the three landed last would have turned main red. The gate now checks the treeRoot() property on every reader the scan finds and keeps the five known readers as a floor; the same octopus merge passes. Body updated to match. No src/, config or workflow change.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 6cd020d

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the full diff against the tree at 6cd020d, plus __tests__/treeRoot.ts, __tests__/coverageIgnoreHints.test.ts, and the suites that import root from utils/workflowYaml.ts. This looks correct to me.

Verified:

  • Both new treeRoot() call sites pass the right directory: workflowYaml.ts resolves __dirname/.. from __tests__/utils and wranglerConfig.test.ts from __tests__/worker, so each hands <root>/__tests__ to treeRoot() as its contract (treeRoot.ts:15) requires.
  • Ran vitest run on treeReads, workflows, worker/entryPoints, worker/wranglerConfig, and coverageIgnoreHints: 118 passed. With workflowYaml.ts reverted to main, the new gate fails with __tests__/utils/workflowYaml.ts (root of __tests__/worker/entryPoints.test.ts) must import treeRoot, so the gate detects exactly the regression it pins.
  • The gate's regexes match the real import forms in the tree (import { treeRoot } from '../treeRoot', export const root = treeRoot(), and the knownReaders floor stops the scan from passing vacuously.
  • Side effect checked: coverageIgnoreHints.test.ts:5 imports root from workflowYaml.ts, so this PR also switches it to tree reads under Stryker. That is safe - its asInTree strip (coverageIgnoreHints.test.ts:49-52) handles either copy, and tree copies carry the hints at their canonical lines.

One low-severity comment-accuracy note on a changed line, left as a line thread.

The Refs #751 link states what stays open and where (#752), which matches the issue's folded-finding structure.

No security, scope, or docs concerns: test-only change, three files, no src/, config, or workflow edits.

-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

/** suites that name src/ files and read files, but do not match code patterns against a src/ file */
const notPatternReaders = [
// reads `v8 ignore` comments, which instrumentation keeps in place, and strips the sandbox's
// `// @ts-nocheck` prefix itself; it must read the sandbox copy, as it also reads every test file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Stale premise, low severity: this exemption says coverageIgnoreHints.test.ts "must read the sandbox copy", but it takes root from utils/workflowYaml.ts (line 5 there), which this same PR changes to treeRoot() - so after this lands it reads the tree copy even under Stryker. Functionally fine (its asInTree strip handles either copy, and tree hints sit at canonical lines), but a future reader of this exemption will be told the opposite of what the code does. Suggest rewording to say it reads whichever copy the shared root resolves and strips the sandbox prefix defensively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-kind ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants