Commit 7bf427e
fix(sandbox): harden PR 6065 advisor follow-ups (#6068)
## Summary
Follow-up to merged PR #6065 to address the unaddressed PR Review
Advisor warnings:
- Adds safe gateway-log append helper for PID 1/root recovery warnings;
refuses symlink/non-regular/replaced log targets instead of appending
through them.
- Adds guard-chain recovery tests proving regular log append still works
and unsafe targets are refused.
- Adds focused reconciliation coverage proving `NEMOCLAW_MODEL_OVERRIDE`
wins over conflicting gateway state, plus no-override reconciliation
still runs.
## Test plan
- [x] `npx vitest run --project integration
test/nemoclaw-start-reconcile.test.ts
test/nemoclaw-start-guard-recovery.test.ts`
Refs #6065
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Hardened gateway log writing to refuse unsafe targets (non-regular,
swapped, invalid), while sanitizing and newline-terminating log lines in
UTF-8.
* Recovery now records restoration warnings in the gateway log when
safe, without blocking startup if logging fails.
* Reconcile behavior improved: explicit model overrides are preserved;
otherwise configuration is reconciled from the live gateway model.
* **Tests**
* Expanded gateway recovery coverage with
regular/symlink/directory/missing log scenarios, validating behavior via
gateway-log contents.
* Added reconcile tests for overridden vs non-overridden behavior.
* Updated gateway health watchdog tests to direct critical logging to
controlled per-test log files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Advisor disposition / E2E evidence
PR Review Advisor `PRA-1` / `PRA-2` runtime-validation warnings are
resolved by the combination of in-PR helper hardening coverage plus live
E2E evidence:
- Source boundary: `append_openclaw_gateway_log_line` is the permanent
PID 1 append boundary and hardcodes canonical `/tmp/gateway.log`; it
intentionally refuses symlink, non-regular, replaced, or missing log
targets rather than honoring inherited path seams.
- Source-fix constraint: startup remains responsible for pre-creating
canonical `/tmp/gateway.log`; recovery/watchdog append paths must not
create a missing log because creation at recovery time would re-open the
unsafe target/ownership ambiguity this PR removes.
- Regression/unit coverage: `test/nemoclaw-start-guard-recovery.test.ts`
covers regular append, symlink refusal, non-regular refusal, missing-log
no-create, replaced-target refusal, inherited env ignored, and newline
sanitization. `test/nemoclaw-start-gateway-health.test.ts` covers
watchdog CRITICAL breadcrumb append through the same safe helper.
- Runtime validation: current-head E2E revalidation passed on
`9cda35bdaa6d426d160d262ac35c99c7449c1560`: run
https://github.com/NVIDIA/NemoClaw/actions/runs/28874860688 passed
required jobs `gateway-guard-recovery` and
`issue-2478-crash-loop-recovery`, and run
https://github.com/NVIDIA/NemoClaw/actions/runs/28874896411 passed
required target `ubuntu-repo-cloud-openclaw`. The earlier same-PR
artifact for `issue-2478-crash-loop-recovery` showed the real sandbox
respawn path emitted `[gateway-recovery] WARNING ... (#2478/#2701)` and
mirrored the same line as `[gateway-log:] [gateway-recovery] WARNING
...`, proving the real PID 1 startup/recovery lifecycle pre-created and
preserved the canonical gateway log before append.
- Removal condition: keep the helper-level contract tests until gateway
recovery/watchdog logging is no longer routed through `/tmp/gateway.log`
or the startup ownership contract is replaced by a different diagnostics
channel with equivalent live E2E coverage.
---------
Signed-off-by: cjagwani <cjagwani@nvidia.com>
Co-authored-by: cjagwani <cjagwani@nvidia.com>1 parent 778811d commit 7bf427e
4 files changed
Lines changed: 340 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4448 | 4448 | | |
4449 | 4449 | | |
4450 | 4450 | | |
4451 | | - | |
4452 | | - | |
4453 | | - | |
| 4451 | + | |
4454 | 4452 | | |
4455 | 4453 | | |
4456 | 4454 | | |
| |||
4796 | 4794 | | |
4797 | 4795 | | |
4798 | 4796 | | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
| 4805 | + | |
| 4806 | + | |
| 4807 | + | |
| 4808 | + | |
| 4809 | + | |
| 4810 | + | |
| 4811 | + | |
| 4812 | + | |
| 4813 | + | |
| 4814 | + | |
| 4815 | + | |
| 4816 | + | |
| 4817 | + | |
| 4818 | + | |
| 4819 | + | |
| 4820 | + | |
| 4821 | + | |
| 4822 | + | |
| 4823 | + | |
| 4824 | + | |
| 4825 | + | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
| 4832 | + | |
| 4833 | + | |
| 4834 | + | |
| 4835 | + | |
| 4836 | + | |
| 4837 | + | |
| 4838 | + | |
| 4839 | + | |
| 4840 | + | |
| 4841 | + | |
| 4842 | + | |
4799 | 4843 | | |
4800 | 4844 | | |
4801 | 4845 | | |
4802 | 4846 | | |
4803 | | - | |
| 4847 | + | |
| 4848 | + | |
| 4849 | + | |
| 4850 | + | |
| 4851 | + | |
4804 | 4852 | | |
4805 | 4853 | | |
4806 | 4854 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
81 | | - | |
| 88 | + | |
82 | 89 | | |
83 | 90 | | |
84 | 91 | | |
85 | 92 | | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
| |||
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| 135 | + | |
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| |||
135 | 144 | | |
136 | 145 | | |
137 | 146 | | |
138 | | - | |
| 147 | + | |
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| |||
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
161 | | - | |
162 | | - | |
163 | | - | |
| 170 | + | |
164 | 171 | | |
165 | 172 | | |
166 | 173 | | |
| |||
339 | 346 | | |
340 | 347 | | |
341 | 348 | | |
| 349 | + | |
| 350 | + | |
342 | 351 | | |
343 | 352 | | |
344 | 353 | | |
| |||
380 | 389 | | |
381 | 390 | | |
382 | 391 | | |
383 | | - | |
| 392 | + | |
384 | 393 | | |
385 | 394 | | |
386 | 395 | | |
| |||
0 commit comments