Skip to content

[purelock] Lock down packageFunctionAliasInitializer, statusOnlyExpressionPath, graderJavaScriptReferenceName with pure-function test suite - #73778

Merged
pelikhan merged 2 commits into
mainfrom
purelock/lock-down-pure-functions-1e826f93d2d82268
Nov 1, 2026
Merged

pelikhan merged 2 commits into
mainfrom
purelock/lock-down-pure-functions-1e826f93d2d82268

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

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

Function Function coverage Package coverage Suite
packageFunctionAliasInitializer 0.0% → 100.0% 59.8% → 61.9% 1 test, 18 subtests, 50 assertions
statusOnlyExpressionPath 0.0% → 100.0% 51.0% → 56.0% 1 test, 15 subtests, 30 assertions
graderJavaScriptReferenceName 27.3% → 100.0% 90.8% → 91.1% 1 test, 22 subtests, 88 assertions

Function details

packageFunctionAliasInitializer

  • File: pkg/linters/internal/astutil/astutil.go
  • Signature: func packageFunctionAliasInitializer(pass *golang.org/x/tools/go/analysis.Pass, node go/ast.Node, obj go/types.Object) go/ast.Expr
  • Pure because precompute found “no observable side effects detected”; semantic verification confirms it only reads supplied AST/type data and returns an existing expression or nil.
  • Fuzzing: not needed. Residual uncovered target lines: none.

statusOnlyExpressionPath

  • File: pkg/workflow/aw/status_only_job.go
  • Signature: func statusOnlyExpressionPath(node github.com/rhysd/actionlint.ExprNode) ([]string, bool)
  • Pure because precompute found “no observable side effects detected”; semantic verification confirms it only reads expression-node fields and builds fresh result slices recursively.
  • Fuzzing: not needed. Residual uncovered target lines: none.

graderJavaScriptReferenceName

  • File: pkg/workflow/lint/grader_file_io_ast.go
  • Signature: func graderJavaScriptReferenceName(node *github.com/github/gh-aw/pkg/workflow/taint.JavaScriptNode) string
  • Pure because precompute found “no observable side effects detected”; semantic verification confirms it only reads the AST and recursively constructs local strings, with no I/O, global access, mutation, clock, or randomness.
  • Fuzzing: not needed. Residual uncovered target lines: none.

Validation

  • gofmt, go vet, and go test -race -count=1 passed for all three changed packages.
  • Combined atomic coverage test and Cobertura conversion passed.
  • make agent-report-progress completed impacted tests but could not run golangci-lint: the executable is absent in this runner. This is an environment limitation; no lint failure was reported.

References: §41306466750

Generated by 🔐 PureLock · codex · gpt56 · ~136 AIC · ⌖ ~16 AIC · ⊞ 15.6K · ◷

  • expires on Nov 6, 2026, 4:48 AM UTC-08:00

@pelikhan
pelikhan marked this pull request as ready for review November 1, 2026 15:03
Copilot AI dynamic review requested due to automatic review settings November 1, 2026 15:03
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · haiku45 · ~6 AIC · ⌖ ~11 AIC · ◇ ~3 AIC · ⊞ 9.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · gpt56 · ~12 AIC · ⌖ ~6 AIC · ⊞ 15.1K · ◷

Generated by Ponytail Reviewer for #73778

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

🏗️ Design Decision Gate — No Architectural Decision Detected

This PR crossed the default volume threshold (456 added lines under pkg/, threshold 100), so ADR enforcement was evaluated. No draft ADR was generated, because the PR doesn't make an architectural decision that can be inferred from the evidence.

Evidence

  • All 3 changed files are new _test.go files:

    • pkg/linters/internal/astutil/astutil_alias_initializer_test.go (+155)
    • pkg/workflow/aw/status_only_job_test.go (+146)
    • pkg/workflow/lint/grader_file_io_ast_test.go (+155)
  • No production code, interfaces, dependencies, or package structure changes. The PR only adds table-driven tests for existing pure helpers: packageFunctionAliasInitializer, statusOnlyExpressionPath, and graderJavaScriptReferenceName.

  • No ADR is linked in the PR body or present on the branch for this PR.

Missing context
No architectural decision can be inferred from the current PR evidence. Adding test coverage within the existing testing pattern doesn't usually need an ADR.

Next action
You don't need to add an ADR for this test-only change. If this PR is meant to introduce a new testing strategy or quality gate (for example, making PureLock coverage a requirement), add an ADR under docs/adr/73778-*.md or link one in the PR description.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: opus55 medium · ~16 AIC · ⌖ ~1 AIC · ⊞ 7.7K · ◷
Comment /review to run again

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.

🟢 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)

@github-actions github-actions 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.

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 (packageFunctionAliasInitializer in astutil.go, statusOnlyExpressionPath in status_only_job.go, graderJavaScriptReferenceName in grader_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 /tdd practice 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

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-01T15:06:30Z
review_event: REQUEST_CHANGES
top_themes:
  - Assignment tests use Defs instead of Uses and miss real production behavior
  - Malformed JavaScript path fixtures codify capability-looking false positives
files_reviewed:
  - pkg/linters/internal/astutil/astutil_alias_initializer_test.go
  - pkg/workflow/aw/status_only_job_test.go
  - pkg/workflow/lint/grader_file_io_ast_test.go
comment_count: 2

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷
Comment /review to run again

@github-actions github-actions 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.

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.Defs instead of Uses.
  • 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,

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.

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.

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.

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.",

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 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.

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.

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.

@pelikhan

pelikhan commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Ran the finisher pass and pushed fixes in 34219e6; I replied to both review threads. The available GitHub tools cannot resolve threads, so they remain outdated/unresolved. Checks for the new head are in progress; merge readiness is still pending.

Copilot AI requested a review from pelikhan November 1, 2026 15:40
@pelikhan
pelikhan merged commit 9dca091 into main Nov 1, 2026
53 checks passed
@pelikhan
pelikhan deleted the purelock/lock-down-pure-functions-1e826f93d2d82268 branch November 1, 2026 15:55
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v1.2.0

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants