Skip to content

[purelock] Lock down parseImportSpecsFromObject, relativizeIncludedFilePath, resolveCacheStepName with pure-function test suites - #54235

Merged
pelikhan merged 2 commits into
mainfrom
purelock/lockdown-batch-20260820-125619-8bda58f88617eb58
Aug 20, 2026
Merged

[purelock] Lock down parseImportSpecsFromObject, relativizeIncludedFilePath, resolveCacheStepName with pure-function test suites#54235
pelikhan merged 2 commits into
mainfrom
purelock/lockdown-batch-20260820-125619-8bda58f88617eb58

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

test> Generated by PR Description Updater for #54235 · auto · 39.7 AIC · ⌖ 7.2 AIC · ⊞ 7.7K ·

Add table-driven tests for three pure functions with weak coverage:
- parseImportSpecsFromObject (pkg/parser/import_bfs.go)
- relativizeIncludedFilePath (pkg/parser/include_expander.go)
- resolveCacheStepName (pkg/workflow/cache_steps.go)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

Great work on this automated test coverage improvement! 🎯

This PR successfully locks down three pure functions with comprehensive table-driven test suites, bringing coverage from 0% → 100% for each function:

  • parseImportSpecsFromObject — 9 subtests covering all branches (missing key, array variants, error cases)
  • relativizeIncludedFilePath — 7 subtests covering path resolution edge cases (under baseDir, outside both baseDir and repoRoot, etc.)
  • resolveCacheStepName — 11 subtests covering name precedence and fallbacks

The PR is well-focused (tests only, no side changes), includes clear documentation of why each function is pure and how the test suite validates behavior, and includes validation results (gofmt, go vet, go test passes). This looks ready to merge! ✅

Generated by ✅ Contribution Check · auto · 48 AIC · ⌖ 7.27 AIC · ⊞ 9.2K ·

@pelikhan
pelikhan marked this pull request as ready for review August 20, 2026 15:28
Copilot AI balanced review requested due to automatic review settings August 20, 2026 15:28
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 20, 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 Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 20, 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 Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Ponytail Reviewer completed successfully!

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by Ponytail Reviewer for #54235

@github-actions

Copy link
Copy Markdown
Contributor Author

Comment Memory

reviewed_at: 2026-08-20T00:00:00Z
review_event: COMMENT
top_themes:
  - tests-only change
  - full-branch coverage for pure helpers
  - no blocking correctness issues found
files_reviewed:
  - pkg/parser/import_bfs_test.go
  - pkg/parser/include_expander_relativize_test.go
  - pkg/workflow/cache_steps_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
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 · gpt54 · 3.56 AIC · ⌖ 6.78 AIC · ⊞ 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.

Verdict

No blocking issues in this diff.

Review notes

This PR only adds table-driven tests around existing pure helpers, and the new cases exercise the intended branches without changing production behavior. I did not find a correctness, security, or performance regression in the changed lines.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 3.56 AIC · ⌖ 6.78 AIC · ⊞ 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.

Test-only PR adding table-driven test coverage for parseImportSpecsFromObject, relativizeIncludedFilePath, and resolveCacheStepName. The test cases are thorough (happy paths, edge cases, error paths), use filepath.FromSlash for cross-platform correctness, and follow existing test conventions. No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 17.2 AIC · ⌖ 8.78 AIC · ⊞ 5.8K

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.

Pull request overview

Adds focused unit coverage for three deterministic parser and workflow helpers.

Changes:

  • Tests import-object parsing and error propagation.
  • Tests included-file path relativization.
  • Tests cache-step naming precedence and fallbacks.
Show a summary per file
File Description
pkg/parser/import_bfs_test.go Covers object-form import parsing.
pkg/parser/include_expander_relativize_test.go Covers path relativization branches.
pkg/workflow/cache_steps_test.go Covers cache-step naming behavior.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@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 — approving. The test suites are well-structured and bring three previously uncovered pure functions to 100% coverage.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Table-driven style with descriptive subtest names that read as specifications
  • ✅ All four branches of parseImportSpecsFromObject covered, including both []any and []string cases
  • relativizeIncludedFilePath covers the crucial cross-boundary cases (inside baseDir, between baseDir and repoRoot, outside both, empty repoRoot)
  • resolveCacheStepName covers the full priority chain: namekey → indexed default, with type-mismatch and empty-string fallthrough
  • ✅ Race-condition testing (-race) run on all new tests

Minor Observations

  1. Error-path require.Nil assertions (pkg/parser/import_bfs_test.go) — every error branch asserts require.Nil(t, specs). The current implementation guarantees this, but Go convention only requires the error to be non-nil on failure; the returned slice is an implementation detail. Dropping these assertions would make the tests less brittle under future refactors.

  2. relativizeIncludedFilePath — portable want strings — tests use filepath.FromSlash on inputs (correct for portability) but hard-code forward-slash want values. This is fine because filepath.ToSlash is what produces them, but a brief inline comment would help future readers understand the portability contract.

Neither is blocking.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 34.2 AIC · ⌖ 9.9 AIC · ⊞ 7.9K
Comment /matt to run again

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (268 new lines in pkg/parser and pkg/workflow) but did not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/54235-adopt-purelock-batch-testing-for-pure-function-coverage.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-54235: Adopt PureLock Batch Testing for Pure-Function Coverage Lockdown

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 54235-adopt-purelock-batch-testing-for-pure-function-coverage.md for PR #54235).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 80.8 AIC · ⌖ 33.7 AIC · ⊞ 9.1K ·
Comment /review to run again

@pelikhan
pelikhan merged commit 23ab38d into main Aug 20, 2026
3 checks passed
@pelikhan
pelikhan deleted the purelock/lockdown-batch-20260820-125619-8bda58f88617eb58 branch August 20, 2026 16:05
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.87.2

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.

2 participants