Skip to content

fix: stop Jarvis reply failures on /proc map_files EPERM - #16

Open
warheart1984-ctrl wants to merge 1 commit into
mainfrom
fix/jarvis-proc-map-files-eperm
Open

fix: stop Jarvis reply failures on /proc map_files EPERM#16
warheart1984-ctrl wants to merge 1 commit into
mainfrom
fix/jarvis-proc-map-files-eperm

Conversation

@warheart1984-ctrl

@warheart1984-ctrl warheart1984-ctrl commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Workspace tools defaulted to Path(__file__).parents[2], which is / in the Docker /app layout. Chat then walked /proc/1/map_files/... and died with [Errno 1] Operation not permitted.
  • Resolve workspace root to the repo (never filesystem root), skip proc/sys/dev/map_files during walks, and fail-open on EPERM so telemetry/introspection cannot abort a reply.
  • Pin AAIS_WORKSPACE_ROOT=/app in Docker/Render.

Test plan

  • python3 -m pytest tests/test_workspace_root.py tests/test_jarvis_operator.py::TestWorkspaceTools tests/test_patch_execution_preview_organ.py tests/test_patch_apply_organ.py -q
  • Send a Jarvis chat turn on Render after deploy and confirm no Jarvis could not reply: [Errno 1] ... /proc/1/map_files/... toast

Made with Cursor

Greptile Summary

The PR centralizes workspace-root resolution, prevents default traversal of the filesystem root and pseudo-filesystems, and makes Jarvis workspace searches tolerate filesystem permission failures. It also configures the container deployments to use /app.

  • Adds a shared workspace-root resolver and regression tests.
  • Applies root resolution to workspace search, patch preview, patch application, and workbench indexing.
  • Adds pseudo-filesystem exclusions and OSError handling around filesystem inspection.
  • Sets AAIS_WORKSPACE_ROOT in Docker and Render deployment configuration.

Confidence Score: 4/5

The invalid-workspace fallback should be fixed before merging because it can redirect an approved patch into the application repository rather than failing on an unavailable intended project.

Patch preview and application now replace a nonexistent configured workspace with the inferred source repository, allowing matching relative patch targets to be validated and written in the wrong project; the remaining findings concern required repository documentation.

Files Needing Attention: src/workspace_root.py, src/patch_apply_engine.py, src/patch_execution_preview.py

Important Files Changed

Filename Overview
src/workspace_root.py Introduces centralized root resolution, but invalid configured projects silently retarget patch operations to the source repository and the new subsystem violates two documentation rules.
src/patch_apply_engine.py Adopts shared root resolution, making writes susceptible to silent fallback when the intended workspace is invalid.
src/patch_execution_preview.py Adopts the same fallback root as patch application, allowing preview validation to mask an unavailable intended workspace.
src/jarvis_operator.py Adds pseudo-filesystem exclusions and fail-open handling for workspace-search filesystem errors without a confirmed blocking defect.
src/evolving_workbench.py Uses centralized root resolution and skips unreadable or unsafe traversal paths.
tests/test_workspace_root.py Covers repository fallback and EPERM-tolerant search, but does not exercise the wrong-project patch consequence of a nonexistent configured root.
Dockerfile Pins the main container workspace root to /app.
deploy/pilot/Dockerfile.aais Pins the pilot container workspace root to /app.
deploy/platform/Dockerfile Pins the platform container workspace root to /app.
render.yaml Configures the Render service workspace root as /app.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Resolve workspace root] --> B{Environment override set?}
    B -->|Yes| C[Resolve environment path]
    B -->|No| D{Explicit root supplied?}
    D -->|Yes| E[Resolve explicit path]
    D -->|No| F[Infer repository root]
    C --> G{Filesystem root or invalid directory?}
    E --> G
    G -->|Yes| F
    G -->|No| H[Use selected workspace]
    F --> H
    H --> I[Workspace search and indexing]
    H --> J[Patch preview]
    J --> K[Patch application]
Loading

Fix all with Greploop Fix All in Codex Fix All in Cursor

Prompt To Fix All With AI
### Issue 1
src/workspace_root.py:82-83
**Invalid Roots Retarget Patches**

If `AAIS_WORKSPACE_ROOT` or an explicit workspace path names a deleted, renamed, or nonexistent project, `resolve_workspace_root` silently substitutes the source repository; patch preview then validates that unintended root and patch application can write matching relative targets into the wrong project instead of failing.

### Issue 2
src/workspace_root.py:1-10
**Subsystem Header Fields Missing**

The new subsystem uses a prose docstring instead of the required five-field Mythic, Engineering, Responsibilities, Non-responsibilities, and Invariants comment header, leaving its repository-mandated ownership and boundary information incomplete.

### Issue 3
src/workspace_root.py:36
**Public Function Comments Missing**

The newly added `default_repo_root` and `resolve_workspace_root` public functions lack the required Mythic and Engineering comment pairs, so their operator intent and deterministic behavior are not documented according to the repository convention.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix: keep Jarvis replies off /proc map_f..." | Re-trigger Greptile

Greptile also left 3 inline comments on this PR.

Context used:

  • Context used - One subsystem per file; mandatory file header bloc... (source)
  • Context used - Dual-layer Mythic + Engineering comments with inva... (source)

Workspace tools defaulted to Path(__file__).parents[2], which is / in the Docker /app layout. Chat then walked /proc/1/map_files and died with EPERM. Pin the root to the repo, skip proc/sys/dev, and fail-open on blocked introspection.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/workspace_root.py
Comment on lines +82 to +83
if _is_filesystem_root(candidate) or not candidate.is_dir():
return fallback

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Invalid Roots Retarget Patches

If AAIS_WORKSPACE_ROOT or an explicit workspace path names a deleted, renamed, or nonexistent project, resolve_workspace_root silently substitutes the source repository; patch preview then validates that unintended root and patch application can write matching relative targets into the wrong project instead of failing.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workspace_root.py
Line: 82-83

Comment:
**Invalid Roots Retarget Patches**

If `AAIS_WORKSPACE_ROOT` or an explicit workspace path names a deleted, renamed, or nonexistent project, `resolve_workspace_root` silently substitutes the source repository; patch preview then validates that unintended root and patch application can write matching relative targets into the wrong project instead of failing.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex Fix in Cursor

Comment thread src/workspace_root.py
Comment on lines +1 to +10
"""Safe workspace-root resolution for Jarvis local file tools.

Mythic: Operator Workshop Boundary
Engineering: WorkspaceRootResolver

Inputs: optional env override, optional explicit root, calling module path
Outputs: absolute Path confined to the repo (never filesystem root)
Constraints: read-only resolution; never walk `/`, `/proc`, `/sys`, `/dev`
Failure modes: missing/invalid override → fall back to repo root; EPERM on
proc map introspection must not reach chat (walkers skip unsafe dirs)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Subsystem Header Fields Missing

The new subsystem uses a prose docstring instead of the required five-field Mythic, Engineering, Responsibilities, Non-responsibilities, and Invariants comment header, leaving its repository-mandated ownership and boundary information incomplete.

Context Used: One subsystem per file; mandatory file header bloc... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workspace_root.py
Line: 1-10

Comment:
**Subsystem Header Fields Missing**

The new subsystem uses a prose docstring instead of the required five-field Mythic, Engineering, Responsibilities, Non-responsibilities, and Invariants comment header, leaving its repository-mandated ownership and boundary information incomplete.

**Context Used:** One subsystem per file; mandatory file header bloc... ([source](https://github.com/warheart1984-ctrl/project-infinity/blob/main/.cursor/rules/jon-file-structure.mdc))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Cursor

Comment thread src/workspace_root.py


def _looks_like_repo_root(candidate: Path) -> bool:
return (candidate / "pyproject.toml").is_file() or (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Public Function Comments Missing

The newly added default_repo_root and resolve_workspace_root public functions lack the required Mythic and Engineering comment pairs, so their operator intent and deterministic behavior are not documented according to the repository convention.

Context Used: Dual-layer Mythic + Engineering comments with inva... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/workspace_root.py
Line: 36

Comment:
**Public Function Comments Missing**

The newly added `default_repo_root` and `resolve_workspace_root` public functions lack the required Mythic and Engineering comment pairs, so their operator intent and deterministic behavior are not documented according to the repository convention.

**Context Used:** Dual-layer Mythic + Engineering comments with inva... ([source](https://github.com/warheart1984-ctrl/project-infinity/blob/main/.cursor/rules/jon-dual-comments.mdc))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Cursor

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.

1 participant