Menu

#3 Harden audit logging and output postcheck to resolve unresolved PR #2 review comments

open
nobody
None
2026-05-20
2026-05-20
Anonymous
No

Originally created by: Copilot

This PR addresses the remaining review-thread feedback on app/main.py, app/policy/gate.py, and app/observability/audit.py. The changes remove sensitive-data exposure paths in audit logs and align policy/check behavior with actual runtime behavior.

  • Input logging hardening
  • handle_input() now runs precheck before run_started logging.
  • Replaced raw input logging with safe metadata (classification, input_length).

  • Output logging hardening

  • run_completed no longer logs full output payload.
  • Completion audit event now emits only safe metadata (output_length).

  • Postcheck policy enforcement

  • postcheck() now performs a minimal sensitive-content check and redacts sensitive output as "[REDACTED]".
  • Updated function intent to match behavior.

  • Audit logging correctness

  • Removed import-time root logger configuration from audit.py (no global logging side effects on import).
  • Switched audit event emission from Python dict repr to JSON serialization for consistent machine parsing.

    :::python
    result = precheck_with_warning(user_input)
    log_event(run_id, "run_started", {
    "classification": result["classification"],
    "input_length": len(str(result["input"])),
    })

    checked_output = postcheck(output)
    log_event(run_id, "run_completed", {"output_length": len(str(checked_output))})

Discussion

  • Anonymous

    Anonymous - 2026-05-20
     
  • Anonymous

    Anonymous - 2026-05-20
     

Log in to post a comment.

Auth0 Logo