Skip to content

refactor(core): share project path validation contracts - #1932

Merged
phernandez merged 10 commits into
mainfrom
codex/security-shared-path-contracts
Oct 29, 2026
Merged

phernandez merged 10 commits into
mainfrom
codex/security-shared-path-contracts

Conversation

@phernandez

@phernandez phernandez commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Why

Project creation and project moves duplicated resolved-root checks, and note moves maintained separate portable-path syntax checks. The user requested shared path helpers across these security boundaries.

What Changed

Reuse resolve_path_within_root for project creation and project moves, requiring strict descendants of a configured root. Reuse valid_project_path_value for note-move syntax. Uploads already use that portable validator in #1928; storage/import/materialization guards already share resolved containment in #1931.

Implementation Details

The shared helpers live in the preceding PRs. This PR removes the remaining project and note-move copies and adds controls for root permissions, sibling-prefix and symlink escapes, filename spelling, and literal tildes. Filename normalization remains an explicit operation policy; reference validation keeps its existing default restrictions. Object-storage keys do not resolve against the host filesystem.

Stacked on #1931. The ignore-rule PR (#1929) is held separately and is not a dependency.

Testing

  • uv run pytest tests/utils/test_path_containment.py tests/utils/test_validate_project_path.py tests/utils/test_remote_project_paths.py tests/runtime/test_note_move_destination.py tests/services/test_destination_containment.py tests/services/test_project_move_root.py tests/services/test_project_root_containment.py tests/cli/cloud/test_upload_destination.py -q --no-cov: 118 passed on the final stack.
  • just fast-check: passed, including repository type checking.
  • just doctor: passed sandboxed write/index/search self-test.

Risks / Follow-ups

Note moves apply the shared portable restrictions, including control characters and Windows-normalized traversal segments. File storage explicitly permits literal tildes because it never expands home markers. Native POSIX storage preserves literal-colon names; remote keys and reference validation retain their drive restrictions. Archive syntax remains a separately stricter format contract.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T00:15:20.074957Z 5997238 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19c4980e19

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: f744253288

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from f744253 to b9368db Compare October 28, 2026 21:44
@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from 47f7789 to 21d4111 Compare October 28, 2026 21:44
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b9368db814

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from 21d4111 to f2939a7 Compare October 28, 2026 22:17
@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from b9368db to f4f2956 Compare October 28, 2026 22:17
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4f2956908

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: d7a9e794f7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from d7a9e79 to 372aa7c Compare October 28, 2026 22:23
@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from f2939a7 to 4923a55 Compare October 28, 2026 22:23
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from 372aa7c to e257e8e Compare October 28, 2026 22:26
@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from 4923a55 to 46d3ab7 Compare October 28, 2026 22:26
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e257e8e2f6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from 46d3ab7 to f610f1d Compare October 28, 2026 23:01
@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from e257e8e to 8b577e6 Compare October 28, 2026 23:01
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 8b577e6766

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from 8b577e6 to c47c543 Compare October 28, 2026 23:05
@phernandez
phernandez force-pushed the codex/security-import-materialization-root branch from f610f1d to 4c483a3 Compare October 28, 2026 23:05
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from 412b611 to f02c754 Compare October 28, 2026 23:25
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from f02c754 to e6fd64b Compare October 28, 2026 23:27
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: e6fd64be16

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from e6fd64b to 6649d5f Compare October 28, 2026 23:33
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 6649d5f3ee

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from 6649d5f to 0a209fb Compare October 28, 2026 23:43
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 0a209fbc88

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@phernandez
phernandez changed the base branch from codex/security-import-materialization-root to main October 29, 2026 00:11
@phernandez
phernandez force-pushed the codex/security-shared-path-contracts branch from 0a209fb to 5997238 Compare October 29, 2026 00:12
@phernandez
phernandez changed the base branch from main to codex/security-import-materialization-root October 29, 2026 00:12
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 5997238301

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Base automatically changed from codex/security-import-materialization-root to main October 29, 2026 00:30
@phernandez
phernandez merged commit 3a5e99e into main Oct 29, 2026
55 checks passed
@phernandez
phernandez deleted the codex/security-shared-path-contracts branch October 29, 2026 00:37
phernandez added a commit that referenced this pull request Oct 29, 2026
## Why

YAML aliases create shared or cyclic containers that downstream
normalization, schema processing, and export treat as trees; merge
construction can expand work before those consumers run. A 347-character
alias document allocated 2.5 MiB in normalization, and a cyclic alias
caused RecursionError in the real entity parser. Fixes #1892
(K6/K15/K16/K22/K44).

## What Changed

Adopt the user-approved simple YAML policy: aliases and merge keys are
unsupported in note metadata. Reject them during YAML composition,
before construction or recursive normalization. Emit repeated values
directly so writers do not introduce aliases. Document the policy in
DOMAIN_MODEL.md.

## Implementation Details

One SafeLoader subclass enforces the policy across Core frontmatter
parsing, MCP read shaping, python-frontmatter adapters, schema-file
reads, local Wiki ownership parsing, and OKF validation. OKF retains its
timestamp-spelling resolver while inheriting the same graph restriction.
Existing malformed-frontmatter handling preserves canonical bytes as
body content; strict metadata/OKF readers reject unsupported YAML.
SafeDumper customization keeps generated frontmatter compatible with the
reader.

Stacked on #1932; only YAML policy, its adapters, documentation, and
regression tests are new here.

## Testing

- Before the fix: 14 policy regressions failed, including the real
entity-parser cycle and writer-produced aliases.
- `uv run pytest tests/markdown/test_simple_yaml_policy.py
tests/utils/test_file_utils.py
tests/utils/test_frontmatter_obsidian_compatible.py tests/okf
tests/picoschema tests/services/test_entity_service.py
tests/services/test_note_section_edits.py
tests/mcp/test_tool_read_note.py tests/api/v2/test_schema_router.py
tests/index/test_local_wiki_projection.py -q --no-cov`: 608 passed.
- No mocks in the new alias/cycle/merge/reader/writer regressions.
Ordinary quoted marker text remains data.
- `just fast-check`: passed, including repository type checking.
- `just doctor`: passed sandboxed write/index/search self-test.
- `git diff --check`: passed.

## Risks / Follow-ups

This deliberately stops accepting alias/merge metadata. Existing notes
must repeat those values directly to use them as frontmatter; canonical
bytes are not automatically rewritten. Unused anchors carry no alias
edges and do not expand graphs. The CI project-update configuration
parser is not note metadata and retains its existing YAML handling.
Cloud must update Core and use the shared policy in any Cloud-owned YAML
reader to receive the complete cross-repository fix.

Signed-off-by: phernandez <[email protected]>
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