← Back to Pull requests

fix(plugins): catalog plugins stop tripping scanner false positives (public PostHog key, own /proc reads, documented imports); validator now flags committed .pyc, private core calls and raw Desktop bridge #146352

Merged
teknium1 merged 9 files (402 lines) on Oct 29, 2026 06:07 UTC
View on GitHub
teknium1 teknium1 commented on Oct 29, 2026 05:20 UTC
Author

A catalog plugin shipping a public PostHog key no longer gets hard-blocked. Reading its own cgroup/mountinfo no longer needs confirmation. The validator stops warning on the documented get_session_env route and on a plugin's fallback import of its own path. Three gaps that let a real violation through admission green are closed: committed .pyc, private-method calls on core objects, and raw Desktop bridge / app markup reach.

Every row was found in plugin catalog sweep 1028 and reproduced on origin/main against a frozen copy of the real pinned tree, then re-run on this branch.

Before / after (real pinned trees)

| Class | Plugin (pin) | main | this branch |
|---|---|---|---|
| 1. hardcoded_secret on a public PostHog project key (phc_) | telesec 74d2d97a (telemetry.py:27) | dangerous (critical, install blocked even with --force) | caution (high, reviewable) |
| 2. proc_access on its own /proc/self/cgroup, mountinfo | hermes-lcm-x 1a137444 (cpu_capacity.py:25,29) | caution (2× high) | safe (2× low, still listed) |
| 3. private-import warning on the documented gateway.session_context.get_session_env | onebot-platform 086dd7e5 (tools.py:28), hermes-lcm-x (__init__.py:156) | warned | not warned |
| 3. private-import warning on the plugin's fallback import of its own path | openltm 8ee2a8e4 / 91f77925 (plugins.memory.openltm._db) | warned | not warned |
| 4a. private-method calls on core handles (gap) | opencode-sync 6fcc8284 (db._execute_write, db._read_ctx, runner._evict_cached_agent, …) | silent | warns, 10 sites |
| 4b. raw window.hermesDesktop. / app markup selectors (gap) | squad-hub 2695b147, novel-reader d6236943, search-sources 27e9502a | silent | desktop surface review warning |
| 4c. committed .pyc (rule 17, gap) | hermes-emotion 3cb05766 (tests/__pycache__/
.pyc) | safe | caution (bytecode_file high) |

4a note: function-scope from hermes_cli… import _private was already caught on main. The sweep saw only client.py:28,69 because the warning shows the first 10 sites. What no import check could see was the private-method calls on the SessionDB/GatewayRunner objects the plugin is handed.

What changed

Install scanner (tools/plugin_guard.py; PLUGIN_SCANNER_VERSION bumped once):

  • is_public_client_key replaces the Google-only GOCSPX- predicate and also covers PostHog phc_. It applies only when every hardcoded_secret literal on the line has a public prefix. A phx_ personal key, or a real token next to the public key, stays critical.

  • is_own_proc_read lowers proc_access to low (still reported) when every /proc/self|<pid>/<leaf> on the logical line is in a scheduling/placement set: cgroup, mountinfo, mounts, stat, statm, status, limits, io, comm, cpuset, sched, schedstat, oom_score, and nothing writes it. environ, cmdline, mem, maps, fd, root/cwd, ns, a bare /proc/self, any unlisted leaf and any write all keep high. This salvages #144304 by @Sahilvishnaliya (cherry-picked, authorship kept). The trim changed one thing: the finding is lowered instead of dropped. #144304 can close when this lands.

  • bytecode_file (high, the same level as a bundled binary) fires on .pyc/.pyo that git ls-files tracks, and on bytecode outside __pycache__ (CPython 3 never writes it there). The untracked __pycache__ that hermes plugins validate writes when it imports the plugin is not flagged. CI's scan_plugin_payloads.py step already refused these. Now the install scanner and the validator see them too.
  • Validator (hermes plugins validate; warnings only, never failures):

  • _PUBLIC += gateway.session_context:get_session_env, which website/docs/developer-guide/plugins/index.md tells authors to use.

  • Own install path: a Hermes-shaped module that core does not ship, whose tail is one of the plugin's own modules, counts as local. A path core does ship is still flagged.

  • private core attribute access: warns on private methods of the core handle classes (hermes_state, run_agent/agent/turn_, gateway/run, hermes_cli/plugins.py) that the plugin does not define itself. self/cls receivers and test files are excluded.

  • desktop surface review: warns on window.hermesDesktop and on [data-slot|tour|sidebar|testid|tree-*|pane-host|titlebar-cluster] selectors in CSS text, closest() or templates. Lines the existing refusal already covers are skipped, and so are comments. These are warnings, not refusals, because listed pins (hermes-talk, search-sources, novel-reader, hermes-plexus) still use the bridge where the SDK has no verb (microphone access, favicon lookup). A refusal would brick them on their next bump.

  • Rule 8 / 9 text in plugin-catalog/README.md and its mirror in catalog-submission.md now names the two new warnings.
  • Validation

  • Catalog pin sweep, main vs branch (219 pinned trees from sweep 1028; scanner verdict, validator warnings, desktop check):

  • - 2 better: telesec dangerous→caution; hermes-lcm-x caution→safe.
    - 1 moved to caution: hermes-emotion. That is the intended rule-17 detection (class 4c). The tracked .pyc is the same file the review already asked the author to remove.
    - 0 other verdict changes. The desktop refusal check moved on no pin.
    - New warnings land only on the plugins named above, plus same-shape hits: hermes-whatsapp-voice (GatewayRunner._load_fallback_model), and asgard/kemet/pantheon, prompt-enhancer, provider-status, minimalist-themes, canadian-primary-care, hermes-plexus, hermes-talk ([data-slot]/[data-tree-group] CSS, window.hermesDesktop).
  • In-tree sweep (skills/, optional-skills/, plugins/, 308 entries): 0 findings changed.

  • Attack-probe A/B (the scanner skill's executable-shape probes plus 23 new ones for these classes, each run on both trees): the branch is weaker on 0 attack rows. Changed rows: phc_ alone dangerous→caution, /proc/self/cgroup and grep /proc/1/cgroup caution→safe/low, tracked or loose .pyc safe→caution. Unchanged on purpose:

  • - /proc/self/environ, /proc/1/environ, /proc/1/cmdline, mem, maps, fd, cwd, /proc/1/ns/mnt, a bare /proc/self, cgroup+environ on one line, and writes or redirects into /proc all stay high.
    - /proc/1/root/... stays critical.
    - A phx_ key, phc_ next to a real token, and xphc_… all stay critical.
    - An untracked __pycache__ stays safe.
  • scripts/run_tests.sh over test_plugin_guard.py, test_plugin_guard_block_reason.py, test_skills_guard.py, test_skills_guard_agent_config.py, test_threat_patterns.py, test_plugin_validate.py, test_plugin_validate_private_imports.py, test_plugin_validate_locales.py: 381 passed. tests/website/test_catalog_rules_mirror.py passed.

  • The 5 new behaviour tests fail on origin/main and pass here; the 9 attack-twin cases pass on both. Per behaviour: one benign shape, one attack twin.

  • python scripts/check (13 checks, incl. health): ok.
  • Infographic

    !scanner-fps-1028

    Diff: 402 lines (+355 / -47) across 9 files Reviewer: teknium1 Review duration: 46m
    All Vouch review confidence checks passed
    Residual risk 0.10 = Change Risk (0.70) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.70 · 402 lines diff across 9 files
    0.70
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.94 · 5 substantive comment(s)
    0.94
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    85%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Self Review self_review
    0.140
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    11 items
    github-actions[bot] github-actions[bot] commented on Oct 29, 2026 05:21 UTC
    Bot

    <!-- hermes-ci-review-bot -->

    ૮ >ﻌ< ა ci review

    <sub>ran on 0316d51 — fix(plugins): quoted /proc redirects stay writes; own-module</sub>

    ℹ️ Info

    CI caches · View report · View job

    27 / 27 cache hits (0 misses)
    4682.14 MiB restored
    0 B not restored.

    <details>
    <summary>per-job cache results</summary>

    <h3>hits</h3>

    <table><thead><tr><th>Job</th><th>Step</th><th>Logs</th><th>Restored</th><th>Δ vs main</th></tr></thead><tbody>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827875#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827875#step:4:1">view step</a></td><td>165.04 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827875#step:4:1">view step</a></td><td>841.49 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827939#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827939#step:4:1">view step</a></td><td>165.04 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827939#step:4:1">view step</a></td><td>841.49 MiB</td><td>+0 B</td></tr>
    <tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827459#step:4:1">view step</a></td><td>131.51 MiB</td><td>+0 B</td></tr>
    <tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827459#step:4:1">view step</a></td><td>67.42 MiB</td><td>+0 B</td></tr>
    <tr><td>Icon assets freshness / Regenerate icons + diff against committed</td><td>Run ./.github/actions/setup-pm / Restore npm dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827459#step:4:1">view step</a></td><td>351.86 MiB</td><td>+0 B</td></tr>
    <tr><td>Docs Site / docs-site-checks</td><td>Set up the locked site toolchain / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827395#step:4:1">view step</a></td><td>131.51 MiB</td><td>+0 B</td></tr>
    <tr><td>Docs Site / docs-site-checks</td><td>Set up the locked site toolchain / Restore npm dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827395#step:4:1">view step</a></td><td>370.98 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827639#step:5:1">view step</a></td><td>80.78 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827639#step:5:1">view step</a></td><td>67.42 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (2/2)</td><td>Run tests</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827639#step:8:1">view step</a></td><td>0.08 MiB</td><td>unknown</td></tr>
    <tr><td>Python lints / ruff + ty diff</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827699#step:4:1">view step</a></td><td>80.78 MiB</td><td>unknown</td></tr>
    <tr><td>Python lints / code health ratchet (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827717#step:4:1">view step</a></td><td>80.78 MiB</td><td>unknown</td></tr>
    <tr><td>Python lints / Windows footguns (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827725#step:4:1">view step</a></td><td>80.78 MiB</td><td>+0 B</td></tr>
    <tr><td>Python lints / ruff enforcement (blocking)</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827785#step:4:1">view step</a></td><td>80.78 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827723#step:5:1">view step</a></td><td>80.78 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827723#step:5:1">view step</a></td><td>67.42 MiB</td><td>+0 B</td></tr>
    <tr><td>Python tests / Run tests (1/2)</td><td>Restore per-file duration cache</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827723#step:7:1">view step</a></td><td>0.08 MiB</td><td>unknown</td></tr>
    <tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827756#step:5:1">view step</a></td><td>42.23 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827756#step:5:1">view step</a></td><td>153.05 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827790#step:5:1">view step</a></td><td>42.23 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827790#step:5:1">view step</a></td><td>153.05 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827867#step:5:1">view step</a></td><td>171.66 MiB</td><td>+0 B</td></tr>
    <tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/40825895366/job/123288827867#step:5:1">view step</a></td><td>381.39 MiB</td><td>+0 B</td></tr>
    </tbody></table>

    <h3>misses</h3>

    none

    <p>Compressed archive bytes. Not-restored bytes use the main-size reference; missing sizes remain unknown.</p>

    </details>

    ---

    debug info

    <details>
    <summary>CI timings</summary>

    CI timings · View report · View job

    Wall time 7m56s vs 7m50s (+1.3%). 11 job(s) slower, 7 faster, 1 unchanged.

  • OS-specific tests / Windows-only tests (arm64, 1/2): -136.0s

  • OS-specific tests / Windows-only tests: +52.0s

  • OS-specific tests / macOS-only tests (2/2): +48.0s

  • Python lints / Windows footguns (blocking): +17.0s

  • OS-specific tests / Windows-only tests (arm64, 2/2): -12.0s
  • </details>

    greptile-apps[bot] greptile-apps[bot] commented on Oct 29, 2026 05:27 UTC
    Bot

    <!-- greptile_summary -->

    <h2><a href="https://app.greptile.com/api/retrigger?id=90349773"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/nous-research/github/NousResearch/hermes-agent/-/pull/146352?utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 3/5</h2>

    [Medium impact] The changes affect plugin install decisions and catalog review warnings\.

    Fix the process-write demotion and satisfy the test-file size requirement before merging.

    <h2>Findings</h2>

    1. <img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top">&nbsp;<img alt="Security" src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2" align="top">&nbsp;Process writes skip confirmation <a href="https://github.com/NousResearch/hermes-agent/pull/146352#discussion_r4408998304">▶</a>
    2. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Test file exceeds size limit <a href="https://github.com/NousResearch/hermes-agent/pull/146352#discussion_r4408998300">▶</a>
    3. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top">&nbsp;Own imports still warn <a href="https://github.com/NousResearch/hermes-agent/pull/146352#discussion_r4408998312">▶</a>

    <details><summary>Fix with agent prompt</summary>

    `

    ### Issue 1
    tools/plugin_guard_context.py:791-792
    The new read-only exemption accepts writes that `_PROC_WRITE` misses. For example, `printf worker > "/proc/self/comm"` passes because `comm` is allowed but the redirect check requires an unquoted path. Likewise, `open("/proc/self/comm", "r+")` passes because the mode check misses modes starting with `r`.
    
    These findings now fall from `high` to `low`, so an otherwise clean plugin installs without confirmation. Require a recognized read shape before lowering the finding, and add both cases as attack twins.
    
    **How this was verified:** The allowed-leaf check accepts `comm`, the write matcher misses quoted redirects and `r+`, and low-only findings produce a `safe` verdict that installs without confirmation.
    
    ### Issue 2
    tests/tools/test_plugin_guard.py:973-975
    These additions grow `tests/tools/test_plugin_guard.py` from 967 to 1,030 lines. The repository requires decomposition before crossing 1,000 lines unless there is a strong structural reason. Move `TestProcKeyAndBytecodeShapes` into a focused sibling test file and share only the fixture helpers it needs. This repository requirement must be satisfied before merging.
    
    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
    
    ### Issue 3
    hermes_cli/plugin_validate_private_imports.py:132-133
    The own-module exemption misses the normal `from` spelling. With the `__init__.py` and `_db.py` layout in the new test, `from plugins.memory.openltm import _db` still warns. `_imported` passes `plugins.memory.openltm` as `module`, and `_is_own_module_path` never checks the imported `_db` name. The equivalent `import plugins.memory.openltm._db as _db` is exempt.
    
    This leaves authors with a false private-core warning. Resolve the full imported target against the plugin's files while preserving warnings for real core paths, and test both spellings.
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    

    </details>

    <details><summary><h3>Summary</h3></summary>

    The PR adjusts plugin scan results and adds admission warnings.

  • Plugin scans distinguish public client keys, routine /proc` reads, and shipped bytecode.

  • Plugin validation recognizes public imports and warns about private calls on core objects.

  • Desktop validation warns reviewers about raw bridge calls and app markup selectors.

  • </details>

    <!-- greptile_confidence_score:3 -->

    <sub>Reviews (1) · Last reviewed commit: "fix(plugins): clear catalog sweep 1028 s..." · Reviewed by Greptile</sub>

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 29, 2026 05:27 UTC
    Code Review
    tests/tools/test_plugin_guard.py:1
    @@ -961,5 +962,69 @@ def test_attack_twin_still_flags(self, tmp_path, rel, text, pattern_id):
     
         def test_scanner_version_contract(self):
             # A bump un-blocks previously-quarantined packages; assert the contract (changed), not a literal.
    -        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v10"
    +        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v11"
             assert PLUGIN_SCANNER_VERSION.startswith("plugin-guard-v")
    +
    +
    +# Built at runtime so no full vendor-shaped key sits in the source (forge secret scanning).
    +_FAKE_KEY_BODY = "Ab3" * 14 + "x"
    +
    +
    +class TestProcKeyAndBytecodeShapes:
    +    """Shapes real catalog pins tripped (telesec, hermes-lcm-x, hermes-emotion), each next to the
    +    attack twin that must keep its severity."""

    <a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Test file exceeds size limit

    These additions grow tests/tools/test_plugin_guard.py from 967 to 1,030 lines. The repository requires decomposition before crossing 1,000 lines unless there is a strong structural reason. Move TestProcKeyAndBytecodeShapes into a focused sibling test file and share only the fixture helpers it needs. This repository requirement must be satisfied before merging.

    Context Used: Perform a deep code quality audit of the current branch's changes. Rethink how to structure / implement the changes to meaningfully improve code quality without impacting behavior. Work to improve abstractions, modularity, reduce Spaghetti code, impr... (source)

    <details><summary>Prompt To Fix With AI</summary>

    `

    This is a comment left during a code review.
    Path: tests/tools/test_plugin_guard.py
    Line: 973-975
    
    Comment:
    **Test file exceeds size limit**
    
    These additions grow `tests/tools/test_plugin_guard.py` from 967 to 1,030 lines. The repository requires decomposition before crossing 1,000 lines unless there is a strong structural reason. Move `TestProcKeyAndBytecodeShapes` into a focused sibling test file and share only the fixture helpers it needs. This repository requirement must be satisfied before merging.
    
    **Context Used:** Perform a deep code quality audit of the current branch's changes. Rethink how to structure / implement the changes to meaningfully improve code quality without impacting behavior. Work to improve abstractions, modularity, reduce Spaghetti code, impr... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    
    `
    </details>

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 29, 2026 05:27 UTC
    Code Review
    tools/plugin_guard_context.py:1
    @@ -760,16 +760,44 @@ def is_coin_name_only(finding: Finding, line: str) -> bool:
         return bool(hits) and all(_is_standalone_coin_name(line, h.start(), h.end()) for h in hits)
     
     
    -# Google mints installed-app (desktop/CLI) OAuth clients with a ``GOCSPX-`` secret that its OAuth
    -# docs say cannot be kept confidential: every copy of the app ships it (gcloud does). A plugin is
    -# such an app, so the literal identifies a public client rather than leaking a credential; it stays
    -# in the report for review (caution) instead of hard-blocking the install.
    -_GOOGLE_PUBLIC_CLIENT_SECRET = re.compile(r'["\']GOCSPX-[A-Za-z0-9_-]{20,}["\']')
    -
    -
    -def is_google_installed_app_secret(finding: Finding, line: str) -> bool:
    -    """A ``hardcoded_secret`` hit whose literal is a Google installed-app OAuth client secret."""
    -    return finding.pattern_id == "hardcoded_secret" and bool(_GOOGLE_PUBLIC_CLIENT_SECRET.search(line))
    +# Key shapes the vendor documents as public, shipped in every copy of a client: a Google
    +# installed-app (desktop/CLI) OAuth client secret (``GOCSPX-``, gcloud ships one) and a PostHog
    +# project API key (``phc_``, a write-only ingest key every web page embeds). The literal identifies
    +# a client rather than leaking a credential, so it stays in the report for review (caution) instead
    +# of hard-blocking the install. Only when EVERY ``hardcoded_secret`` literal on the line has one of
    +# these prefixes: a PostHog personal key (``phx_``) or any other token beside it keeps critical.
    +_PUBLIC_CLIENT_KEY_PREFIXES = ("GOCSPX-", "phc_")
    +_SECRET_LITERAL = re.compile(r'[=:]\s*["\']([A-Za-z0-9+/=_-]{20,})')
    +
    +
    +def is_public_client_key(finding: Finding, line: str) -> bool:
    +    """A ``hardcoded_secret`` hit whose every matched literal is a public-by-design client key."""
    +    if finding.pattern_id != "hardcoded_secret":
    +        return False
    +    literals = [_SECRET_LITERAL.search(m.group(0)) for m in _PATTERN_BY_ID["hardcoded_secret"].finditer(line)]
    +    return bool(literals) and all(
    +        lit is not None and lit.group(1).startswith(_PUBLIC_CLIENT_KEY_PREFIXES) for lit in literals)
    +
    +
    +# ``/proc/self/<leaf>`` and ``/proc/<pid>/<leaf>`` files that describe scheduling and container
    +# placement (cgroup membership, mount layout, start time in ``stat``, limits): container CPU-quota
    +# detection and pid-reuse checks read them. A read of one of these is not process introspection.
    +# The leaves that leak or reach another process keep ``high``: ``environ``, ``cmdline``, ``mem``,
    +# ``maps``, ``fd``, ``root``/``cwd`` (procfs escape into the host tree), ``exe``, ``ns`` and any
    +# leaf not listed, as do a bare ``/proc/self`` and any write.
    +_BENIGN_PROC_LEAVES = frozenset({
    +    "cgroup", "mountinfo", "mounts", "stat", "statm", "status", "limits", "io", "comm", "cpuset",
    +    "sched", "schedstat", "oom_score"})
    +_PROC_PATH = re.compile(r"/proc/(?:self|\d+)(?:/([\w.-]*))?")
    +_PROC_WRITE = re.compile(r"write_text|write_bytes|\.write\s*\(|open\s*\([^)]*['\"][wax+]|>\s*/proc/|\btee\b")

    <a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> <a href="#"><img alt="security" src="https://greptile-static-assets.s3.amazonaws.com/badges/Security.svg?v=2" align="top"></a> Process writes skip confirmation

    The new read-only exemption accepts writes that _PROC_WRITE misses. For example, printf worker > "/proc/self/comm" passes because comm is allowed but the redirect check requires an unquoted path. Likewise, open("/proc/self/comm", "r+") passes because the mode check misses modes starting with r.

    These findings now fall from high to low, so an otherwise clean plugin installs without confirmation. Require a recognized read shape before lowering the finding, and add both cases as attack twins.

    How this was verified: The allowed-leaf check accepts comm, the write matcher misses quoted redirects and r+, and low-only findings produce a safe verdict that installs without confirmation.

    <details><summary>Prompt To Fix With AI</summary>

    `

    This is a comment left during a code review.
    Path: tools/plugin_guard_context.py
    Line: 791-792
    
    Comment:
    **Process writes skip confirmation**
    
    The new read-only exemption accepts writes that `_PROC_WRITE` misses. For example, `printf worker > "/proc/self/comm"` passes because `comm` is allowed but the redirect check requires an unquoted path. Likewise, `open("/proc/self/comm", "r+")` passes because the mode check misses modes starting with `r`.
    
    These findings now fall from `high` to `low`, so an otherwise clean plugin installs without confirmation. Require a recognized read shape before lowering the finding, and add both cases as attack twins.
    
    **How this was verified:** The allowed-leaf check accepts `comm`, the write matcher misses quoted redirects and `r+`, and low-only findings produce a `safe` verdict that installs without confirmation.
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    
    `
    </details>

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 29, 2026 05:27 UTC
    Code Review
    hermes_cli/plugin_validate_private_imports.py:1
    @@ -111,30 +113,52 @@ def _imported(node: ast.AST) -> list[tuple[str, str]]:
         return []
     
     
    +@lru_cache(maxsize=512)
    +def _core_module_exists(module: str) -> bool:
    +    path = Path(__file__).resolve().parents[1].joinpath(*module.split("."))
    +    return path.with_suffix(".py").is_file() or path.is_dir()
    +
    +
    +def _is_own_module_path(module: str, local: set[str]) -> bool:
    +    """A Hermes-shaped path that core does not ship but whose tail is one of the plugin's own modules:
    +    the fallback spelling of the plugin's install location (``plugins.memory.openltm._db`` beside
    +    ``from . import _db``). A path core DOES ship stays a core import."""
    +    parts = module.split(".")
    +    return any(".".join(parts[i:]) in local for i in range(1, len(parts))) and not _core_module_exists(module)
    +
    +
     def _private_target(module: str, name: str, core: frozenset, local: set[str]) -> str:
         """The dotted target to report, or "" when the import is public, local or not Hermes's."""
         target = f"{module}.{name}" if name else module
    -    hermes = module.split(".")[0] in core and module not in local
    +    hermes = module.split(".")[0] in core and module not in local and not _is_own_module_path(module, local)

    <a href="#"><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> Own imports still warn

    The own-module exemption misses the normal from spelling. With the __init__.py and _db.py layout in the new test, from plugins.memory.openltm import _db still warns. _imported passes plugins.memory.openltm as module, and _is_own_module_path never checks the imported _db name. The equivalent import plugins.memory.openltm._db as _db is exempt.

    This leaves authors with a false private-core warning. Resolve the full imported target against the plugin's files while preserving warnings for real core paths, and test both spellings.

    <details><summary>Prompt To Fix With AI</summary>

    `

    This is a comment left during a code review.
    Path: hermes_cli/plugin_validate_private_imports.py
    Line: 132-133
    
    Comment:
    **Own imports still warn**
    
    The own-module exemption misses the normal `from` spelling. With the `__init__.py` and `_db.py` layout in the new test, `from plugins.memory.openltm import _db` still warns. `_imported` passes `plugins.memory.openltm` as `module`, and `_is_own_module_path` never checks the imported `_db` name. The equivalent `import plugins.memory.openltm._db as _db` is exempt.
    
    This leaves authors with a false private-core warning. Resolve the full imported target against the plugin's files while preserving warnings for real core paths, and test both spellings.
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
    
    `
    </details>

    blacksmith-sh[bot] blacksmith-sh[bot] commented on Oct 29, 2026 05:28 UTC
    Bot

    <!-- Blacksmith CI Status -->
    Found 1 test failure on Blacksmith runners:

    Failure

    | Test | View Logs |
    | --- | --- |
    | <code>test_authority_route_runs_a_wake_receipted_before_drain_once_after_restart[idle]</code> | View Logs |

    <a href="https://app.blacksmith.sh/NousResearch/codesmith/hermes-agent/pr/146352?prompt=Repository%3A+NousResearch%2Fhermes-agent%0ABranch%3A+fix%2Fcatalog-scanner-fps-1028%0APR%3A+%23146352%0A%0AFix+these+failing+tests%3A%0A%0A1.+test_authority_route_runs_a_wake_receipted_before_drain_once_after_restart%5Bidle%5D%0A&amp;entry=pr_comment&amp;ref=gh_comment&amp;autoLogin=true&amp;autoSend=true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light.svg"><img alt="Fix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-3x.png" width="149" height="28"></picture></a>
    <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    teknium1 teknium1 commented on code on Oct 29, 2026 05:52 UTC
    Code Review
    tests/tools/test_plugin_guard.py:1
    @@ -961,5 +962,69 @@ def test_attack_twin_still_flags(self, tmp_path, rel, text, pattern_id):
     
         def test_scanner_version_contract(self):
             # A bump un-blocks previously-quarantined packages; assert the contract (changed), not a literal.
    -        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v10"
    +        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v11"
             assert PLUGIN_SCANNER_VERSION.startswith("plugin-guard-v")
    +
    +
    +# Built at runtime so no full vendor-shaped key sits in the source (forge secret scanning).
    +_FAKE_KEY_BODY = "Ab3" * 14 + "x"
    +
    +
    +class TestProcKeyAndBytecodeShapes:
    +    """Shapes real catalog pins tripped (telesec, hermes-lcm-x, hermes-emotion), each next to the
    +    attack twin that must keep its severity."""

    Not changing this one: the repo ratchet caps files at 2,000 lines (scripts/code_health/config.py), and this test file sits at ~1,030, well under it. Splitting the class out would only move code around.

    teknium1 teknium1 commented on code on Oct 29, 2026 05:52 UTC
    Code Review
    tools/plugin_guard_context.py:1
    @@ -760,16 +760,44 @@ def is_coin_name_only(finding: Finding, line: str) -> bool:
         return bool(hits) and all(_is_standalone_coin_name(line, h.start(), h.end()) for h in hits)
     
     
    -# Google mints installed-app (desktop/CLI) OAuth clients with a ``GOCSPX-`` secret that its OAuth
    -# docs say cannot be kept confidential: every copy of the app ships it (gcloud does). A plugin is
    -# such an app, so the literal identifies a public client rather than leaking a credential; it stays
    -# in the report for review (caution) instead of hard-blocking the install.
    -_GOOGLE_PUBLIC_CLIENT_SECRET = re.compile(r'["\']GOCSPX-[A-Za-z0-9_-]{20,}["\']')
    -
    -
    -def is_google_installed_app_secret(finding: Finding, line: str) -> bool:
    -    """A ``hardcoded_secret`` hit whose literal is a Google installed-app OAuth client secret."""
    -    return finding.pattern_id == "hardcoded_secret" and bool(_GOOGLE_PUBLIC_CLIENT_SECRET.search(line))
    +# Key shapes the vendor documents as public, shipped in every copy of a client: a Google
    +# installed-app (desktop/CLI) OAuth client secret (``GOCSPX-``, gcloud ships one) and a PostHog
    +# project API key (``phc_``, a write-only ingest key every web page embeds). The literal identifies
    +# a client rather than leaking a credential, so it stays in the report for review (caution) instead
    +# of hard-blocking the install. Only when EVERY ``hardcoded_secret`` literal on the line has one of
    +# these prefixes: a PostHog personal key (``phx_``) or any other token beside it keeps critical.
    +_PUBLIC_CLIENT_KEY_PREFIXES = ("GOCSPX-", "phc_")
    +_SECRET_LITERAL = re.compile(r'[=:]\s*["\']([A-Za-z0-9+/=_-]{20,})')
    +
    +
    +def is_public_client_key(finding: Finding, line: str) -> bool:
    +    """A ``hardcoded_secret`` hit whose every matched literal is a public-by-design client key."""
    +    if finding.pattern_id != "hardcoded_secret":
    +        return False
    +    literals = [_SECRET_LITERAL.search(m.group(0)) for m in _PATTERN_BY_ID["hardcoded_secret"].finditer(line)]
    +    return bool(literals) and all(
    +        lit is not None and lit.group(1).startswith(_PUBLIC_CLIENT_KEY_PREFIXES) for lit in literals)
    +
    +
    +# ``/proc/self/<leaf>`` and ``/proc/<pid>/<leaf>`` files that describe scheduling and container
    +# placement (cgroup membership, mount layout, start time in ``stat``, limits): container CPU-quota
    +# detection and pid-reuse checks read them. A read of one of these is not process introspection.
    +# The leaves that leak or reach another process keep ``high``: ``environ``, ``cmdline``, ``mem``,
    +# ``maps``, ``fd``, ``root``/``cwd`` (procfs escape into the host tree), ``exe``, ``ns`` and any
    +# leaf not listed, as do a bare ``/proc/self`` and any write.
    +_BENIGN_PROC_LEAVES = frozenset({
    +    "cgroup", "mountinfo", "mounts", "stat", "statm", "status", "limits", "io", "comm", "cpuset",
    +    "sched", "schedstat", "oom_score"})
    +_PROC_PATH = re.compile(r"/proc/(?:self|\d+)(?:/([\w.-]*))?")
    +_PROC_WRITE = re.compile(r"write_text|write_bytes|\.write\s*\(|open\s*\([^)]*['\"][wax+]|>\s*/proc/|\btee\b")

    Fixed in 0316d515: a quoted redirect (printf x > "/proc/self/comm") now counts as a write, and r+ / rb+ / os.open(..., O_WRONLY|O_RDWR) were already covered in 2e093bfd. Added both as attack twins; each one fails on the earlier head and passes now.

    teknium1 teknium1 commented on code on Oct 29, 2026 05:52 UTC
    Code Review
    hermes_cli/plugin_validate_private_imports.py:1
    @@ -111,30 +113,52 @@ def _imported(node: ast.AST) -> list[tuple[str, str]]:
         return []
     
     
    +@lru_cache(maxsize=512)
    +def _core_module_exists(module: str) -> bool:
    +    path = Path(__file__).resolve().parents[1].joinpath(*module.split("."))
    +    return path.with_suffix(".py").is_file() or path.is_dir()
    +
    +
    +def _is_own_module_path(module: str, local: set[str]) -> bool:
    +    """A Hermes-shaped path that core does not ship but whose tail is one of the plugin's own modules:
    +    the fallback spelling of the plugin's install location (``plugins.memory.openltm._db`` beside
    +    ``from . import _db``). A path core DOES ship stays a core import."""
    +    parts = module.split(".")
    +    return any(".".join(parts[i:]) in local for i in range(1, len(parts))) and not _core_module_exists(module)
    +
    +
     def _private_target(module: str, name: str, core: frozenset, local: set[str]) -> str:
         """The dotted target to report, or "" when the import is public, local or not Hermes's."""
         target = f"{module}.{name}" if name else module
    -    hermes = module.split(".")[0] in core and module not in local
    +    hermes = module.split(".")[0] in core and module not in local and not _is_own_module_path(module, local)

    Fixed in 0316d515: the own-module check now also matches the full module.name target, so from plugins.memory.openltm import _db is exempt the same way the import ... as _db spelling is. The test covers both spellings, and a real core import beside them still warns. The test fails on the earlier head.

    greptile-apps[bot] greptile-apps[bot] commented on code on Oct 29, 2026 05:53 UTC
    Code Review
    tests/tools/test_plugin_guard.py:1
    @@ -961,5 +962,69 @@ def test_attack_twin_still_flags(self, tmp_path, rel, text, pattern_id):
     
         def test_scanner_version_contract(self):
             # A bump un-blocks previously-quarantined packages; assert the contract (changed), not a literal.
    -        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v10"
    +        assert PLUGIN_SCANNER_VERSION != "plugin-guard-v11"
             assert PLUGIN_SCANNER_VERSION.startswith("plugin-guard-v")
    +
    +
    +# Built at runtime so no full vendor-shaped key sits in the source (forge secret scanning).
    +_FAKE_KEY_BODY = "Ab3" * 14 + "x"
    +
    +
    +class TestProcKeyAndBytecodeShapes:
    +    """Shapes real catalog pins tripped (telesec, hermes-lcm-x, hermes-emotion), each next to the
    +    attack twin that must keep its severity."""

    You’re right. scripts/code_health/config.py sets the file limit at 2,000 lines, and the root guidance does not impose a 1,000-line threshold. At ~1,030 lines, this file is below the configured cap; my comment overstated the repository requirement. No split is warranted on that basis, so I’d withdraw the comment.

    Should I remember this review rule: verify the repo’s configured file-size ratchet before requesting a test-file split?

    Reviewers
    Assignees
    teknium1 teknium1
    Labels
    risk: low confidence: 85.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 69.6% (HIGH) · Higher = larger blast radius
    69.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 85.1% · Lower = rushed or shallow review
    85.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 10.4% · Safe to merge
    10.4%