Skip to content

Fix reference adapter follow-ups from review - #620

Closed
drk-ram wants to merge 1 commit into
GenAI-Security-Project:integrationfrom
drk-ram:fix/adapter-followups-509
Closed

drk-ram wants to merge 1 commit into
GenAI-Security-Project:integrationfrom
drk-ram:fix/adapter-followups-509

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What changed

Resolves all five reference-adapter follow-ups tracked in the review backlog:

  1. Sidecar lock on load_session_state (adapters/src/acs/client/_store.py): Extract _load_unlocked(path) for the raw read inside update_session_state and acquire _locked(path) in load_session_state so concurrent readers on Windows cannot block os.replace with PermissionError and drop session-state updates.
  2. Sub-second disambiguated backup filenames (adapters/src/acs/integrations/_settings_file.py and adapters/src/acs/integrations/nat/wire.py): Add _backup_path(target) with microseconds (%Y%m%dT%H%M%S_%f) and a collision counter suffix (.1, .2, ...) so two wire runs within the same second never overwrite a backup.
  3. Raise ImportError instead of sys.exit(2) in nat/wire.py (adapters/src/acs/integrations/nat/wire.py): When ruamel.yaml is missing, raise ImportError from the underlying exception so pytest tests does not abort at collection when the nat extra is not installed.
  4. Parse JSON-string tool_input on Cursor preToolUse (adapters/src/acs/integrations/cursor/adapter.py): Parse tool_input / arguments with _parse_json_field in _payload_pretool (wrapping non-dict values as {"raw_params": args}) and normalize original_input in translate_response, matching _payload_before_mcp so stringified preToolUse inputs are evaluated by the Guardian instead of raising in _wrap_arguments and failing open under ACS_DEFAULT_DENY=0.
  5. Document default-deny effects (adapters/README.md and adapters/docs/claude_code/README.md): State under **Degraded-Guardian behavior.** and in the Claude Code README that a slow or unreachable Guardian on Claude Code withholds a tool's output after PostToolUse, and that if the adapter fails to import it proceeds only when the agent's local config sets both ACS_STARTUP_POSTURE=proceed and ACS_DEFAULT_DENY=0.

Which issue does this implement

Closes #509
Refs #22, #483

  • This is an editorial correction (typo, grammar, link, formatting) with no change in
    meaning, so it needs no issue

Base branch

  • integration, because this touches the specification, schemas, a reference
    implementation, an adapter, tests, or CI
  • main, because every changed path is on the documentation lane allowlist in
    CONTRIBUTING.md

Type of change

  • Specification change (schema, hooks, events, AgBOM)
  • Reference implementation or adapter
  • Documentation
  • Tooling or CI
  • Governance (licensing, security policy, contributor docs)

I tested this

  • I synced my branch with the base branch before opening this
  • uv run pytest -v passes on my machine
  • uv run mkdocs build --strict passes on my machine

Validation commands run and results:

  • python -m unittest tests.client.test_store tests.common.test_hook_command.WrittenCommandsAndFiles.test_two_writes_in_the_same_second_keep_both_backups tests.integrations.nat.test_wire tests.integrations.cursor.test_adapter.JsonStringToolInputOnPreToolUse (passed: 17 tests, 8 expected NAT skips without nat extra)
  • pytest tests --collect-only -q in adapters/ (passed: 1391 tests collected without SystemExit)
  • pytest tests/client/test_store.py tests/integrations/nat/test_wire.py -q in adapters/ (passed: 7 passed, 8 skipped, 4 subtests passed)
  • pytest tests/test_landing_page.py tests/test_site_nav.py -q at repo root (passed: 69 passed)

Checklist

  • Commits are signed off with git commit -s (required by the DCO)
  • Prose follows STYLE.md
  • No secrets, tokens, or internal URLs in the diff

Security

  • This change has no security impact

…review

- Acquire the sidecar lock in load_session_state and read via
  _load_unlocked inside update_session_state so concurrent readers on
  Windows cannot block os.replace and drop state updates.
- Include microseconds and a collision counter in _backup_path so two
  wire runs within the same second never overwrite a backup.
- Raise ImportError instead of calling sys.exit(2) in nat/wire.py when
  ruamel.yaml is absent so pytest collection does not abort without the
  nat extra.
- Parse JSON-stringified tool_input in Cursor _payload_pretool and
  translate_response so stringified preToolUse inputs are evaluated by
  the Guardian instead of raising in _wrap_arguments.
- Document the two default-deny effects in adapters/README.md and
  adapters/docs/claude_code/README.md (PostToolUse output withholding on
  slow/unreachable Guardian, and ImportError requiring both
  ACS_STARTUP_POSTURE=proceed and ACS_DEFAULT_DENY=0 to proceed).

Closes GenAI-Security-Project#509

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Thanks for this. It is queued rather than ignored. A lead has not reviewed this pull request yet. A lead will read it when they have time, and we can't promise a date. Nothing here is rejected. If a check below fails, please fix it. A pull request that waits a long time may be closed, and you can reopen it later.

@github-actions

Copy link
Copy Markdown

This pull request's description says it closes #509, which is on the project roadmap. When it merges, GitHub closes that issue and the roadmap counts it as delivered. Please confirm the change delivers the whole issue before merging.

@bar-capsule

Copy link
Copy Markdown
Collaborator

@drk-ram closing this: #509 is assigned to me. Please check who holds an issue before starting on it. If you'd like to help with one, ask on the issue and wait until a lead assigns it to you, as how work gets accepted describes (D-041). A PR on work someone else holds duplicates their effort and takes review time away from the planned work.

@github-project-automation github-project-automation Bot moved this from Needs triage to Done in ACS Project Tracker Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Not yet triaged. Applied by the issue forms

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Reference adapter follow-ups from the PR #22 review

2 participants