Skip to content

[build-tools][steps] Load composite function catalogs for hook steps - #4063

Merged
sswrk merged 9 commits into
mainfrom
szymonswierk/eng-22387-build-tools-hook-composite-catalog
Aug 3, 2026
Merged

[build-tools][steps] Load composite function catalogs for hook steps#4063
sswrk merged 9 commits into
mainfrom
szymonswierk/eng-22387-build-tools-hook-composite-catalog

Conversation

@sswrk

@sswrk sswrk commented Jul 23, 2026

Copy link
Copy Markdown
Member

Why

Local composite functions can be referenced from hook steps (uses: ./...), but build-tools only builds the composite catalog from job steps.

How

  • Steps-based jobs: eager catalog loag from job steps, pass a lazy loadCompositeFunction loader so hook composites load only when their anchor runs
  • Native jobs: load only from wrapped anchors
  • Warn and skip for registered hook keys whose anchors never appear

Test Plan

Added unit tests.

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

ENG-22387

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.14815% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 62.43%. Comparing base (1b7a876) to head (ca5c2ca).

Files with missing lines Patch % Lines
packages/steps/src/StepsConfigParser.ts 97.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4063      +/-   ##
==========================================
+ Coverage   62.40%   62.43%   +0.03%     
==========================================
  Files        1009     1009              
  Lines       45699    45735      +36     
  Branches     9615     9621       +6     
==========================================
+ Hits        28513    28548      +35     
- Misses      15723    15724       +1     
  Partials     1463     1463              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from b9e011c to eb60cb4 Compare July 23, 2026 16:17
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from eb60cb4 to e2453da Compare July 23, 2026 17:06
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from e2453da to be59908 Compare July 24, 2026 11:43
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from be59908 to e65600c Compare July 24, 2026 11:49
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch 2 times, most recently from 31f42c2 to b5884c9 Compare July 24, 2026 13:02
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from b5884c9 to e810dd3 Compare July 24, 2026 14:12
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from e810dd3 to 2f52da6 Compare July 24, 2026 14:41
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from 2f52da6 to 55401ab Compare July 24, 2026 15:00
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from 55401ab to 078f9c2 Compare July 24, 2026 15:17
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from c302845 to ae26d93 Compare July 30, 2026 16:12
@graphite-app
graphite-app Bot changed the base branch from graphite-base/4063 to main July 30, 2026 16:12
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from ae26d93 to 400067c Compare July 30, 2026 16:12
@sswrk
sswrk marked this pull request as ready for review July 30, 2026 16:26
@sswrk
sswrk requested review from hSATAC and sjchmiela July 30, 2026 16:26

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

Overall this looks good to me, and the native/steps split makes sense. I left a couple of non-blocking inline comments on things I wasn’t sure were intentional.

One separate follow-up: eas workflow:validate only checks composites in job.steps, so references from hooks or defaults.hooks could pass validation and then fail on the worker. Not blocking this PR, but worth tracking.

Comment thread packages/build-tools/src/steps/compositeFunctions.ts Outdated
Comment thread packages/build-tools/src/steps/compositeFunctions.ts Outdated
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from 400067c to f940337 Compare July 31, 2026 10:06
@sswrk

sswrk commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

One separate follow-up: eas workflow:validate only checks composites in job.steps, so references from hooks or defaults.hooks could pass validation and then fail on the worker. Not blocking this PR, but worth tracking.

Thanks for thinking about everything. This is coming in the next PR, I'm also looking into reducing the duplication between build-tools and eas-cli.

@sswrk sswrk changed the title [build-tools] Load composite function catalogs for hook steps [build-tools][steps] Load composite function catalogs for hook steps Jul 31, 2026
@sswrk
sswrk requested a review from hSATAC July 31, 2026 13:37
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from 8fa56f7 to d156a2e Compare July 31, 2026 14:46

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

The lazy loader addresses what I raised last time, and the rejectingLoader() test covers it. Removing hooks from buildCompositeFunctionCatalogAsync also resolves my other comment.

I left one blocking comment in jobHooks.ts about the hook error messages regressing from main. The other three are non-blocking.

Comment thread packages/build-tools/src/common/jobHooks.ts Outdated
Comment thread packages/steps/src/StepsConfigParser.ts Outdated
Comment thread packages/steps/src/StepsConfigParser.ts Outdated
Comment thread packages/steps/src/StepsConfigParser.ts Outdated
@sswrk sswrk added the ai-review Commits pushed to PRs with this label be automatically reviewed. label Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

🤖 AI code review

Decision: Approve with comments

Overall PR risk: Medium. The change modifies existing hook parsing and composite loading behavior. The affected surface is build hook execution for steps and native builds. The main reported risk is that an unknown hook key can write terminal control text to build logs.

🟡 Warning (1)

  • Unknown hook key can inject terminal control textpackages/steps/src/StepsConfigParser.ts:216 (security) · id:cdc3a52d7fd0
    Confidence: Medium — the hook key is logged without sanitization.
    Impact if shipped: Medium — build log output could be spoofed.
    Suggested remediation: Strip or escape ANSI and control characters before logging the hook key.

    Evidence and reasoning

    hooks accepts arbitrary string keys. A PR-controlled workflow can set an unknown hook key with ANSI or control characters.

    parseHookKey returns null for that key. The parser then writes the raw key to the logger.

    Build logs display logger text. A control sequence can alter log display or spoof later output.


This review is advisory — it never blocks a merge and never auto-approves.

@sswrk

sswrk commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Re. AI review:

Hook composite errors lose the hook key

Fair, goes hand in hand with #4063 (comment). Addressed: 060c136

Unknown hook key can spoof terminal output

Leaving this out for now, I think it's not really specific to this PR

@sswrk
sswrk requested a review from hSATAC July 31, 2026 17:38

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

Left one non-blocking inline comment.

Comment thread packages/steps/src/StepsConfigParser.ts Outdated
@sswrk
sswrk force-pushed the szymonswierk/eng-22387-build-tools-hook-composite-catalog branch from 060c136 to ca5c2ca Compare August 3, 2026 11:32
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

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

Labels

ai-review Commits pushed to PRs with this label be automatically reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants