<feed xmlns='http://www.w3.org/2005/Atom'>
<title>claude-plugins-official.git/plugins/security-guidance/hooks/_base.py, branch bump/snowflake-cortex-code</title>
<subtitle>Official Claude Code plugin directory
</subtitle>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/'/>
<entry>
<title>Merge branch 'main' into mhegazy/sg-launcher-probe-timing</title>
<updated>2026-10-20T22:36:29+00:00</updated>
<author>
<name>Claude</name>
<email>noreply@anthropic.com</email>
</author>
<published>2026-10-20T22:36:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=6d4e17c8c4d45de2eba6dce119e56fff18ae43b1'/>
<id>6d4e17c8c4d45de2eba6dce119e56fff18ae43b1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'mhegazy/sg-gateway-login' into mhegazy/sg-sdk-bootstrap-switches</title>
<updated>2026-10-20T20:35:31+00:00</updated>
<author>
<name>Claude</name>
<email>noreply@anthropic.com</email>
</author>
<published>2026-10-20T20:35:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=03bab72cbdce7039f452b15417de84989858b9e0'/>
<id>03bab72cbdce7039f452b15417de84989858b9e0</id>
<content type='text'>
Resolves the overlap with the bootstrap working-directory change and the gateway sign-in route: the import probe keeps the state-dir working directory, and llm.py keeps both imports.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Resolves the overlap with the bootstrap working-directory change and the gateway sign-in route: the import probe keeps the state-dir working directory, and llm.py keeps both imports.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: run SDK bootstrap subprocesses from the state dir</title>
<updated>2026-10-19T17:11:22+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-19T17:11:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=1eee6df1f032b8719fecdd987273d908d168f467'/>
<id>1eee6df1f032b8719fecdd987273d908d168f467</id>
<content type='text'>
`python -c` and `python -m` put the working directory first on the import
path, and hooks run in the user's repository. A repository file named
claude_agent_sdk.py, venv.py or pip.py was imported in place of the real
module by the SessionStart check and the venv build. Run those
subprocesses from the plugin's state dir, and make state_dir() return an
absolute path as its docstring says, so a relative override isn't
resolved twice.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`python -c` and `python -m` put the working directory first on the import
path, and hooks run in the user's repository. A repository file named
claude_agent_sdk.py, venv.py or pip.py was imported in place of the real
module by the SessionStart check and the venv build. Run those
subprocesses from the plugin's state dir, and make state_dir() return an
absolute path as its docstring says, so a relative override isn't
resolved twice.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: do not install the agent SDK for reviews that are off</title>
<updated>2026-10-19T16:29:44+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-14T16:56:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=49484affa8f5730ec9bcfd6e25c393bc021cdd34'/>
<id>49484affa8f5730ec9bcfd6e25c393bc021cdd34</id>
<content type='text'>
The SessionStart bootstrap and its PostToolUse rescue built a venv of a few
hundred MB for the agent SDK whatever the environment said, including under
SECURITY_GUIDANCE_DISABLE=1, and the rescue started the bootstrap again
every five minutes on machines whose SDK lives in that venv (#5331).

- Nothing is installed when the environment turns off every review that
  loads the SDK: the kill switch, ENABLE_CODE_SECURITY_REVIEW=0, or
  ENABLE_STOP_REVIEW=0 with ENABLE_COMMIT_REVIEW=0. Reported as
  sdk_bootstrap 10. A disabled plugin also no longer shows the
  "reviewer unavailable" notice on a Python below 3.10.
- The rescue leaves a finished install under the state dir alone instead
  of starting the bootstrap for it every five minutes.
- New counts on the bootstrap's metrics row, set only when true and only
  when the install exists: sdk_no_creds and sdk_no_git (the session cannot
  run the reviews the install serves), sdk_venv_py (the venv was built by
  another Python version than the one running the hooks, #5706). They
  size follow-up changes; no behaviour depends on them.

With the reviews on, what is built and when is unchanged.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The SessionStart bootstrap and its PostToolUse rescue built a venv of a few
hundred MB for the agent SDK whatever the environment said, including under
SECURITY_GUIDANCE_DISABLE=1, and the rescue started the bootstrap again
every five minutes on machines whose SDK lives in that venv (#5331).

- Nothing is installed when the environment turns off every review that
  loads the SDK: the kill switch, ENABLE_CODE_SECURITY_REVIEW=0, or
  ENABLE_STOP_REVIEW=0 with ENABLE_COMMIT_REVIEW=0. Reported as
  sdk_bootstrap 10. A disabled plugin also no longer shows the
  "reviewer unavailable" notice on a Python below 3.10.
- The rescue leaves a finished install under the state dir alone instead
  of starting the bootstrap for it every five minutes.
- New counts on the bootstrap's metrics row, set only when true and only
  when the install exists: sdk_no_creds and sdk_no_git (the session cannot
  run the reviews the install serves), sdk_venv_py (the venv was built by
  another Python version than the one running the hooks, #5706). They
  size follow-up changes; no behaviour depends on them.

With the reviews on, what is built and when is unchanged.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: report how long the launcher waits for interpreter probes</title>
<updated>2026-10-19T16:29:25+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-15T22:47:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=d2919136660832d06d5260677b256033c7dbdbda'/>
<id>d2919136660832d06d5260677b256033c7dbdbda</id>
<content type='text'>
sg-python.sh asks each candidate interpreter for its version before running a
hook, and waits as long as that takes. Nothing recorded how long.

The launcher now times each probe with bash builtins (no extra process) and
passes the result to the hook, which reports two keys when the probes of one
launch took a second or more together:

- launcher_probe_ms: all probes of this launch
- launcher_probe_max_ms: the slowest one

The keys go last on a row, so they never displace an existing key. Measurement
only: the launcher still waits for every probe and picks the same interpreter.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sg-python.sh asks each candidate interpreter for its version before running a
hook, and waits as long as that takes. Nothing recorded how long.

The launcher now times each probe with bash builtins (no extra process) and
passes the result to the hook, which reports two keys when the probes of one
launch took a second or more together:

- launcher_probe_ms: all probes of this launch
- launcher_probe_max_ms: the slowest one

The keys go last on a row, so they never displace an existing key. Measurement
only: the launcher still waits for every probe and picks the same interpreter.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #6589 from anthropics/mhegazy/sg-review-cost-log</title>
<updated>2026-10-15T22:41:17+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>8000722+mhegazy@users.noreply.github.com</email>
</author>
<published>2026-10-15T22:41:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=4db747859e151db177af7ed7cd8b5a20c5995ca2'/>
<id>4db747859e151db177af7ed7cd8b5a20c5995ca2</id>
<content type='text'>
security-guidance: log each review's token use and estimated cost</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
security-guidance: log each review's token use and estimated cost</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: log each review's token use and estimated cost</title>
<updated>2026-10-15T22:40:35+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-13T20:52:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=48805c9f91eb029cb49286cad82dde3381ef7e3c'/>
<id>48805c9f91eb029cb49286cad82dde3381ef7e3c</id>
<content type='text'>
The plugin computed a review's usage but kept it only in its metrics.
Each review now writes one line to the plugin's debug log with the kind
of review, the Claude Code session, model, tokens and estimated cost.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The plugin computed a review's usage but kept it only in its metrics.
Each review now writes one line to the plugin's debug log with the kind
of review, the Claude Code session, model, tokens and estimated cost.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: print one JSON document from the SessionStart hook on other hosts</title>
<updated>2026-10-15T16:31:46+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-15T16:31:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=ced6733eee6aa246e2af55ce0c71e38c01a50141'/>
<id>ced6733eee6aa246e2af55ce0c71e38c01a50141</id>
<content type='text'>
On a host other than Claude Code the SessionStart hook printed an async
declaration line and then a metrics line. A host that reads hook output as
one JSON document with a closed schema rejects that.

In portable mode the hook now skips the async line and prints one object
with only the standard fields. The portable-mode helpers move to _base.py so
both hook scripts share them, and the mode is decided once at start-up.
Output under Claude Code is unchanged.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On a host other than Claude Code the SessionStart hook printed an async
declaration line and then a metrics line. A host that reads hook output as
one JSON document with a closed schema rejects that.

In portable mode the hook now skips the async line and prints one object
with only the standard fields. The portable-mode helpers move to _base.py so
both hook scripts share them, and the mode is decided once at start-up.
Output under Claude Code is unchanged.
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: follow the newest Opus instead of a pinned release (2.0.8 → 2.0.9)</title>
<updated>2026-10-02T20:17:39+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-02T20:17:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=01f8be9b220b6e993a3c2cb219f28d7cc6fd3d6f'/>
<id>01f8be9b220b6e993a3c2cb219f28d7cc6fd3d6f</id>
<content type='text'>
The review model was hardcoded to claude-opus-4-7, so the plugin fell
behind each time a new Opus shipped.

- The diff review asks the configured endpoint (GET /v1/models) for the
  newest Opus it serves, cached for a day; claude-opus-5-5 if it can't say.
- The agentic commit review, and every review on Bedrock, Vertex and
  Foundry, use Claude Code's `opus` alias.
- SECURITY_REVIEW_MODEL and SG_AGENTIC_MODEL still pin a model.
- Adds pricing rows for the newer Opus models, and tests.

Co-Authored-By: Claude Code &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The review model was hardcoded to claude-opus-4-7, so the plugin fell
behind each time a new Opus shipped.

- The diff review asks the configured endpoint (GET /v1/models) for the
  newest Opus it serves, cached for a day; claude-opus-5-5 if it can't say.
- The agentic commit review, and every review on Bedrock, Vertex and
  Foundry, use Claude Code's `opus` alias.
- SECURITY_REVIEW_MODEL and SG_AGENTIC_MODEL still pin a model.
- Adds pricing rows for the newer Opus models, and tests.

Co-Authored-By: Claude Code &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>security-guidance: emit HTTP error codes + fix sdk_bootstrap phase/err encoding</title>
<updated>2026-05-31T15:34:35+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-05-31T15:34:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=475038edfce3b736fba6648af7d8c1bd627c2464'/>
<id>475038edfce3b736fba6648af7d8c1bd627c2464</id>
<content type='text'>
Fills two failure-visibility gaps in plugin telemetry.

## Gap 1: HTTP errors from _call_claude invisible

Before: a 4xx/5xx response from the LLM API caused `_call_claude` to
return None and produce ZERO fingerprint in tengu_hook_plugin_metrics.
A failed call looked identical to "no review needed". The recent
deprecation-400 outage (PR #2105, output_format → output_config.format,
#2098) was invisible in aggregate dashboards until a user manually
reported errors from their debug log. Cohort-specific or partial
outages would never show up in BQ.

Fix: add `http_err_last` (most recent status) and `http_err_count`
to the existing `_USAGE` accumulator in `_base.py`. `_usage_metrics()`
snapshots them whenever count &gt; 0 (skip-path no-pollute contract
preserved when count == 0). All `_call_claude` error sites now call
the new `_record_http_error()` helper alongside the existing
`_last_call_claude_http_error` module-state assignment.

Now any future API failure category is queryable in BQ in real time:

  SELECT
    DATE(server_timestamp, "America/Los_Angeles") AS d,
    CAST(JSON_VALUE(additional_metadata, "$.http_err_last") AS INT64) AS code,
    COUNT(*) AS n
  FROM ... WHERE event_name = "tengu_hook_plugin_metrics"
    AND JSON_VALUE(additional_metadata, "$.pluginId") LIKE "%security-guidance%"
    AND JSON_VALUE(additional_metadata, "$.http_err_count") IS NOT NULL
  GROUP BY d, code ORDER BY d, n DESC

## Gap 2: sdk_bootstrap_phase / sdk_bootstrap_err always NULL in BQ

Before: ensure_agent_sdk.py emitted these as strings (e.g. "pip",
"dns_fail"). CC's plugin-metrics pipeline silently drops
plugin-emitted string values — only bool|finite-number plugin metrics
reach BigQuery. (CC-core fields like `subscription_type` are exempt
because they're injected downstream of plugin validation.)

Confirmed empirically: ~185K BUILD_FAILED rows in BQ over the past 2
days had `sdk_bootstrap_phase` = NULL and `sdk_bootstrap_err` = NULL
despite the Python code emitting them. ~28K BUILD_FAILED sessions/day
had no diagnostic split — flying blind on whether the failures are
pip-no-match vs dns-fail vs ssl-verify vs proxy-auth etc.

Fix: encode phase + err_kind as stable integers via
SDK_BOOTSTRAP_PHASE_CODES and SDK_BOOTSTRAP_ERR_CODES. Phase: 1=pre,
2=venv, 3=pip, 4=main. Err: 10 known categories (1-10), 11-98
reserved, 99 = uncategorized catch-all (covers "exc:&lt;X&gt;", "other:&lt;X&gt;",
and unmapped strings). APPEND-ONLY for telemetry stability.

Also corrects the misleading "CC accepts string metric values"
comment in ensure_agent_sdk.py that led to the bug originally.

Verified locally on macOS Python 3.13:

  - py_compile clean.
  - 32 new tests in test_telemetry_failure_signals.py (added to
    internal test suite at sg-staging/tests/, not in this PR):

      * 4 HTTP-error tracking unit tests: _record_http_error increments
        count + tracks most-recent; handles None/invalid; -1 for
        network/timeout.
      * 4 _usage_metrics emission tests: empty when no activity;
        successful call has no http_err fields; failure-only has http_err
        and no api_calls; mixed has both.
      * 1 contract test: every emitted value is bool|finite-number
        (catches future regression of the string-dropping bug class).
      * 13 sdk_bootstrap encoding tests (parametrized over the 10 known
        err_kind categories + 5 catch-all shapes): each maps to the
        right integer; unknown phase = 0; unknown err = 99.
      * 1 static-shape regression catcher: every `err_kind = "..."`
        string in ensure_agent_sdk.main() must be in
        SDK_BOOTSTRAP_ERR_CODES (otherwise new err_kinds silently
        collapse to 99).
      * 2 emit-shape regression catchers: the assignments in main() go
        through _encode_phase / _encode_err_kind helpers (no raw
        strings); no literal string values for sdk_bootstrap_phase/err.
      * 1 comment-accuracy: the misleading "CC accepts string metric
        values" comment is gone.

  - Full suite: 437/437 pass + 2 skipped (live API tests, opt-in).

NOT verified end-to-end against BQ — would require shipping +
observing in production for 24h to confirm the http_err and
sdk_bootstrap_phase/err fields actually appear in
tengu_hook_plugin_metrics rows. The unit tests pin the contract; if
the wire shape is broken, BQ will show NULL for the new fields and we
revisit (with the same diagnostic the BUILD_FAILED bug gave us).

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fills two failure-visibility gaps in plugin telemetry.

## Gap 1: HTTP errors from _call_claude invisible

Before: a 4xx/5xx response from the LLM API caused `_call_claude` to
return None and produce ZERO fingerprint in tengu_hook_plugin_metrics.
A failed call looked identical to "no review needed". The recent
deprecation-400 outage (PR #2105, output_format → output_config.format,
#2098) was invisible in aggregate dashboards until a user manually
reported errors from their debug log. Cohort-specific or partial
outages would never show up in BQ.

Fix: add `http_err_last` (most recent status) and `http_err_count`
to the existing `_USAGE` accumulator in `_base.py`. `_usage_metrics()`
snapshots them whenever count &gt; 0 (skip-path no-pollute contract
preserved when count == 0). All `_call_claude` error sites now call
the new `_record_http_error()` helper alongside the existing
`_last_call_claude_http_error` module-state assignment.

Now any future API failure category is queryable in BQ in real time:

  SELECT
    DATE(server_timestamp, "America/Los_Angeles") AS d,
    CAST(JSON_VALUE(additional_metadata, "$.http_err_last") AS INT64) AS code,
    COUNT(*) AS n
  FROM ... WHERE event_name = "tengu_hook_plugin_metrics"
    AND JSON_VALUE(additional_metadata, "$.pluginId") LIKE "%security-guidance%"
    AND JSON_VALUE(additional_metadata, "$.http_err_count") IS NOT NULL
  GROUP BY d, code ORDER BY d, n DESC

## Gap 2: sdk_bootstrap_phase / sdk_bootstrap_err always NULL in BQ

Before: ensure_agent_sdk.py emitted these as strings (e.g. "pip",
"dns_fail"). CC's plugin-metrics pipeline silently drops
plugin-emitted string values — only bool|finite-number plugin metrics
reach BigQuery. (CC-core fields like `subscription_type` are exempt
because they're injected downstream of plugin validation.)

Confirmed empirically: ~185K BUILD_FAILED rows in BQ over the past 2
days had `sdk_bootstrap_phase` = NULL and `sdk_bootstrap_err` = NULL
despite the Python code emitting them. ~28K BUILD_FAILED sessions/day
had no diagnostic split — flying blind on whether the failures are
pip-no-match vs dns-fail vs ssl-verify vs proxy-auth etc.

Fix: encode phase + err_kind as stable integers via
SDK_BOOTSTRAP_PHASE_CODES and SDK_BOOTSTRAP_ERR_CODES. Phase: 1=pre,
2=venv, 3=pip, 4=main. Err: 10 known categories (1-10), 11-98
reserved, 99 = uncategorized catch-all (covers "exc:&lt;X&gt;", "other:&lt;X&gt;",
and unmapped strings). APPEND-ONLY for telemetry stability.

Also corrects the misleading "CC accepts string metric values"
comment in ensure_agent_sdk.py that led to the bug originally.

Verified locally on macOS Python 3.13:

  - py_compile clean.
  - 32 new tests in test_telemetry_failure_signals.py (added to
    internal test suite at sg-staging/tests/, not in this PR):

      * 4 HTTP-error tracking unit tests: _record_http_error increments
        count + tracks most-recent; handles None/invalid; -1 for
        network/timeout.
      * 4 _usage_metrics emission tests: empty when no activity;
        successful call has no http_err fields; failure-only has http_err
        and no api_calls; mixed has both.
      * 1 contract test: every emitted value is bool|finite-number
        (catches future regression of the string-dropping bug class).
      * 13 sdk_bootstrap encoding tests (parametrized over the 10 known
        err_kind categories + 5 catch-all shapes): each maps to the
        right integer; unknown phase = 0; unknown err = 99.
      * 1 static-shape regression catcher: every `err_kind = "..."`
        string in ensure_agent_sdk.main() must be in
        SDK_BOOTSTRAP_ERR_CODES (otherwise new err_kinds silently
        collapse to 99).
      * 2 emit-shape regression catchers: the assignments in main() go
        through _encode_phase / _encode_err_kind helpers (no raw
        strings); no literal string values for sdk_bootstrap_phase/err.
      * 1 comment-accuracy: the misleading "CC accepts string metric
        values" comment is gone.

  - Full suite: 437/437 pass + 2 skipped (live API tests, opt-in).

NOT verified end-to-end against BQ — would require shipping +
observing in production for 24h to confirm the http_err and
sdk_bootstrap_phase/err fields actually appear in
tengu_hook_plugin_metrics rows. The unit tests pin the contract; if
the wire shape is broken, BQ will show NULL for the new fields and we
revisit (with the same diagnostic the BUILD_FAILED bug gave us).

Co-Authored-By: Claude Opus 4.7 (1M context) &lt;noreply@anthropic.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
