Skip to content

Capture flags: --tag, --deploy-config with --reload-wait, --export-trace with --phoenix-url and --phoenix-project - #1

Open
claytondukes wants to merge 7 commits into
mainfrom
capture-flags
Open

claytondukes wants to merge 7 commits into
mainfrom
capture-flags

Conversation

@claytondukes

@claytondukes claytondukes commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three flags that let a customer capture a run the way LogZilla's certification harness does, so a model tested in their own lab compares like for like with a published row:

  • --tag TAG: the saved files go under <save-dir>/<tag>/, one directory per model or hardware setup (needs --save-dir; letters, digits, ., _, -).
  • --deploy-config PATH with --reload-wait SECONDS (default 30): before the first question, scp the ai.yaml to /etc/logzilla/settings/ai.yaml as root, ssh root@<host> logzilla settings reload ai, wait. A failed step stops the run with the remote's own message. With --save-dir, a copy is saved as ai-config.yaml with every *_KEY, *_TOKEN and API_KEY value replaced by <redacted>.
  • --export-trace with --phoenix-url and --phoenix-project (or LZ_PHOENIX_URL / LZ_PHOENIX_PROJECT, or the --deploy-config file's TRACING_SERVER_URL / TRACING_PROJECT_NAME): after each answer, the question's trace is found on Phoenix (root spans inside the question's window, five seconds of slack, candidates exported and matched on the question text, never guessed) and saved as <timestamp>-<slug>-trace.json beside the result. A missing or ambiguous trace is an error for that question ("trace": {"status": ...} in the JSON, exit 2), because a run without its trace cannot be scored.

The JSON result gains a trace object when the export ran. The GraphQL queries are the ones the harness uses against Phoenix's schema (node(id: ID!), Project.spans(first: Int!, timeRange, filterCondition: "parent_id is None"), getTraceByOtelId). No new dependency: requests carries the GraphQL calls, the config copy is redacted line by line.

Verification

  • python3 -m unittest discover -s tests -v on d34f6d2 -> Ran 22 tests, OK (the redaction incl. quoted keys, block scalars, continuation lines and the refused flow style; the tracing settings with trailing comments; the tag pattern and directory; the IPv6 scp target; the trace match: exported, missing, ambiguous, over the cap, a longer question not matched; the bounded ingestion wait and the lazily resolved project; a Phoenix failure as a recorded trace error; the lookup off the event-loop thread).
  • python3 -m py_compile lz-ai-query.py; --help renders the new capture group and the example.
  • Written against Python 3.8 syntax (no union types, no removeprefix, no walrus); checked by reading, not run on 3.8.
  • Not exercised against a live server from this branch: the same three steps run in LogZilla's harness against the lab server with the same GraphQL queries.

Review rounds

Three Copilot rounds, every finding fixed RED-first (a failing test committed before the fix): round 1 seven threads (the redaction's quoted keys and block scalars, substring trace matching, YAML comments kept in values, the IPv6 scp target, no ingestion wait, a Phoenix failure discarding a captured answer, the project looked up before its first trace); round 2 two threads (secrets continued on the lines below the key, the lookup blocking the event loop); round 3 one suppressed finding (a flow-style secret, now refused before the deploy). Converged; the merge is LogZilla's call, the tool being customer-facing.

…ag, --deploy-config with --reload-wait, --export-trace with --phoenix-url and --phoenix-project
Copilot AI balanced review requested due to automatic review settings October 29, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved defects can leave plaintext credentials in saved configuration and export unrelated traces, while project lookup and trace-export failures can abort otherwise valid runs.

7 open issues
What changed in this PR

Adds capture options to the query CLI so lab runs can save configuration, results, and Phoenix traces for comparison with LogZilla’s certification results.

Changes:

  • Adds tagged output directories and remote AI configuration deployment with a reload wait and redacted configuration copy.
  • Adds Phoenix trace lookup, export, and per-question trace status.
  • Documents the capture workflow and adds tests for redaction, configuration parsing, tags, and trace matching.
File Description
tests/​test_capture.py Adds focused tests for capture helpers and trace matching.
README.md Documents capture flags, workflow, and trace failure behavior.
lz-ai-query.py Implements deployment, tagged output, configuration redaction, and trace export.
.env.example Adds optional Phoenix server and project settings.

Review effort: Balanced

Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
…comment, an IPv6 scp target, a whole-string trace match, the ingestion wait, the project resolved at the first trace, a Phoenix failure recorded on the question
…a trailing YAML comment is not part of a tracing setting; scp keeps an IPv6 literal's brackets; the trace match is on the whole question string; the lookup waits --trace-wait seconds for ingestion and resolves the project then; a Phoenix failure is recorded on the question, the answer saved
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread lz-ai-query.py Resolved
Comment thread lz-ai-query.py Resolved
… the trace lookup runs off the event loop thread
… value on the next line, a multi-line quoted or plain scalar) with its header; the trace lookup runs in a worker thread so an open conversation socket keeps its heartbeat
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Flow-style YAML bypasses the anchored key regex, allowing plaintext API credentials to be copied into ai-config.yaml despite the redaction guarantee.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Flow-style YAML secrets bypass redaction

lz-ai-query.py:711

A flow-style YAML document such as {"MODEL_TYPE": "anthropic", "API_KEY": "sk-live-secret"} never matches the anchored key regex, so this branch copies the credential verbatim into ai-config.yaml. This leaves plaintext secrets in the artifact despite the redaction guarantee. Please handle secret values structurally, or reject unsupported YAML forms before saving the copy, and add a regression case for a flow-style document.

2 resolved since last review

Review effort: Balanced

…low-style mapping, an inline value) refuses the run before the deploy instead of saving the credential
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:24
@claytondukes

Copy link
Copy Markdown
Contributor Author

Copilot suppressed finding fixed - e0663f2d020a in d34f6d2

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A critical redaction bypass leaves plaintext credentials in saved ai-config.yaml files when a secret value starts on the line after its key.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants