Skip to content

Commit 808bdf4

Browse files
ilblackdragonclaude
andcommitted
fix: address Copilot review - tighten pre-commit filter, document TTL sync
- pre-commit-safety.sh: only exclude `mod tests` hunks (not `fn test_*`) to avoid hiding unwrap/assert in production functions like test_server() - session.rs: extract AUTH_MODE_TTL_SECS constant and add doc comment linking to OAUTH_FLOW_EXPIRY to prevent silent drift [skip-regression-check] Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 831f987 commit 808bdf4

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

scripts/pre-commit-safety.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ fi
136136
PROD_DIFF="$DIFF_OUTPUT"
137137
# Strip hunks from test-only files (tests/ directory, *_test.rs, test_*.rs)
138138
PROD_DIFF=$(echo "$PROD_DIFF" | grep -v '^+++ b/tests/' || true)
139-
# Strip hunks whose @@ context line indicates a test function or module
140-
# (git diff -U0 includes the enclosing function name after @@).
139+
# Strip hunks whose @@ context line indicates a test module.
140+
# git diff includes the enclosing function/module name after @@.
141+
# Only match `mod tests` (the conventional #[cfg(test)] module) — do NOT
142+
# match `fn test_*` because production code can have functions named test_*.
141143
PROD_DIFF=$(echo "$PROD_DIFF" | awk '
142-
/^@@ / { in_test = ($0 ~ /fn test_/ || $0 ~ /mod tests/) }
144+
/^@@ / { in_test = ($0 ~ /mod tests/) }
143145
!in_test { print }
144146
' || true)
145147
if echo "$PROD_DIFF" | grep -nE '^\+' \

src/agent/session.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ pub enum ThreadState {
135135

136136
/// Pending auth token request.
137137
///
138-
/// Auth mode TTL — matches `OAUTH_FLOW_EXPIRY` (5 minutes).
139-
const AUTH_MODE_TTL: TimeDelta = TimeDelta::minutes(5);
138+
/// Auth mode TTL — must stay in sync with
139+
/// `crate::cli::oauth_defaults::OAUTH_FLOW_EXPIRY` (5 minutes / 300 s).
140+
/// Defined separately to avoid a session→cli module dependency.
141+
const AUTH_MODE_TTL_SECS: i64 = 300;
142+
const AUTH_MODE_TTL: TimeDelta = TimeDelta::seconds(AUTH_MODE_TTL_SECS);
140143

141144
/// When `tool_auth` returns `awaiting_token`, the thread enters auth mode.
142145
/// The next user message is intercepted before entering the normal pipeline

0 commit comments

Comments
 (0)