Skip to content

feat: add AWF_ONE_SHOT_TOKEN_DEBUG env var for silent-by-default logging#864

Merged
lpcox merged 3 commits intomainfrom
claude/fix-one-shot-token-output-settings
Feb 15, 2026
Merged

feat: add AWF_ONE_SHOT_TOKEN_DEBUG env var for silent-by-default logging#864
lpcox merged 3 commits intomainfrom
claude/fix-one-shot-token-output-settings

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 15, 2026

  • Add AWF_ONE_SHOT_TOKEN_DEBUG environment variable to control logging output
  • Default logging to off (silent mode)
  • Enable logging only when AWF_ONE_SHOT_TOKEN_DEBUG=1 or AWF_ONE_SHOT_TOKEN_DEBUG=true
  • Ensure AWF_ONE_SHOT_TOKEN_DEBUG is never in the list of protected tokens (prevent infinite recursion)
  • Update lib.rs with conditional logging based on debug flag
  • Update integration tests to use debug flag when needed
  • Update README.md documentation
  • Build and test locally
  • Add debug flag to C implementation (one-shot-token.c)
  • Test C implementation with debug flag

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix one-shot-token output settings based on environment variable feat: add AWF_ONE_SHOT_TOKEN_DEBUG env var for silent-by-default logging Feb 15, 2026
@Claude Claude AI requested a review from lpcox February 15, 2026 15:38
Add debug flag support to the C implementation of one-shot-token library
to match the Rust implementation. Logging is now off by default and can
be enabled by setting AWF_ONE_SHOT_TOKEN_DEBUG=1 or AWF_ONE_SHOT_TOKEN_DEBUG=true.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 15, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.71% 82.86% 📈 +0.15%
Statements 82.63% 82.78% 📈 +0.15%
Functions 82.74% 82.74% ➡️ +0.00%
Branches 74.78% 74.88% 📈 +0.10%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 84.1% → 84.7% (+0.56%) 83.4% → 83.9% (+0.54%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Contributor

Build Test: Deno

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests passed successfully.

AI generated by Build Test Deno

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data successfully
  • ✅ Playwright: Verified GitHub homepage title contains "GitHub"
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-copilot-22038526166.txt
  • ✅ Bash Tool: File verified with content "Smoke test passed for Copilot at Sun Feb 15 15:59:24 UTC 2026"

Status: PASS 🎉

PR #858 by @Claude (assignees: @lpcox, @Claude)
PR #861 by @github-actions[bot]

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Node.js Build Test Results

Project Install Tests Status
clsx PASS PASS
execa PASS PASS
p-limit PASS PASS

Overall: PASS

All three Node.js projects successfully installed dependencies and passed their test suites.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

Bun Build Test Results

Project Install Tests Status
elysia 1/1 PASS
hono 1/1 PASS

Overall: PASS

All Bun projects built and tested successfully.

AI generated by Build Test Bun

@github-actions
Copy link
Contributor

Go Build Test Results

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

All Go projects successfully downloaded dependencies and passed tests.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects successfully configured with CMake and built without errors.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

.NET Build Test Results

All .NET projects tested successfully! ✅

Project Restore Build Run Status
hello-world PASS
json-parse PASS

Overall: PASS

Test Details

hello-world:

  • Restored in 79ms
  • Build succeeded (0 warnings, 0 errors)
  • Output: Hello, World!

json-parse:

  • Restored in 660ms (with NuGet dependencies)
  • Build succeeded (0 warnings, 0 errors)
  • Output: Successfully parsed and displayed JSON data

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

Smoke Test Results - Claude Engine

Last 2 merged PRs:

  • [docs] Sync CLI flags and agent image presets with code
  • chore: bump version to 0.18.0

Test Results:

  • ✅ GitHub MCP (list_pull_requests)
  • ✅ Playwright (navigated to github.com, title verified)
  • ✅ File creation (/tmp/gh-aw/agent/smoke-test-claude-22038526127.txt)
  • ✅ Bash tool (verified file content)

Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

Rust Build Test Results

Project Build Tests Status
fd 1/1 PASS
zoxide 1/1 PASS

Overall: PASS

All Rust projects built and tested successfully.

AI generated by Build Test Rust

@github-actions
Copy link
Contributor

Smoke Test (Codex)
Merged PRs: [docs] Sync CLI flags and agent image presets with code | chore: bump version to 0.18.0
GitHub MCP review: ✅
Safeinputs gh pr list: ✅
Playwright title check: ✅
Tavily search: ❌ (tool unavailable)
File write+cat: ✅
Discussion comment: ✅
Build (npm ci && npm run build): ✅
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

🔍 Chroot Version Comparison Test Results

Runtime Host Version Chroot Version Match?
Python 3.12.12 3.12.3 ❌ NO
Node.js v24.13.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall Result:FAILED - Not all versions match

The chroot mode test detected version mismatches for Python and Node.js. This is expected behavior as the chroot environment uses container binaries which may differ from the host system. Only Go matched between host and chroot environments.

AI generated by Smoke Chroot

@lpcox lpcox marked this pull request as ready for review February 15, 2026 16:29
Copilot AI review requested due to automatic review settings February 15, 2026 16:29
@lpcox lpcox merged commit 2d90521 into main Feb 15, 2026
93 checks passed
@lpcox lpcox deleted the claude/fix-one-shot-token-output-settings branch February 15, 2026 16:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an AWF_ONE_SHOT_TOKEN_DEBUG environment flag to make one-shot-token logging silent-by-default while allowing opt-in debug output for troubleshooting and test verification.

Changes:

  • Added a debug flag (AWF_ONE_SHOT_TOKEN_DEBUG=1|true) to enable/disable stderr logging (default off) in both Rust and C implementations.
  • Updated integration tests to set AWF_ONE_SHOT_TOKEN_DEBUG=1 when asserting on one-shot-token log output.
  • Updated one-shot-token README to document silent-by-default behavior and the debug flag.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
tests/integration/one-shot-tokens.test.ts Sets AWF_ONE_SHOT_TOKEN_DEBUG=1 in test container env where stderr log assertions are made.
containers/agent/one-shot-token/src/lib.rs Adds debug_enabled state + is_debug_enabled() and gates logging accordingly.
containers/agent/one-shot-token/one-shot-token.c Adds debug_enabled + is_debug_enabled() and gates stderr logging accordingly.
containers/agent/one-shot-token/README.md Documents the new debug flag and updates examples for silent-by-default operation.
Comments suppressed due to low confidence (2)

containers/agent/one-shot-token/README.md:292

  • Same as the earlier example: the expected output shows INFO: Token ... cleared from process environment, but the C implementation doesn’t emit these INFO lines. Please adjust this expected output (or implement the INFO logging in C under the debug flag) to avoid misleading users.
[one-shot-token] Initialized with 2 custom token(s) from AWF_ONE_SHOT_TOKENS
[one-shot-token] Token MY_API_KEY accessed and cached (value: secr...)
[one-shot-token] INFO: Token MY_API_KEY cleared from process environment
First MY_API_KEY: secret-value-123
Second MY_API_KEY: secret-value-123
[one-shot-token] Token SECRET_TOKEN accessed and cached (value: anot...)
[one-shot-token] INFO: Token SECRET_TOKEN cleared from process environment
First SECRET_TOKEN: another-secret

containers/agent/one-shot-token/src/lib.rs:112

  • The module docs and README state the library is silent by default unless AWF_ONE_SHOT_TOKEN_DEBUG is enabled, but this secure_getenv-missing warning is emitted unconditionally. Either gate this message behind the debug flag (without using intercepted getenv), or update the documentation to call out this exception so “silent by default” remains accurate.
            // Note: We can't check debug flag here because it would cause infinite recursion
            // during initialization. This is a rare case (secure_getenv unavailable) so we
            // always log it.
            eprintln!("[one-shot-token] WARNING: secure_getenv not available, falling back to getenv");
            None

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +196 to 200
/* Check if debug logging is enabled */
debug_enabled = is_debug_enabled();

/* Get the configuration from environment */
const char *config = real_getenv("AWF_ONE_SHOT_TOKENS");
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWF_ONE_SHOT_TOKEN_DEBUG is documented as never being cached/cleared, but the custom token list parsing will currently accept it like any other token name. Consider explicitly skipping AWF_ONE_SHOT_TOKEN_DEBUG when parsing AWF_ONE_SHOT_TOKENS to make that guarantee true.

Copilot uses AI. Check for mistakes.
**Important notes:**
- Debug logging is **off by default** to reduce noise in production environments
- When enabled, the library logs initialization messages and token access events to stderr
- The `AWF_ONE_SHOT_TOKEN_DEBUG` variable is never cached or cleared (prevents infinite recursion)
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bullet says AWF_ONE_SHOT_TOKEN_DEBUG is “never cached or cleared”, but neither the C nor Rust implementation currently prevents a user from including it in AWF_ONE_SHOT_TOKENS (in which case it would be treated like a protected token). Either enforce the exclusion in code or soften this statement to reflect the actual behavior.

Suggested change
- The `AWF_ONE_SHOT_TOKEN_DEBUG` variable is never cached or cleared (prevents infinite recursion)
- By default, the `AWF_ONE_SHOT_TOKEN_DEBUG` variable is not cached or cleared (to prevent infinite recursion when checking it)
- If you explicitly add `AWF_ONE_SHOT_TOKEN_DEBUG` to `AWF_ONE_SHOT_TOKENS`, it will be treated like any other protected token and may be cached/cleared

Copilot uses AI. Check for mistakes.
```
[one-shot-token] Initialized with 11 default token(s)
[one-shot-token] Token GITHUB_TOKEN accessed and cached (value: test...)
[one-shot-token] INFO: Token GITHUB_TOKEN cleared from process environment
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expected output includes an INFO: Token ... cleared from process environment line, but the agent Docker image builds the C implementation (one-shot-token.c), which does not emit these INFO lines. Update the example to match the C library’s actual output, or add equivalent logging to the C implementation when debug is enabled.

This issue also appears on line 285 of the same file.

Suggested change
[one-shot-token] INFO: Token GITHUB_TOKEN cleared from process environment

Copilot uses AI. Check for mistakes.
Comment on lines 169 to 177
return;
}

// Check if debug logging is enabled
state.debug_enabled = is_debug_enabled();

// Get configuration from environment
let config_cstr = CString::new("AWF_ONE_SHOT_TOKENS").unwrap();
// SAFETY: We're calling the real getenv with a valid C string
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AWF_ONE_SHOT_TOKEN_DEBUG is now a special control variable, but init_token_list will still accept it as a protected token if a user includes it in AWF_ONE_SHOT_TOKENS. That contradicts the documented guarantee that this variable is never cached/cleared. Consider filtering out AWF_ONE_SHOT_TOKEN_DEBUG when parsing the custom token list (and/or preventing it from being added to state.tokens).

Copilot uses AI. Check for mistakes.
Comment on lines 376 to 380
libc::unsetenv(name);

// Verify the token was cleared from the process environment
check_task_environ_exposure(name_str);
check_task_environ_exposure(name_str, debug_enabled);

Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_task_environ_exposure still scans the entire environ even when debug logging is disabled, but its only observable effect is emitting debug logs. To avoid unnecessary work in the default (silent) mode, gate the call to check_task_environ_exposure(...) behind if debug_enabled { ... } (or early-return at the top of the function when debug_enabled is false).

This issue also appears on line 108 of the same file.

See below for a potential fix:

    // Verify the token was cleared from the process environment only when debug logging is enabled
    if debug_enabled {
        check_task_environ_exposure(name_str, debug_enabled);
    }

Copilot uses AI. Check for mistakes.
Comment on lines 459 to +463

fprintf(stderr, "[one-shot-token] Token %s accessed and cached (value: %s) (via secure_getenv)\n",
name, format_token_value(token_cache[token_idx]));
if (debug_enabled) {
fprintf(stderr, "[one-shot-token] Token %s accessed and cached (value: %s) (via secure_getenv)\n",
name, format_token_value(token_cache[token_idx]));
}
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secure_getenv() does not initialize the token list (and debug_enabled is only set inside init_token_list). If secure_getenv is the first call in a process, num_tokens will still be 0 so no tokens are protected and debug logging will never enable. Fix by ensuring token initialization (under the mutex) happens in secure_getenv() before checking get_token_index() / using debug_enabled.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants