Skip to content

refactor(filters): remove unused getFilter helper - #213

Merged
steipete merged 2 commits into
openclaw:mainfrom
KrasimirKralev:refactor/drop-unused-getfilter
Nov 5, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
KrasimirKralev:refactor/drop-unused-getfilter

Conversation

@KrasimirKralev

@KrasimirKralev KrasimirKralev commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/core/filters.ts exports a getFilter(name) helper that nothing uses.

  • Its definition is its only reference in the repository. applyFilters reads the filter table directly, the template command imports only applyFilters, and the package entry points (., ./sdk, ./core, ./recipes/github) do not re-export anything from core/filters. So the helper is not part of the public API, and no caller can reach it.
  • Scope: only the four lines of getFilter are removed, plus a CHANGELOG line. The filter table, parseFilterExpression, applyFilters and the template command are unchanged.

User Impact

User impact: there is no user-visible change. Template filters (upper, trim, length, join, …) render exactly as before; the module just has one less dead export to maintain.

Why This Change Was Made

It removes dead code from the template filters module. git grep getFilter on upstream/main bfad09a finds only the definition, and the helper has had no caller since commit 60c9765 added the filters. Before deleting it, I checked the published entry points in package.json exports and src/core/index.ts, and neither exposes core/filters. The full suite (pnpm test) passes 742/742 on the branch, and pnpm lint and pnpm typecheck are clean.

Evidence

  • Behavior or issue addressed: template filter rendering through the real CLI stays identical with getFilter removed.
  • Real environment tested: Linux, Node 24.22.2, lobster built from source (tsc) on upstream/main bfad09a and on this branch.
  • Exact steps or command run after this patch: node bin/lobster.js "exec --json 'printf …' | template --text '{{name | trim | upper}} has {{tags | length}} tags: {{tags | join \"/\"}}'", run on both builds, plus grep -c getFilter dist/src/core/filters.js.
  • Evidence after fix:
# before (main bfad09a, built from source)
$ node bin/lobster.js "exec --json 'printf \"[{\\\"name\\\":\\\"  bob  \\\",\\\"tags\\\":[\\\"a\\\",\\\"b\\\"]}]\"' | template --text '{{name | trim | upper}} has {{tags | length}} tags: {{tags | join \"/\"}}'"
[
  "BOB has 2 tags: a/b"
]
exit=0
$ grep -c getFilter dist/src/core/filters.js
1

# after (this branch, built from source)
$ node bin/lobster.js "exec --json 'printf \"[{\\\"name\\\":\\\"  bob  \\\",\\\"tags\\\":[\\\"a\\\",\\\"b\\\"]}]\"' | template --text '{{name | trim | upper}} has {{tags | length}} tags: {{tags | join \"/\"}}'"
[
  "BOB has 2 tags: a/b"
]
exit=0
$ grep -c getFilter dist/src/core/filters.js
0

$ git grep -n getFilter upstream/main
src/core/filters.ts:48:export function getFilter(name: string): FilterFn | undefined {
  • Observed result after fix: running node bin/lobster.js with a chained trim | upper, length and join template prints the same output before and after, and the built module no longer contains getFilter.
  • What was not tested: consumers outside this repository that might import the private dist/src/core/filters.js path directly; it is not a published entry point.
  • Proof limitations or environment constraints: none.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T06:30:58.847580Z 5a4c4d9 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR deletes the unused getFilter helper and adds an Unreleased changelog entry.

Example: Render name " bob " and tags ["a", "b"] using trim, upper, length and join filters.

  • Before: The CLI prints "BOB has 2 tags: a/b".
  • After: The CLI prints "BOB has 2 tags: a/b".

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal, source-verified cleanup supported by relevant shipped CLI output and successful checks on the reviewed head.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied terminal trace exercises the real built CLI on Linux with chained filters before and after removal, shows identical rendered output, and confirms the helper is absent from the resulting module.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintenance benefit is modest but clear: remove a verified unused internal export with a four-line deletion and no replacement machinery or public contract change.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it removes a verified unused internal helper that remains on current main, with no actionable correctness or security findings.

Priority: P3
Reviewed head: 0b674bc487cf14210b22470f7da3dce68eb2e010

Before merge

None.

Findings

None.

Agent review details

How this fits together

The template command receives pipeline items, resolves template fields, applies named filters from an internal table, and emits rendered strings.

flowchart LR
A[Pipeline items] --> B[Template command]
B --> C[Field resolution]
C --> D[applyFilters]
D --> E[Internal filter table]
E --> F[Rendered strings]
Loading

Technical review

Best possible solution:

Land the focused deletion while preserving the existing filter table and template execution path.

Do we have a high-confidence way to reproduce the issue?

There is no reported runtime bug; source inspection confirms that getFilter is unused and remains present on current main.

Is this the best way to solve the issue?

Deleting the unused helper is the smallest complete cleanup because existing callers already use applyFilters directly.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bfad09a49747.

Provenance checked

  • Internal getFilter helper changes intended behavior with a stated reason (60c9765: The template-filter feature commit added both the lookup helper and direct table access in applyFilters; no separate requirement for the helper was found.)
  • Unreleased changelog section keeps the original intent (85307ff: The release preparation retained finalized notes and restored an empty Unreleased section for subsequent changes.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Exact introduced change: The pinned diff removes only the four-line getFilter declaration and adds two changelog lines; filter execution is unchanged. (src/core/filters.ts:48, 0b674bc487cf)
  • Current-main callers and package boundary: On main, getFilter occurs only at its declaration; the template command imports applyFilters, which accesses FILTERS directly. Package exports and their entry modules do not expose the filters module. (package.json:37, bfad09a49747)
  • Original filter implementation: The original filter implementation already had applyFilters read the table directly alongside getFilter. Local history identifies the feature commit; some historical parent blobs are unavailable, but the original filters blob is readable. (src/core/filters.ts:48, 60c976571a4d)
  • Supplied shipped CLI proof: The PR body supplies Linux Node 24 before-and-after terminal output through node bin/lobster.js: chained trim/upper, length and join produce identical output, while the built getFilter occurrence disappears. (0b674bc487cf)
  • Feature-history contributor: The author previously contributed merged characterization coverage for this filter engine in test(filters): cover template filter boundary and error-path branches #137; those tests cover parsing, boundary values and error paths without changing runtime behavior. (test/template_filters.test.ts:132, d1cf4eae41e3)
  • Policy applied: Read the complete root AGENTS.md; no nested src AGENTS.md, maintainer-notes directory or pr-simplify skill was present. Direct read-only inspection fits its one-off shell guidance. (AGENTS.md:1, 0b674bc487cf)

Labels

Label changes:

  • add P3: This is a small internal dead-code cleanup with no intended user-visible behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a small internal dead-code cleanup with no intended user-visible behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 12:45 PM ET / 16:45 UTC.

@steipete
steipete merged commit cf0e95c into openclaw:main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants