Commit 6fc834c
authored
fix(hermes): read API port from gateway identity (#9059)
<!-- markdownlint-disable MD041 -->
## Summary
Hermes MCP transactions now resolve the sandbox API port from the
validated same-identity gateway process. They no longer read the
protected service-manager environment, which OpenShell denies across
identities.
## Related Issue
Fixes #9044
## Changes
- Read `NEMOCLAW_HERMES_API_PORT` from `/proc/<gateway-pid>/environ`
after the existing gateway PID, owner, launcher, managed-parent, and
start-time checks.
- Recheck the gateway identity after the bounded environment read.
Reject an unavailable, oversized, malformed, ambiguous, or
identity-changed source without logging environment values.
- Add a real same-identity process regression test that fails when the
helper reads the service-manager PID. Keep focused negative tests for
access denial, invalid ports, duplicate values, and identity changes.
- Update the OpenShell 0.0.101 child-environment manifest with the
changed helper's exact SHA-256 integrity value and keep its
migration-review expectation aligned.
- Root cause: the per-sandbox port change selected the service manager
as the environment source. Existing tests mocked that cross-identity
read and did not exercise the Linux process boundary.
## 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: The API-port range, default,
onboarding input, MCP commands, and lifecycle behavior do not change.
- [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: The nine-category
review passed with no findings for commit `197b2c4160`:
#9059 (comment)
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:
## Documentation Writer Review
- [x] Documentation writer subagent reviewed the completed changes
- Result: `no-docs-needed`
- Evidence: The change corrects an internal Hermes MCP API-port lookup.
Existing documentation remains accurate for the environment-variable
range, default, onboarding input, MCP commands, and lifecycle behavior.
The reviewer found no blocker or writing suggestion.
- Agent: Codex Desktop
<!-- docs-review-head-sha: 197b2c4 -->
<!-- docs-review-agents-blob-sha: e30afb2 -->
## DGX Station Hardware Evidence
- [ ] Tested on DGX Station
- Tested commit:
- Station profile/scenario:
- Result:
- Supporting evidence:
## Verification
- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run validate:pr` passed after refreshing `origin/main` when hooks
were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run --project integration
test/hermes-mcp-api-port.test.ts test/hermes-mcp-probe-api-port.test.ts
test/hermes-mcp-config-transaction.test.ts
test/hermes-mcp-apply-race.test.ts
test/hermes-mcp-rollback-pending.test.ts
test/hermes-mcp-integrity-state.test.ts
test/hermes-mcp-reload-convergence.test.ts
test/hermes-mcp-force-cleanup.test.ts
test/hermes-mcp-private-target-validation.test.ts
test/openshell-0.0.101-migration-review.test.ts`: 10 files and 73 tests
passed after the integrity-pin repair.
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — command/result: Not run; this change is
limited to one Hermes transaction helper and its focused integration
tests.
- [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)
---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved gateway API port resolution by reading environment settings
directly from the gateway process.
* Added clearer handling when gateway environment information is
unavailable or the process identity changes.
* Improved validation of gateway process environment access for more
reliable configuration behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Signed-off-by: Carlos Villela <cvillela@nvidia.com>1 parent 0497b56 commit 6fc834c
4 files changed
Lines changed: 117 additions & 52 deletions
File tree
- agents/hermes
- src/lib/actions/sandbox
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
1051 | | - | |
1052 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1053 | 1051 | | |
1054 | 1052 | | |
1055 | 1053 | | |
1056 | | - | |
| 1054 | + | |
1057 | 1055 | | |
1058 | 1056 | | |
1059 | 1057 | | |
1060 | | - | |
1061 | | - | |
1062 | | - | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1073 | 1061 | | |
1074 | 1062 | | |
1075 | 1063 | | |
| |||
1078 | 1066 | | |
1079 | 1067 | | |
1080 | 1068 | | |
1081 | | - | |
| 1069 | + | |
1082 | 1070 | | |
1083 | 1071 | | |
1084 | 1072 | | |
1085 | 1073 | | |
1086 | 1074 | | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
| 1075 | + | |
1090 | 1076 | | |
1091 | 1077 | | |
1092 | 1078 | | |
| |||
1099 | 1085 | | |
1100 | 1086 | | |
1101 | 1087 | | |
1102 | | - | |
| 1088 | + | |
1103 | 1089 | | |
1104 | 1090 | | |
1105 | 1091 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
16 | 52 | | |
17 | 53 | | |
18 | 54 | | |
| |||
26 | 62 | | |
27 | 63 | | |
28 | 64 | | |
29 | | - | |
30 | | - | |
| 65 | + | |
31 | 66 | | |
32 | 67 | | |
33 | 68 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
38 | 72 | | |
39 | | - | |
| 73 | + | |
40 | 74 | | |
41 | 75 | | |
42 | 76 | | |
| |||
45 | 79 | | |
46 | 80 | | |
47 | 81 | | |
48 | | - | |
49 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
50 | 85 | | |
51 | 86 | | |
52 | | - | |
| 87 | + | |
53 | 88 | | |
54 | 89 | | |
55 | 90 | | |
56 | | - | |
57 | | - | |
| 91 | + | |
| 92 | + | |
58 | 93 | | |
59 | 94 | | |
60 | | - | |
61 | | - | |
| 95 | + | |
| 96 | + | |
62 | 97 | | |
63 | 98 | | |
64 | 99 | | |
65 | | - | |
| 100 | + | |
66 | 101 | | |
67 | 102 | | |
68 | 103 | | |
| |||
71 | 106 | | |
72 | 107 | | |
73 | 108 | | |
| 109 | + | |
74 | 110 | | |
75 | 111 | | |
76 | 112 | | |
| |||
84 | 120 | | |
85 | 121 | | |
86 | 122 | | |
87 | | - | |
88 | | - | |
| 123 | + | |
| 124 | + | |
89 | 125 | | |
90 | 126 | | |
91 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
92 | 171 | | |
93 | 172 | | |
94 | 173 | | |
| |||
227 | 306 | | |
228 | 307 | | |
229 | 308 | | |
230 | | - | |
| 309 | + | |
231 | 310 | | |
232 | 311 | | |
233 | 312 | | |
| |||
241 | 320 | | |
242 | 321 | | |
243 | 322 | | |
244 | | - | |
| 323 | + | |
245 | 324 | | |
246 | 325 | | |
247 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
0 commit comments