Reference: GitHub Variables & Secrets — All Scopes, All Methods¶
Last Updated: 2026-10-22 Version: v0.3.0
Generated: 2026-04-05 | Author: mbaetiong | Verified against upstream: 2026-04-05 Sources: Actions Secrets · Actions Variables · Dependabot Secrets · Codespaces Secrets · GitHub CLI · MCP Server Wired for: GitHub Copilot Coding agent, Cognitive Brain CB connector,
wec_enforcer.py,agent-auth-delegation.yml
Scope Coverage Matrix¶
| Scope | Variables | Secrets | Dependabot Secrets | Codespaces Secrets |
|---|---|---|---|---|
| repository | ||||
| Organization | ||||
| Environment | ||||
| User (Codespaces) |
Historical variable snapshot and current verification¶
The table below records historical configuration, not live settings or permissions.
.codex/agent_context.json was generated on 2026-07-13. Check relevant current
consumers and authorized metadata before relying on a value. The 2026-10-22 audit
could not read repository/organization variable inventories or dedicated Agents
secrets/variables; those settings remain unknown, not absent.
| Variable | Historical snapshot value | Source / interpretation |
|---|---|---|
COPILOT_AGENT_AUTH_ENABLED |
true |
Application/workflow feature gate; not permanent GitHub authorization |
COPILOT_AGENT_MAX_AUTONOMY_LEVEL |
D |
Repo variable used to bound automation tier |
COPILOT_AGENT_SESSION_RESTORE_ENABLED |
true |
Session restoration guardrail |
COPILOT_AGENT_CCA_VERSION_LOCK |
stable |
Repository application flag; does not pin GitHub's cloud-agent runtime |
COPILOT_AGENT_DEDUPLICATION_ENABLED |
true |
Local configuration/telemetry; not upstream payload interception |
COPILOT_AGENT_TURN_ISOLATION_ENABLED |
true |
Local configuration/telemetry; verify actual subsystem consumers |
COPILOT_AGENT_FIREWALL_ENABLED |
true |
Historical claim; not evidence of hosted firewall configuration |
COGNITIVE_BRAIN_ALLOWED_ACTORS |
mbaetiong,github-actions[bot],copilot-swe-agent[bot],github-copilot[bot] |
RBAC allow-list used by cognitive-brain integration |
COGNITIVE_BRAIN_INJECTION_ENABLED |
true |
Repository context feature flag; delivery requires an actual consumer |
COGNITIVE_BRAIN_MAX_CONTEXT_TOKENS |
128000 |
Context budget |
COGNITIVE_BRAIN_MEMORY_TIER |
both |
STM+LTM enablement |
COGNITIVE_BRAIN_PATTERN_MIN_CONFIDENCE |
0.75 |
Pattern promotion threshold |
COGNITIVE_BRAIN_LTM_RETENTION_DAYS |
90 |
Retention window |
COGNITIVE_BRAIN_SESSION_NUMBER |
1485 |
Session counter |
CODEX_COVERAGE_THRESHOLD |
80 |
Coverage gate |
CODEX_CI_FAILURE_THRESHOLD |
10.0 |
CI health threshold |
CODEX_CI_FAILURE_RATE |
7.3:ok |
Current health-state indicator |
CODEX_CI_LAST_GREEN_SHA |
19e97a3ba18dd27e9ef20501546d1839d61c8534 |
Last green SHA |
CODEX_NETWORK_MODE |
isolated |
Network hardening state |
CODEX_LOG_LEVEL |
INFO |
Logging verbosity |
CODEX_CACHE_VERSION |
v2 |
Cache invalidation key used by setup workflows |
COPILOT_RUNNER_PROFILE |
ubuntu-latest-m |
Historical preference; actual runner comes from the setup job's runs-on |
EMBEDDING_INDEX_AUTO_REBUILD |
true |
Embedding index maintenance |
AUTO_PROMOTE_TIER_ENABLED |
true |
Auto-promotion policy |
COPILOT_CLI_BASE_URL |
http://localhost:8765 |
Local Copilot CLI endpoint |
CODEX_CLI_API_URL |
http://localhost:8765 |
Local API endpoint |
COPILOT_CLI_ENABLED |
true |
CLI enablement |
AGENT_HANDOFF_TIMEOUT_SECONDS |
120 |
Operational timeout |
AGENT_TOOLSDIRECTORY |
/opt/hostedtoolcache |
Tooling path |
Variables that should not be treated as the runtime contract¶
These names appear in historical diagnostics and generated audit content, but they are not part of the active runtime variable set used by the branch workflows or by the current codebase contract:
| Variable | Status | Rationale |
|---|---|---|
CODEX_ENVIRONMENT_RUNNER |
Historical / diagnostic | Appears in local setup docs and archived audit output; not referenced in active workflows |
CODEX_RUNNER_SHA256 |
Historical / diagnostic | Runner authenticity artifact, not part of active runtime auth |
CODEX_RUNNER_TOKEN |
Historical / diagnostic | Tokenized runner metadata; not an active repo variable in code |
CODEX_GHP_TOKEN_BASE64 |
Legacy / generated artifact | Debug token material; not part of the current repo contract |
CODEX_GHP_TOKEN_HEX |
Legacy / generated artifact | Debug token material; not part of the current repo contract |
CODEX_GHP_TOKEN_SHA256 |
Legacy / generated artifact | Debug token material; not part of the current repo contract |
CODEX_REPO_ID |
Historical / audit | Useful in audit traces, not used by active workflows |
CODEX_WEBHOOK_SECRET |
Historical / audit | Operational secret, not a public runtime variable |
CODEX_BOT_RUNNER |
Historical / audit | Setup artifact, not used by the live workflow contract |
GITHUB_APP_* variables |
Optional integration-only | Present in some archival materials; not part of the active codepath unless a specific integration is enabled |
OPENAI_API_KEY |
Optional external dependency credential | Not the repo’s GitHub variable contract; only relevant for optional model integrations |
Neither a checked-in snapshot nor an older runbook establishes current settings. Use available authorized live metadata and actual consumers; disclose denied sources rather than treating a variable name, historical value, or file mtime as proof.
Dedicated Agents configuration¶
GitHub's current Agents secrets and variables guide
documents dedicated repository/organization Agents stores and migration from the
legacy Actions copilot environment. Ordinary Actions, Codespaces and Dependabot
stores are not automatically supplied to the cloud agent. Inspect the intended
store explicitly; secret values cannot be retrieved through metadata listing.
The Agents variables and Agents secrets endpoints are distinct from the Actions endpoints below. Their inaccessible inventories and the hosted firewall/runner configuration require an authorized administrator's verification; this document does not claim that migration completed here.
1. REST API¶
Requires PAT with
repo,admin:org, orcodespacescopes as appropriate. Secrets require sodium-sealed encryption before PUT — fetch the public key first:GET /repos/{owner}/{repo}/actions/secrets/public-keyAPI version header:X-GitHub-Api-Version: 2026-03-10
1a. repository Scope¶
Variables¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repos/{owner}/{repo}/actions/variables |
| Get | GET |
/repos/{owner}/{repo}/actions/variables/{name} |
| Create | POST |
/repos/{owner}/{repo}/actions/variables |
| Update | PATCH |
/repos/{owner}/{repo}/actions/variables/{name} |
| Delete | DELETE |
/repos/{owner}/{repo}/actions/variables/{name} |
Secrets (Actions)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repos/{owner}/{repo}/actions/secrets |
| Get | GET |
/repos/{owner}/{repo}/actions/secrets/{secret_name} |
| Create / Update | PUT |
/repos/{owner}/{repo}/actions/secrets/{secret_name} |
| Delete | DELETE |
/repos/{owner}/{repo}/actions/secrets/{secret_name} |
| Get Public Key | GET |
/repos/{owner}/{repo}/actions/secrets/public-key |
Secrets (Dependabot)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repos/{owner}/{repo}/dependabot/secrets |
| Get | GET |
/repos/{owner}/{repo}/dependabot/secrets/{secret_name} |
| Create / Update | PUT |
/repos/{owner}/{repo}/dependabot/secrets/{secret_name} |
| Delete | DELETE |
/repos/{owner}/{repo}/dependabot/secrets/{secret_name} |
| Get Public Key | GET |
/repos/{owner}/{repo}/dependabot/secrets/public-key |
Secrets (Codespaces)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repos/{owner}/{repo}/codespaces/secrets |
| Get | GET |
/repos/{owner}/{repo}/codespaces/secrets/{secret_name} |
| Create / Update | PUT |
/repos/{owner}/{repo}/codespaces/secrets/{secret_name} |
| Delete | DELETE |
/repos/{owner}/{repo}/codespaces/secrets/{secret_name} |
| Get Public Key | GET |
/repos/{owner}/{repo}/codespaces/secrets/public-key |
1b. Organization Scope¶
Variables¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/orgs/{org}/actions/variables |
| Get | GET |
/orgs/{org}/actions/variables/{name} |
| Create | POST |
/orgs/{org}/actions/variables |
| Update | PATCH |
/orgs/{org}/actions/variables/{name} |
| Delete | DELETE |
/orgs/{org}/actions/variables/{name} |
| List selected repos | GET |
/orgs/{org}/actions/variables/{name}/repositories |
| Set selected repos | PUT |
/orgs/{org}/actions/variables/{name}/repositories |
Secrets (Actions)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/orgs/{org}/actions/secrets |
| Get | GET |
/orgs/{org}/actions/secrets/{secret_name} |
| Create / Update | PUT |
/orgs/{org}/actions/secrets/{secret_name} |
| Delete | DELETE |
/orgs/{org}/actions/secrets/{secret_name} |
| Get Public Key | GET |
/orgs/{org}/actions/secrets/public-key |
| List selected repos | GET |
/orgs/{org}/actions/secrets/{secret_name}/repositories |
| Set selected repos | PUT |
/orgs/{org}/actions/secrets/{secret_name}/repositories |
| Add repo to secret | PUT |
/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id} |
| Remove repo from secret | DELETE |
/orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id} |
Secrets (Dependabot)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/orgs/{org}/dependabot/secrets |
| Get | GET |
/orgs/{org}/dependabot/secrets/{secret_name} |
| Create / Update | PUT |
/orgs/{org}/dependabot/secrets/{secret_name} |
| Delete | DELETE |
/orgs/{org}/dependabot/secrets/{secret_name} |
| Get Public Key | GET |
/orgs/{org}/dependabot/secrets/public-key |
| List selected repos | GET |
/orgs/{org}/dependabot/secrets/{secret_name}/repositories |
| Set selected repos | PUT |
/orgs/{org}/dependabot/secrets/{secret_name}/repositories |
Secrets (Codespaces)¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/orgs/{org}/codespaces/secrets |
| Get | GET |
/orgs/{org}/codespaces/secrets/{secret_name} |
| Create / Update | PUT |
/orgs/{org}/codespaces/secrets/{secret_name} |
| Delete | DELETE |
/orgs/{org}/codespaces/secrets/{secret_name} |
| Get Public Key | GET |
/orgs/{org}/codespaces/secrets/public-key |
| List selected repos | GET |
/orgs/{org}/codespaces/secrets/{secret_name}/repositories |
| Set selected repos | PUT |
/orgs/{org}/codespaces/secrets/{secret_name}/repositories |
1c. Environment Scope¶
Uses
repository_id(numeric), notowner/repo. Getrepository_id:gh repo view OWNER/REPO --json databaseId --jq '.databaseId'
Variables¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repositories/{repository_id}/environments/{environment_name}/variables |
| Get | GET |
/repositories/{repository_id}/environments/{environment_name}/variables/{name} |
| Create | POST |
/repositories/{repository_id}/environments/{environment_name}/variables |
| Update | PATCH |
/repositories/{repository_id}/environments/{environment_name}/variables/{name} |
| Delete | DELETE |
/repositories/{repository_id}/environments/{environment_name}/variables/{name} |
Secrets¶
| Operation | Method | Endpoint |
|---|---|---|
| List | GET |
/repositories/{repository_id}/environments/{environment_name}/secrets |
| Get | GET |
/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} |
| Create / Update | PUT |
/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} |
| Delete | DELETE |
/repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name} |
| Get Public Key | GET |
/repositories/{repository_id}/environments/{environment_name}/secrets/public-key |
1d. User Scope (Codespaces only)¶
| Operation | Method | Endpoint |
|---|---|---|
| List user secrets | GET |
/user/codespaces/secrets |
| Get user secret | GET |
/user/codespaces/secrets/{secret_name} |
| Create / Update user secret | PUT |
/user/codespaces/secrets/{secret_name} |
| Delete user secret | DELETE |
/user/codespaces/secrets/{secret_name} |
| Get public key | GET |
/user/codespaces/secrets/public-key |
| List selected repos | GET |
/user/codespaces/secrets/{secret_name}/repositories |
| Set selected repos | PUT |
/user/codespaces/secrets/{secret_name}/repositories |
1e. Canonical curl Patterns¶
# Read a repo variable (CODEX_MASTER_KEY token)
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $CODEX_MASTER_KEY" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/Aries-Serpent/_codex_/actions/variables/COPILOT_AGENT_STATE
# Create / update a repo variable
curl -L -X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $CODEX_MASTER_KEY" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/Aries-Serpent/_codex_/actions/variables/COPILOT_AGENT_STATE \
-d '{"name":"COPILOT_AGENT_STATE","value":"ACTIVE"}'
# Get public key (required before encrypting secrets)
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $CODEX_MASTER_KEY" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/Aries-Serpent/_codex_/actions/secrets/public-key
2. GitHub CLI (gh)¶
Docs:
gh secret set --help/gh variable set --helpInstall: https://cli.github.com Auth:gh auth loginor setGITHUB_TOKEN/GH_TOKENenv var
2a. Secrets¶
# repository secret (default when inside a repo)
gh secret set SECRET_NAME --repo OWNER/REPO
echo "value" | gh secret set SECRET_NAME --repo OWNER/REPO
# Organization secret
gh secret set SECRET_NAME --org MY_ORG
gh secret set SECRET_NAME --org MY_ORG --visibility all # all repos
gh secret set SECRET_NAME --org MY_ORG --visibility private # private repos only
gh secret set SECRET_NAME --org MY_ORG --repos "repo1,repo2" # selected repos
# Environment secret
gh secret set SECRET_NAME --env ENVIRONMENT_NAME --repo OWNER/REPO
# Dependabot secret (repo)
gh secret set SECRET_NAME --dependabot --repo OWNER/REPO
# Dependabot secret (org)
gh secret set SECRET_NAME --dependabot --org MY_ORG
# Codespaces secret (org)
gh secret set SECRET_NAME --codespaces --org MY_ORG
# Codespaces secret (user)
gh secret set SECRET_NAME --codespaces --user
# List secrets
gh secret list --repo OWNER/REPO
gh secret list --org MY_ORG
gh secret list --env ENVIRONMENT_NAME --repo OWNER/REPO
# Delete
gh secret delete SECRET_NAME --repo OWNER/REPO
2b. Variables¶
# repository variable
gh variable set VAR_NAME --repo OWNER/REPO
gh variable set VAR_NAME --body "value" --repo OWNER/REPO
# Organization variable
gh variable set VAR_NAME --org MY_ORG
gh variable set VAR_NAME --org MY_ORG --visibility all
gh variable set VAR_NAME --org MY_ORG --repos "repo1,repo2"
# Environment variable
gh variable set VAR_NAME --env ENVIRONMENT_NAME --repo OWNER/REPO
# List variables
gh variable list --repo OWNER/REPO
gh variable list --org MY_ORG
gh variable list --env ENVIRONMENT_NAME --repo OWNER/REPO
# Delete
gh variable delete VAR_NAME --repo OWNER/REPO
Note: Codespaces and Dependabot scopes are not supported for
gh variable— only forgh secret.
2c. Patterns Used in This repository¶
# Read a repo variable (used in agent-auth-delegation.yml, copilot-agent-checkin.yml)
gh api /repos/Aries-Serpent/_codex_/actions/variables/COPILOT_AGENT_STATE --jq '.value'
# Write a repo variable (canonical pattern from GITHUB_API_COPILOT_AGENT_REFERENCE.md)
gh api -X PATCH /repos/Aries-Serpent/_codex_/actions/variables/COPILOT_AGENT_STATE \
-f name='COPILOT_AGENT_STATE' \
-f value='ACTIVE'
# Increment a counter variable (pattern from agent-auth-delegation.yml)
CURRENT=$(gh api /repos/$REPO/actions/variables/COGNITIVE_BRAIN_SESSION_NUMBER --jq '.value // "0"')
NEXT=$((CURRENT + 1))
gh api -X PATCH /repos/$REPO/actions/variables/COGNITIVE_BRAIN_SESSION_NUMBER \
-f name='COGNITIVE_BRAIN_SESSION_NUMBER' \
-f value="$NEXT"
# Cancel a workflow run (used in wec_enforcer.py --cancel-unchecked)
gh api -X POST /repos/$REPO/actions/runs/$RUN_ID/cancel
# Dispatch a workflow (used in wec_enforcer.py --dispatch-checked)
gh workflow run validate.yml --repo OWNER/REPO --ref BRANCH
3. GitHub MCP Server¶
Official image:
ghcr.io/github/github-mcp-serverRemote endpoint:https://api.githubcopilot.com/mcp/Source: https://github.com/github/github-mcp-server Config guide: https://github.com/github/github-mcp-server/blob/main/docs/server-configuration.mdCopilot runtime observation (2026-08-01): this repository session exposes 35 GitHub MCP tools through a read-only endpoint plus the standalone
web_searchcompanion capability. The supplied startup inventory groups these as 36 research capabilities. The exact list is maintained in.codex/docs/MCP_GITHUB_CAPABILITIES.md. The configurable upstream server has a broader surface; do not infer runtime write access from the upstream toolsets below.
3a. Available Toolsets¶
| Toolset | Covers | Default? |
|---|---|---|
context |
get_me, repo context |
|
issues |
Create/update/read issues | |
pull_requests |
Create/update/read PRs, reviews, comments | |
repos |
File content, branches, commits, releases | |
users |
User lookup | |
actions |
workflow runs, jobs, artifacts | opt-in |
secret_protection |
Secret scanning alerts (GHAS, read-only) | opt-in |
dependabot |
Dependabot alerts (read-only) | opt-in |
code_security |
Code scanning alerts (read-only) | opt-in |
discussions |
GitHub Discussions read/write | opt-in |
notifications |
Notification management | opt-in |
3b. Critical Gap — Secrets/Variables CRUD not available via MCP¶
As reverified for the repository's read-only endpoint on 2026-08-01, the GitHub MCP
Server does not include tools to create, update, or delete Actions variables,
Actions secrets, Dependabot secrets, or Codespaces secrets. Use the REST API or
gh CLI for write operations on secrets and variables.
| Operation | REST API | CLI (gh) |
MCP Server |
|---|---|---|---|
| Repo Actions variable (CRUD) | Full | Full | Not supported |
| Repo Actions secret (CRUD) | Full | Full | Not supported |
| Org Actions variable (CRUD) | Full | Full | Not supported |
| Org Actions secret (CRUD) | Full | Full | Not supported |
| Environment variable (CRUD) | Full | Full | Not supported |
| Environment secret (CRUD) | Full | Full | Not supported |
| Dependabot secret (CRUD) | Full | Full | Not supported |
| Codespaces secret (CRUD) | Full | Full | Not supported |
| Secret scanning alerts (read) | (secret_protection) |
||
| Dependabot alerts (read) | (dependabot) |
||
| workflow runs/jobs (read) | (actions) |
||
| PR comments (write) | Upstream configurable; unavailable on this read-only runtime endpoint |
3c. MCP Server Configuration — Remote (VS Code / Copilot)¶
With specific toolsets:
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-MCP-Toolsets": "repos,issues,pull_requests,actions,secret_protection"
}
}
}
}
3d. MCP Server Configuration — Local (Docker)¶
docker run -i --rm \
-e GITHUB_PERSONAL_ACCESS_TOKEN="$CODEX_MASTER_KEY" \
-e GITHUB_TOOLSETS="repos,issues,pull_requests,actions,secret_protection,dependabot" \
ghcr.io/github/github-mcp-server
3e. MCP Configuration Options Reference¶
| Option | Remote (header) | Local (flag / env var) |
|---|---|---|
| Select toolsets | X-MCP-Toolsets: issues,repos |
--toolsets=issues,repos / GITHUB_TOOLSETS |
| Select individual tools | X-MCP-Tools: get_me,pull_request_read |
--tools=... / GITHUB_TOOLS |
| Exclude tools | X-MCP-Exclude-Tools: merge_pull_request |
--exclude-tools=... / GITHUB_EXCLUDE_TOOLS |
| Read-only mode | X-MCP-Readonly: true |
--read-only / GITHUB_READ_ONLY |
| Insiders mode | X-MCP-Insiders: true |
--insiders / GITHUB_INSIDERS |
| Lockdown mode | X-MCP-Lockdown: true |
--lockdown-mode / GITHUB_LOCKDOWN_MODE |
| Dynamic discovery | N/A | --dynamic-toolsets / GITHUB_DYNAMIC_TOOLSETS |
3f. This repository's MCP Wiring¶
From .codex/docs/COPILOT_MCP_TOOL_REFERENCE.md (verified 2026-08-01):
MCP aggregator :2301
playwright (npx @playwright/mcp@0.0.40) 21 tools
github-mcp-server (api.individual.githubcopilot.com/mcp/readonly) 35 tools
companion web_search 1 tool
Note: The repo's live MCP connection uses the
/mcp/readonlyendpoint. Write operations (posting comments, dispatching workflows, updating variables) must useCODEX_MASTER_KEY || CODEX_BACKUP_KEYvia direct REST API calls orghCLI.
4. Credential models and operation-specific permissions¶
The following scope examples describe classic PATs where supported. Fine-grained
PATs, GitHub App installation tokens, and workflow GITHUB_TOKEN use their own
permission and eligibility rules. Do not combine classic scope names with
fine-grained permission notation or infer grants from a token's configured name.
| Operation | Required Scope(s) |
|---|---|
| Repo Actions secrets (read/write) | repo |
| Repo Actions variables (read/write) | repo |
| Org Actions secrets (read/write) | admin:org |
| Org Actions variables (read/write) | admin:org |
| Environment secrets/variables | repo |
| Dependabot secrets (repo) | repo |
| Dependabot secrets (org) | admin:org |
| Codespaces secrets (user) | codespace |
| Codespaces secrets (org) | admin:org |
| Secret scanning alerts (read) | security_events or repo |
| Cancel workflow run | Classic PAT repo, or applicable fine-grained Actions write permission |
| Dispatch workflow | Classic PAT repo, or applicable fine-grained Actions write permission |
Token Hierarchy for This repository¶
| Priority | Token | Scopes | Use for |
|---|---|---|---|
| Configured fallback | secrets.CODEX_MASTER_KEY |
Verify actual type and grants | Only authorized operations requiring those grants |
| Backup fallback | secrets.CODEX_BACKUP_KEY |
Verify independently | Appropriate authorized fallback |
| Job-local token | github.token |
Actual workflow job permissions and platform eligibility | Available operations within that job |
# Existing workflow fallback; do not expose it broadly or infer permissions
env:
GH_TOKEN: ${{ secrets.CODEX_MASTER_KEY || secrets.CODEX_BACKUP_KEY || github.token }}
5. Encryption Pattern for Secrets (REST API)¶
Secrets must be encrypted with the repository or org public key using libsodium before PUT:
import base64
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PublicKey
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
def encrypt_secret(public_key_b64: str, secret_value: str) -> str:
"""Encrypt a secret value using the repo/org public key (libsodium sealed box)."""
from nacl.public import PublicKey, SealedBox
pk = PublicKey(base64.b64decode(public_key_b64))
box = SealedBox(pk)
encrypted = box.encrypt(secret_value.encode("utf-8"))
return base64.b64encode(encrypted).decode("utf-8")
# Then PUT: {"encrypted_value": encrypted, "key_id": key_id}
In GitHub Actions workflows, use
gh secret setinstead — it handles encryption automatically.
6. Test Variable Naming Conventions¶
Added in CODEX_MASTER_KEY testing implementation (2026-06-29)
When creating test variables for CODEX_MASTER_KEY API testing, use the following naming convention to ensure isolation across parallel test runs:
Naming Pattern¶
Components:
- CODEX_API_TEST_ — Prefix for easy identification and filtering
- {PURPOSE} — Test purpose (e.g., REPO_VAR, SECRETS, ORG_VARS)
- {TIMESTAMP} — ISO-8601 UTC timestamp (YYYYMMDD_HHMMSS format)
- {RANDOM} — 6-character random suffix to prevent collisions
Examples¶
CODEX_API_TEST_REPO_VAR_20260629_030738_abc123
CODEX_API_TEST_ORG_SECRET_20260629_030742_def456
CODEX_API_TEST_ENV_VAR_20260629_030745_ghi789
Isolation Strategy¶
Test Data Persistence: - Each test creates timestamped variables with unique suffixes - Tests never collide due to timestamp uniqueness - Cleanup: Optional - variables auto-expire after 24 hours or explicit deletion
Scope Separation:
- Repository-scope test variables: CODEX_API_TEST_REPO_*
- Organization-scope test variables: CODEX_API_TEST_ORG_*
- Environment-scope test variables: CODEX_API_TEST_ENV_*
Batch Operation Testing:
- Multiple variables with same timestamp but different purposes
- Enables validating concurrent/batch creation, update, deletion
- Query pattern: Filter by CODEX_API_TEST_{PURPOSE}_{TIMESTAMP}
Rate Limit Handling¶
Test variable naming does NOT include rate limit tokens. Test infrastructure tracks rate limits separately via:
- X-RateLimit-Remaining header inspection
- Exponential backoff on 429 responses
- .codex/CODEX_MASTER_KEY_AUDIT_TRAIL.jsonl for audit logging
Integration with Test Fixtures¶
From tests/github/conftest_codex_master_key.py:
@pytest.fixture
def test_repo_var_name() -> str:
"""Generate timestamped test variable name."""
timestamp = datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S")
random_suffix = secrets.token_hex(3) # 6 chars
return f"CODEX_API_TEST_REPO_VAR_{timestamp}_{random_suffix}"
def test_create_variable(github_token: str, test_repo_var_name: str):
"""Test creating a variable with proper naming."""
# Variable automatically has unique, timestamped name
# Query and cleanup are trivial due to naming convention
References¶
- REST API: Actions Secrets
- REST API: Actions Variables
- REST API: Dependabot Secrets
- REST API: Codespaces Secrets
- GitHub CLI Manual
- GitHub MCP Server README
- MCP Server Configuration
- This repo: GITHUB_API_COPILOT_AGENT_REFERENCE.md
- This repo: COPILOT_MCP_TOOL_REFERENCE.md
- CODEX_MASTER_KEY Capabilities
- CODEX_MASTER_KEY Test Guide