Skip to content

fix(e2e): preserve Deep Agents TUI markers - #5908

Merged
cv merged 2 commits into
mainfrom
fix/deepagents-tui-capture-markers
Jun 27, 2026
Merged

fix(e2e): preserve Deep Agents TUI markers#5908
cv merged 2 commits into
mainfrom
fix/deepagents-tui-capture-markers

Conversation

@cv

@cv cv commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Preserves Deep Agents TUI expect harness markers in the sanitized capture file. The post-#5905 rerun showed the expect harness reached startup and observed exit, but its markers were only printed to expect stdout and did not survive into the capture file checked by the assertions.

Changes

  • Adds an expect append_marker helper that writes readiness, timeout/EOF, and exit markers directly to the capture file.
  • Keeps the existing strict prompt and clean-exit assertions unchanged.
  • Extends the Deep Agents image contract test to assert marker preservation.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: live E2E harness behavior only.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: self-review; capture-marker persistence only, strict TUI assertions remain in place.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Targeted verification:

bash -n test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh
npm test -- --run test/deepagents-code-tui-startup-check.test.ts test/langchain-deepagents-code-image.test.ts
npm run typecheck:cli

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Tests
    • Improved Deep Agents Code TUI startup/exit-state checks by validating multiple lifecycle markers (readiness, timeout/error/EOF before readiness, and exit capture with timeout/EOF around exit) to make automation more dependable.
    • Added coverage to ensure startup sanitization preserves the lifecycle marker strings in the generated sanitized capture artifact.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv self-assigned this Jun 27, 2026
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a767f501-f28f-414a-96e7-36660af39f85

📥 Commits

Reviewing files that changed from the base of the PR and between 34015e0 and 2ce9589.

📒 Files selected for processing (2)
  • test/deepagents-code-tui-startup-check.test.ts
  • test/langchain-deepagents-code-image.test.ts

📝 Walkthrough

Walkthrough

The TUI startup harness now appends lifecycle markers directly to the capture file during readiness, timeout, EOF, and exit handling. Tests were updated to verify the sanitized capture preserves those markers and to assert the broader marker set in the image test.

Changes

Deep Agents Code TUI marker persistence

Layer / File(s) Summary
append_marker proc and lifecycle branch updates
test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh
New append_marker Tcl proc appends marker strings to the raw capture file. Readiness, timeout, EOF-before-ready, exit-status capture, timeout, and EOF-before-exit branches all call append_marker in addition to puts.
Sanitized capture verification
test/deepagents-code-tui-startup-check.test.ts, test/langchain-deepagents-code-image.test.ts
Adds a test that runs the startup check with capture-file markers and verifies the sanitized log contains readiness and exit markers. The image test expands its startup assertions to cover READY, pre-READY timeout/EOF, exit capture, and pre-exit timeout/EOF markers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#5839: Introduced the Deep Agents Code TUI startup check script and the corresponding image-test assertions that this PR extends.

Suggested labels

integration: dcode

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving Deep Agents TUI markers in e2e checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deepagents-tui-capture-markers

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the fix/deepagents-tui-c... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/deepagents-tui-c... 2ce9589 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the fix/deepagents-tui-c... branch is 67%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/deepagents-tui-c... 2ce9589 +/-
src/lib/actions...all/run-plan.ts 80%
src/lib/state/o...oard-session.ts 79%
src/lib/actions...dbox/rebuild.ts 74%
src/lib/state/sandbox.ts 72%
src/lib/shields/index.ts 70%
src/lib/onboard/preflight.ts 69%
src/lib/actions...licy-channel.ts 59%
src/lib/onboard...er-gpu-patch.ts 59%
src/lib/policy/index.ts 52%
src/lib/onboard.ts 20%

Updated June 27, 2026 20:42 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor (Nemotron Ultra) — Changes requested

Merge posture: Do not merge yet
Primary next action: Resolve or justify PRA-1: Source-of-truth review needed: append_marker Tcl file write.
Open items: 0 required · 6 warnings · 2 suggestions · 8 test follow-ups
Since last review: 2 prior items resolved · 0 still apply · 4 new items found

Action checklist

  • PRA-1 Resolve or justify: Source-of-truth review needed: append_marker Tcl file write
  • PRA-2 Resolve or justify: DEEPAGENTS_TUI_CAPTURE_DIR path traversal risk in make_capture_dir in test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:112
  • PRA-3 Resolve or justify: Secret redaction may miss secrets adjacent to new NEMOCLAW_TUI_* markers in test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:120
  • PRA-4 Resolve or justify: TUI_READY_PATTERN and TUI_TIMEOUT env vars reach expect script; verify injection mitigations in test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:21
  • PRA-5 Resolve or justify: Unit test mocks run_tui_expect; does not exercise real Tcl append_marker proc in test/deepagents-code-tui-startup-check.test.ts:105
  • PRA-6 Resolve or justify: append_marker has no error handling for Tcl file write failures in test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123
  • PRA-T1 Add or justify test follow-up: Mocked behavioral coverage
  • PRA-T2 Add or justify test follow-up: Mocked behavioral coverage
  • PRA-T3 Add or justify test follow-up: Mocked behavioral coverage
  • PRA-T4 Add or justify test follow-up: Mocked behavioral coverage
  • PRA-T5 Add or justify test follow-up: Unit test mocks run_tui_expect; does not exercise real Tcl append_marker proc
  • PRA-T6 Add or justify test follow-up: append_marker has no error handling for Tcl file write failures
  • PRA-T7 Add or justify test follow-up: Prior duplicate NEMOCLAW_TUI_READY assertion resolved by refactoring
  • PRA-T8 Add or justify test follow-up: append_marker Tcl file write
  • PRA-7 In-scope improvement: Prior duplicate NEMOCLAW_TUI_READY assertion resolved by refactoring in test/langchain-deepagents-code-image.test.ts:460
  • PRA-8 In-scope improvement: append_marker proc opens/closes file per marker write — idiomatic Tcl, appropriate for 6 calls in test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-2 Resolve/justify security test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:112 Harden make_capture_dir: resolve DEEPAGENTS_TUI_CAPTURE_DIR to absolute path, verify it's under safe base (${TMPDIR:-/tmp}), reject traversal attempts.
PRA-3 Resolve/justify security test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:120 Add test case where secret appears on same line or adjacent to NEMOCLAW_TUI_READY marker to verify redaction preserves markers while redacting secrets.
PRA-4 Resolve/justify security test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:21 Confirm TUI_READY_PATTERN never overridden by external input. Confirm is_positive_integer validation runs before run_tui_expect call.
PRA-5 Resolve/justify tests test/deepagents-code-tui-startup-check.test.ts:105 Add integration-style test that spawns real expect script (or minimal version) to verify append_marker writes all 6 markers to capture file in real Tcl interpreter.
PRA-6 Resolve/justify tests test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123 Add test for append_marker write failure scenario; consider adding Tcl catch around write ops for defense in depth.
PRA-7 Improvement tests test/langchain-deepagents-code-image.test.ts:460 No action needed. The refactoring implicitly resolved the prior duplicate-assertion suggestion.
PRA-8 Improvement architecture test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123 No action needed. Implementation is appropriate for the use case.
Review findings by urgency: 0 required fixes, 6 items to resolve/justify, 2 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Source-of-truth review needed: append_marker Tcl file write

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: NONE — missing test for write failure scenario
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: append_marker proc at lines 123-127 in shell script; no catch or error handling

PRA-2 Resolve/justify — DEEPAGENTS_TUI_CAPTURE_DIR path traversal risk in make_capture_dir

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:112
  • Category: security
  • Problem: make_capture_dir() uses mkdir -p on DEEPAGENTS_TUI_CAPTURE_DIR without path validation. If attacker controls this env var (e.g., ../../../etc), append_marker proc writes arbitrary files on host via Tcl open $capture a. The capture dir is created on host, not in sandbox.
  • Impact: Host filesystem write outside intended capture directory. CI-only script but env var lacks defense-in-depth.
  • Recommended action: Harden make_capture_dir: resolve DEEPAGENTS_TUI_CAPTURE_DIR to absolute path, verify it's under safe base (${TMPDIR:-/tmp}), reject traversal attempts.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check make_capture_dir() at line 112; search for DEEPAGENTS_TUI_CAPTURE_DIR assignments in CI workflows to confirm trusted-only.
  • Missing regression test: Test that DEEPAGENTS_TUI_CAPTURE_DIR=../../../etc/passwd cannot escape capture directory via append_marker writes
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check make_capture_dir() at line 112; search for DEEPAGENTS_TUI_CAPTURE_DIR assignments in CI workflows to confirm trusted-only.
  • Evidence: make_capture_dir() at line 112: mkdir -p "$DEEPAGENTS_TUI_CAPTURE_DIR" with no validation; append_marker at line 123 opens $capture for append

PRA-3 Resolve/justify — Secret redaction may miss secrets adjacent to new NEMOCLAW_TUI_* markers

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:120
  • Category: security
  • Problem: New markers (READY, TIMEOUT, EOF_BEFORE_READY, EXIT_CAPTURED, EXIT_TIMEOUT, EOF_BEFORE_EXIT) are written to raw capture before sanitization/redaction pipeline. No test verifies secrets on same/adjacent lines as markers still get redacted while markers preserved.
  • Impact: Secret leakage in sanitized capture artifact if secret appears alongside markers.
  • Recommended action: Add test case where secret appears on same line or adjacent to NEMOCLAW_TUI_READY marker to verify redaction preserves markers while redacting secrets.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run new test 'preserves TUI lifecycle markers in the sanitized capture artifact' and verify it also checks secret redaction still works with markers present.
  • Missing regression test: Test that secret appearing as 'NEMOCLAW_TUI_READY\nsk-abc123\nNEMOCLAW_TUI_EXIT_CAPTURED:130' gets redacted to 'NEMOCLAW_TUI_READY\n[REDACTED_SECRET]\nNEMOCLAW_TUI_EXIT_CAPTURED:130'
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run new test 'preserves TUI lifecycle markers in the sanitized capture artifact' and verify it also checks secret redaction still works with markers present.
  • Evidence: append_marker writes markers to raw capture at lines 120-160; redact_secrets_in_file runs after sanitization at line 230

PRA-4 Resolve/justify — TUI_READY_PATTERN and TUI_TIMEOUT env vars reach expect script; verify injection mitigations

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:21
  • Category: security
  • Problem: NEMOCLAW_TUI_READY_PATTERN and NEMOCLAW_TUI_TIMEOUT passed to expect script via env. TUI_READY_PATTERN is static constant (line 21) — safe. TUI_TIMEOUT validated by is_positive_integer (line 186) before run_tui_expect — safe. No injection vector confirmed but verification needed.
  • Impact: Potential Tcl injection if validation bypassed or env vars overridden.
  • Recommended action: Confirm TUI_READY_PATTERN never overridden by external input. Confirm is_positive_integer validation runs before run_tui_expect call.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search for TUI_READY_PATTERN assignments — only static constant at line 21. Verify is_positive_integer call at line 186 precedes run_tui_expect.
  • Missing regression test: Test that malicious DEEPAGENTS_TUI_TIMEOUT='90; exec rm -rf /' is rejected by is_positive_integer before reaching expect
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search for TUI_READY_PATTERN assignments — only static constant at line 21. Verify is_positive_integer call at line 186 precedes run_tui_expect.
  • Evidence: TUI_READY_PATTERN constant at line 21; is_positive_integer validation at line 186; run_tui_expect called at line 220

PRA-5 Resolve/justify — Unit test mocks run_tui_expect; does not exercise real Tcl append_marker proc

  • Location: test/deepagents-code-tui-startup-check.test.ts:105
  • Category: tests
  • Problem: New test 'preserves TUI lifecycle markers' mocks run_tui_expect with shell function that directly printf's to capture — bypasses actual Tcl append_marker proc. 4/6 marker code paths (TIMEOUT, EOF_BEFORE_READY, EXIT_TIMEOUT, EOF_BEFORE_EXIT) untested in unit test.
  • Impact: No verification that real Tcl append_marker works correctly under expect interpreter; partial branch coverage.
  • Recommended action: Add integration-style test that spawns real expect script (or minimal version) to verify append_marker writes all 6 markers to capture file in real Tcl interpreter.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check if existing E2E runs exercise the real expect script with markers; search for expect invocations in CI workflows.
  • Missing regression test: E2E test that spawns real expect with append_marker and verifies all 6 markers appear in sanitized capture
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check if existing E2E runs exercise the real expect script with markers; search for expect invocations in CI workflows.
  • Evidence: Test at lines 105-140 mocks run_tui_expect; contract test only asserts append_marker call strings exist in source

PRA-6 Resolve/justify — append_marker has no error handling for Tcl file write failures

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123
  • Category: tests
  • Problem: append_marker proc uses Tcl open/puts/close without error handling. If write fails (permissions, disk full, bad path), Tcl error propagates as expect non-zero exit (caught by expect_rc), but silent partial-write corruption not tested.
  • Impact: Marker loss or corrupted capture without clear failure signal in some edge cases.
  • Recommended action: Add test for append_marker write failure scenario; consider adding Tcl catch around write ops for defense in depth.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review append_marker proc at lines 123-127; no catch or error handling present.
  • Missing regression test: Test that append_marker handles file write failure gracefully (or fails closed with clear error)
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review append_marker proc at lines 123-127; no catch or error handling present.
  • Evidence: append_marker proc at lines 123-127: set fh [open $capture a]; puts $fh $marker; close $fh

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

PRA-7 Improvement — Prior duplicate NEMOCLAW_TUI_READY assertion resolved by refactoring

  • Location: test/langchain-deepagents-code-image.test.ts:460
  • Category: tests
  • Problem: Contract test now asserts append_marker calls instead of raw marker strings. The previous duplicate NEMOCLAW_TUI_READY assertion (PRA-1 from prior review) is implicitly resolved since the old raw-string assertions are replaced.
  • Impact: Minor test noise eliminated; no functional impact.
  • Suggested action: No action needed. The refactoring implicitly resolved the prior duplicate-assertion suggestion.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for NEMOCLAW_TUI_READY in test/langchain-deepagents-code-image.test.ts — only append_marker assertions remain.
  • Missing regression test: N/A — prior suggestion resolved by refactoring
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Contract test lines 460-475 assert append_marker calls; old raw string assertions removed

PRA-8 Improvement — append_marker proc opens/closes file per marker write — idiomatic Tcl, appropriate for 6 calls

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123
  • Category: architecture
  • Problem: append_marker proc opens, writes, and closes the capture file for each of 6 marker writes. Prior review (PRA-2) noted this is idiomatic Tcl and fine for 6 writes. The PR now formalizes this pattern.
  • Impact: None — current approach is correct and simple. No performance concern for 6 writes.
  • Suggested action: No action needed. Implementation is appropriate for the use case.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Review append_marker proc and its 6 call sites in run_tui_expect.
  • Missing regression test: N/A — architectural observation
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Proc defined at line 123, called at READY (133), TIMEOUT (140), EOF_BEFORE_READY (147), EXIT_CAPTURED (154), EXIT_TIMEOUT (161), EOF_BEFORE_EXIT (168)
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Mocked behavioral coverage — secret on same line as NEMOCLAW_TUI_READY survives redaction with marker preserved. Unit test mocks expect script (bypasses real Tcl append_marker); contract test only static assertions. Missing integration test with real expect, secret+marker collision test, path traversal test, and 4/6 marker branch coverage.
  • PRA-T2 Mocked behavioral coverage — DEEPAGENTS_TUI_CAPTURE_DIR with path traversal attempt is contained. Unit test mocks expect script (bypasses real Tcl append_marker); contract test only static assertions. Missing integration test with real expect, secret+marker collision test, path traversal test, and 4/6 marker branch coverage.
  • PRA-T3 Mocked behavioral coverage — real expect script with append_marker writes all 6 markers to capture file. Unit test mocks expect script (bypasses real Tcl append_marker); contract test only static assertions. Missing integration test with real expect, secret+marker collision test, path traversal test, and 4/6 marker branch coverage.
  • PRA-T4 Mocked behavioral coverage — append_marker handles file write failure gracefully (or fails closed). Unit test mocks expect script (bypasses real Tcl append_marker); contract test only static assertions. Missing integration test with real expect, secret+marker collision test, path traversal test, and 4/6 marker branch coverage.
  • PRA-T5 Unit test mocks run_tui_expect; does not exercise real Tcl append_marker proc — Add integration-style test that spawns real expect script (or minimal version) to verify append_marker writes all 6 markers to capture file in real Tcl interpreter.
  • PRA-T6 append_marker has no error handling for Tcl file write failures — Add test for append_marker write failure scenario; consider adding Tcl catch around write ops for defense in depth.
  • PRA-T7 Prior duplicate NEMOCLAW_TUI_READY assertion resolved by refactoring — No action needed. The refactoring implicitly resolved the prior duplicate-assertion suggestion.
  • PRA-T8 append_marker Tcl file write — NONE — missing test for write failure scenario. append_marker proc at lines 123-127 in shell script; no catch or error handling
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Source-of-truth review needed: append_marker Tcl file write

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: NONE — missing test for write failure scenario
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: append_marker proc at lines 123-127 in shell script; no catch or error handling

PRA-2 Resolve/justify — DEEPAGENTS_TUI_CAPTURE_DIR path traversal risk in make_capture_dir

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:112
  • Category: security
  • Problem: make_capture_dir() uses mkdir -p on DEEPAGENTS_TUI_CAPTURE_DIR without path validation. If attacker controls this env var (e.g., ../../../etc), append_marker proc writes arbitrary files on host via Tcl open $capture a. The capture dir is created on host, not in sandbox.
  • Impact: Host filesystem write outside intended capture directory. CI-only script but env var lacks defense-in-depth.
  • Recommended action: Harden make_capture_dir: resolve DEEPAGENTS_TUI_CAPTURE_DIR to absolute path, verify it's under safe base (${TMPDIR:-/tmp}), reject traversal attempts.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check make_capture_dir() at line 112; search for DEEPAGENTS_TUI_CAPTURE_DIR assignments in CI workflows to confirm trusted-only.
  • Missing regression test: Test that DEEPAGENTS_TUI_CAPTURE_DIR=../../../etc/passwd cannot escape capture directory via append_marker writes
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check make_capture_dir() at line 112; search for DEEPAGENTS_TUI_CAPTURE_DIR assignments in CI workflows to confirm trusted-only.
  • Evidence: make_capture_dir() at line 112: mkdir -p "$DEEPAGENTS_TUI_CAPTURE_DIR" with no validation; append_marker at line 123 opens $capture for append

PRA-3 Resolve/justify — Secret redaction may miss secrets adjacent to new NEMOCLAW_TUI_* markers

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:120
  • Category: security
  • Problem: New markers (READY, TIMEOUT, EOF_BEFORE_READY, EXIT_CAPTURED, EXIT_TIMEOUT, EOF_BEFORE_EXIT) are written to raw capture before sanitization/redaction pipeline. No test verifies secrets on same/adjacent lines as markers still get redacted while markers preserved.
  • Impact: Secret leakage in sanitized capture artifact if secret appears alongside markers.
  • Recommended action: Add test case where secret appears on same line or adjacent to NEMOCLAW_TUI_READY marker to verify redaction preserves markers while redacting secrets.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Run new test 'preserves TUI lifecycle markers in the sanitized capture artifact' and verify it also checks secret redaction still works with markers present.
  • Missing regression test: Test that secret appearing as 'NEMOCLAW_TUI_READY\nsk-abc123\nNEMOCLAW_TUI_EXIT_CAPTURED:130' gets redacted to 'NEMOCLAW_TUI_READY\n[REDACTED_SECRET]\nNEMOCLAW_TUI_EXIT_CAPTURED:130'
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Run new test 'preserves TUI lifecycle markers in the sanitized capture artifact' and verify it also checks secret redaction still works with markers present.
  • Evidence: append_marker writes markers to raw capture at lines 120-160; redact_secrets_in_file runs after sanitization at line 230

PRA-4 Resolve/justify — TUI_READY_PATTERN and TUI_TIMEOUT env vars reach expect script; verify injection mitigations

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:21
  • Category: security
  • Problem: NEMOCLAW_TUI_READY_PATTERN and NEMOCLAW_TUI_TIMEOUT passed to expect script via env. TUI_READY_PATTERN is static constant (line 21) — safe. TUI_TIMEOUT validated by is_positive_integer (line 186) before run_tui_expect — safe. No injection vector confirmed but verification needed.
  • Impact: Potential Tcl injection if validation bypassed or env vars overridden.
  • Recommended action: Confirm TUI_READY_PATTERN never overridden by external input. Confirm is_positive_integer validation runs before run_tui_expect call.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Search for TUI_READY_PATTERN assignments — only static constant at line 21. Verify is_positive_integer call at line 186 precedes run_tui_expect.
  • Missing regression test: Test that malicious DEEPAGENTS_TUI_TIMEOUT='90; exec rm -rf /' is rejected by is_positive_integer before reaching expect
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Search for TUI_READY_PATTERN assignments — only static constant at line 21. Verify is_positive_integer call at line 186 precedes run_tui_expect.
  • Evidence: TUI_READY_PATTERN constant at line 21; is_positive_integer validation at line 186; run_tui_expect called at line 220

PRA-5 Resolve/justify — Unit test mocks run_tui_expect; does not exercise real Tcl append_marker proc

  • Location: test/deepagents-code-tui-startup-check.test.ts:105
  • Category: tests
  • Problem: New test 'preserves TUI lifecycle markers' mocks run_tui_expect with shell function that directly printf's to capture — bypasses actual Tcl append_marker proc. 4/6 marker code paths (TIMEOUT, EOF_BEFORE_READY, EXIT_TIMEOUT, EOF_BEFORE_EXIT) untested in unit test.
  • Impact: No verification that real Tcl append_marker works correctly under expect interpreter; partial branch coverage.
  • Recommended action: Add integration-style test that spawns real expect script (or minimal version) to verify append_marker writes all 6 markers to capture file in real Tcl interpreter.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check if existing E2E runs exercise the real expect script with markers; search for expect invocations in CI workflows.
  • Missing regression test: E2E test that spawns real expect with append_marker and verifies all 6 markers appear in sanitized capture
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check if existing E2E runs exercise the real expect script with markers; search for expect invocations in CI workflows.
  • Evidence: Test at lines 105-140 mocks run_tui_expect; contract test only asserts append_marker call strings exist in source

PRA-6 Resolve/justify — append_marker has no error handling for Tcl file write failures

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123
  • Category: tests
  • Problem: append_marker proc uses Tcl open/puts/close without error handling. If write fails (permissions, disk full, bad path), Tcl error propagates as expect non-zero exit (caught by expect_rc), but silent partial-write corruption not tested.
  • Impact: Marker loss or corrupted capture without clear failure signal in some edge cases.
  • Recommended action: Add test for append_marker write failure scenario; consider adding Tcl catch around write ops for defense in depth.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Review append_marker proc at lines 123-127; no catch or error handling present.
  • Missing regression test: Test that append_marker handles file write failure gracefully (or fails closed with clear error)
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Review append_marker proc at lines 123-127; no catch or error handling present.
  • Evidence: append_marker proc at lines 123-127: set fh [open $capture a]; puts $fh $marker; close $fh

PRA-7 Improvement — Prior duplicate NEMOCLAW_TUI_READY assertion resolved by refactoring

  • Location: test/langchain-deepagents-code-image.test.ts:460
  • Category: tests
  • Problem: Contract test now asserts append_marker calls instead of raw marker strings. The previous duplicate NEMOCLAW_TUI_READY assertion (PRA-1 from prior review) is implicitly resolved since the old raw-string assertions are replaced.
  • Impact: Minor test noise eliminated; no functional impact.
  • Suggested action: No action needed. The refactoring implicitly resolved the prior duplicate-assertion suggestion.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for NEMOCLAW_TUI_READY in test/langchain-deepagents-code-image.test.ts — only append_marker assertions remain.
  • Missing regression test: N/A — prior suggestion resolved by refactoring
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Contract test lines 460-475 assert append_marker calls; old raw string assertions removed

PRA-8 Improvement — append_marker proc opens/closes file per marker write — idiomatic Tcl, appropriate for 6 calls

  • Location: test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh:123
  • Category: architecture
  • Problem: append_marker proc opens, writes, and closes the capture file for each of 6 marker writes. Prior review (PRA-2) noted this is idiomatic Tcl and fine for 6 writes. The PR now formalizes this pattern.
  • Impact: None — current approach is correct and simple. No performance concern for 6 writes.
  • Suggested action: No action needed. Implementation is appropriate for the use case.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Review append_marker proc and its 6 call sites in run_tui_expect.
  • Missing regression test: N/A — architectural observation
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Proc defined at line 123, called at READY (133), TIMEOUT (140), EOF_BEFORE_READY (147), EXIT_CAPTURED (154), EXIT_TIMEOUT (161), EOF_BEFORE_EXIT (168)

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: No advisor follow-up required beyond maintainer review.
Open items: 0 required · 0 warnings · 0 suggestions · 0 test follow-ups
Since last review: 2 prior items resolved · 0 still apply · 0 new items found

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: ubuntu-repo-cloud-langchain-deepagents-code

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. No merge-blocking E2E is required because all changed files are test or E2E-check assets, not runtime/user-flow implementation. The PR updates the live check’s own marker handling and corresponding contract tests; running the Deep Agents Code live scenario is useful but optional.

Optional E2E

  • ubuntu-repo-cloud-langchain-deepagents-code (high): Optional confidence run for the modified Deep Agents Code TUI startup check in a real hosted Deep Agents Code sandbox; this scenario runs the registered cloud-experimental checks including 10-deepagents-code-tui-startup.sh.

New E2E recommendations

  • None.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: ubuntu-repo-cloud-langchain-deepagents-code
Optional Vitest E2E scenarios: None

Dispatch required Vitest E2E scenarios:

  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-langchain-deepagents-code

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • ubuntu-repo-cloud-langchain-deepagents-code: The PR changes the Deep Agents Code TUI startup check script that is executed by the live Vitest registry scenario for cloud-langchain-deepagents-code onboarding. The smallest live-supported typed scenario that exercises this changed surface is ubuntu-repo-cloud-langchain-deepagents-code.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-langchain-deepagents-code

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/langchain-deepagents-code-image.test.ts`:
- Line 475: The assertion in the tuiStartupCheck test is checking the helper
name append_marker instead of the observable behavior; update this test to
verify the public E2E result emits the preserved lifecycle markers in the
sanitized capture artifact. Use the existing test block around tuiStartupCheck
and assert on the output content/signals that prove markers were actually
preserved, rather than matching the implementation detail.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ad46036b-b79f-4c84-b566-41a8068608fe

📥 Commits

Reviewing files that changed from the base of the PR and between a95e851 and 34015e0.

📒 Files selected for processing (2)
  • test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh
  • test/langchain-deepagents-code-image.test.ts

Comment thread test/langchain-deepagents-code-image.test.ts Outdated
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv

cv commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator Author

Automated review follow-up for head 2ce958997c978a5988b014a5a54d016b81f99939:

  • PRA-1: The localized source boundary is the E2E Expect capture. The invalid state was that Expect stdout lifecycle markers were not retained by log_file; upstream dcode has no stable machine-readable ready marker. The branch contracts plus the sanitized-artifact regression test cover the fix. This can be removed if upstream exposes stable machine-readable startup and exit signals.
  • PRA-2: DEEPAGENTS_TUI_CAPTURE_DIR is an intentional caller-owned test-artifact destination, not an untrusted runtime input or privilege boundary. Restricting it to /tmp would break CI-provided artifact directories.
  • PRA-3: Secret scanning/redaction runs over the complete merged capture with unanchored canonical patterns; marker adjacency does not bypass detection. Existing helper coverage exercises every canonical secret family and verifies retained-artifact redaction.
  • PRA-4: TUI_READY_PATTERN is a shell constant and is only exported into Expect; it is not externally overrideable. TUI_TIMEOUT is validated as a positive integer before run_tui_expect executes.
  • PRA-5: Exact writes for all six Tcl branches are pinned by the image contract, the public sanitized artifact behavior is pinned by test/deepagents-code-tui-startup-check.test.ts, and the live scenario exercises the real Expect path.
  • PRA-6: Tcl open/puts/close errors are intentionally uncaught: they terminate Expect nonzero, after which main records finite expect harness exited and fails closed. A catch would not improve the failure posture.
  • PRA-7/PRA-8: no action required, as the advisor notes.

CodeRabbit marked its original coverage finding addressed, the primary PR Review Advisor reports zero findings, DCO is green, and both commits are GitHub Verified.

@cv
cv enabled auto-merge (squash) June 27, 2026 20:43
@cv
cv disabled auto-merge June 27, 2026 20:55
@cv
cv merged commit 1c27f5b into main Jun 27, 2026
45 checks passed
@cv
cv deleted the fix/deepagents-tui-capture-markers branch June 27, 2026 20:55
@cv cv added the v0.0.69 label Jun 27, 2026
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary
Preserves Deep Agents TUI expect harness markers in the sanitized
capture file. The post-NVIDIA#5905 rerun showed the expect harness reached
startup and observed exit, but its markers were only printed to expect
stdout and did not survive into the capture file checked by the
assertions.

## Changes
- Adds an expect `append_marker` helper that writes readiness,
timeout/EOF, and exit markers directly to the capture file.
- Keeps the existing strict prompt and clean-exit assertions unchanged.
- Extends the Deep Agents image contract test to assert marker
preservation.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates
- [x] Tests added or updated for changed behavior
- [ ] Existing tests cover changed behavior — justification:
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: live E2E harness behavior
only.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: self-review;
capture-marker persistence only, strict TUI assertions remain in place.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification
- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [ ] Git hooks passed during commit and push, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [ ] Full `npm test` passes (broad runtime changes only)
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

Targeted verification:

```bash
bash -n test/e2e/e2e-cloud-experimental/checks/10-deepagents-code-tui-startup.sh
npm test -- --run test/deepagents-code-tui-startup-check.test.ts test/langchain-deepagents-code-image.test.ts
npm run typecheck:cli
```

---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Improved Deep Agents Code TUI startup/exit-state checks by validating
multiple lifecycle markers (readiness, timeout/error/EOF before
readiness, and exit capture with timeout/EOF around exit) to make
automation more dependable.
* Added coverage to ensure startup sanitization preserves the lifecycle
marker strings in the generated sanitized capture artifact.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure bug-fix PR fixes a bug or regression integration: dcode LangChain Deep Code integration behavior labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure bug-fix PR fixes a bug or regression integration: dcode LangChain Deep Code integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants