Skip to content

feat(sync): add Team delta pull and proposal push client (engraphis sync --team) - #352

Open
Coding-Dev-Tools wants to merge 9 commits into
mainfrom
feat/v1-8-team-delta-client
Open

Coding-Dev-Tools wants to merge 9 commits into
mainfrom
feat/v1-8-team-delta-client

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Summary

Implements Release 1 (v1.8) Slice 2A: the local Team delta sync & proposal push client (engraphis sync --team), connecting local SQLite stores directly to Engraphis Team Cloud's /v1/team/workspaces/{workspace}/delta and /v1/team/workspaces/{workspace}/propose endpoints.

Highlights

  • Core transport (engraphis/team_delta.py):
    • SSRF- and redirect-safe HTTP client reusing validate_cloud_base_url and PinnedHTTPSHandler with ProxyHandler({}), _NoRedirectHandler, bounded timeout, and 10 MiB response limit.
    • Strict origin-bound credential validation (ENGRAPHIS_TEAM_TOKEN + ENGRAPHIS_TEAM_TOKEN_ORIGIN), refusing --team-token on CLI argv and never hardcoding retired hostnames.
    • Paginated pull_team_delta() with persistent SQLite cursor + tombstone_since watermarks (sync_state), fail-closed review_state == "approved" + prompt_eligible is True gating, client-side reject_secrets + assess_untrusted_payload defense-in-depth, resolve_conflicts=False, and deterministic tombstone eviction (retire vs unapprove/erase hard-purge across active and previously-retired rows with list-typed VectorIndex.delete).
    • Fail-closed push_team_proposals() refusing personal/unreadable workspaces, excluding session/user/quarantined/secret/restricted and synced Team records (zero echo loops), running per-item reject_secrets before HTTP, and chunking batches under server limits (50 items / 900 KB).
  • CLI integration (scripts/sync.py): Adds --team [URL], --propose, --propose-source, --read-only / sync_read_only() enforcement, and read-only --status Team cursor reporting.
  • Design & offline evidence: EGM-reviewed design doc (docs/designs/v1.8-team-delta-sync-client.md) and refreshed SHA-256 bound offline benchmark evidence (offline-fixtures-team-delta-20261124.json) and charts.

Verification (68bafddf)

  • pytest -o addopts= tests/test_team_delta_client.py tests/test_sync.py -q: 172 passed, 2 skipped
  • pytest -o addopts= tests/test_benchmark_evidence.py tests/test_documentation_contracts.py tests/test_artifact_smoke.py -q: 60 passed
  • ruff check, pyright (0 errors), Python 3.9 AST (2/2 clean), media_gate.py (OK on both PNGs).

…ync --team)

Implement SSRF- and redirect-safe Team delta sync client in engraphis/team_delta.py
and wire --team / --propose / --propose-source / --status support into scripts/sync.py:
- Paginated delta pull with persistent SQLite cursor and tombstone_since watermarks,
  client-side secret and poisoning defense-in-depth, and deterministic retire/unapprove/erase eviction.
- Fail-closed proposal push refusing personal/unreadable workspaces, excluding session/user/quarantined
  and already-synced records, running per-item reject_secrets before HTTP, and chunking under server limits.
- Origin-bound ENGRAPHIS_TEAM_TOKEN / ENGRAPHIS_TEAM_TOKEN_ORIGIN enforcement and argv secret refusal.
- Refreshed SHA-256 bound offline benchmark evidence artifact and charts.
…pproval gating

Pass list[str] target IDs to VectorIndex.delete on unapprove/erase tombstones,
include retired local Team cache rows in erase/unapprove lookups, fail closed
unless server items assert review_state=='approved' and prompt_eligible is True,
check workspace shareability on pull, reuse single read-only SQLite handle in
--status, and refresh offline benchmark evidence.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-29T11:51:46.867906Z
We couldn’t complete this review. Comment @codex review to try again.
8757948 New commits
ℹ️ 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: 68bafddfb5

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread engraphis/team_delta.py Resolved
Comment thread engraphis/team_delta.py Resolved
…er-item propose failures

Prevent tombstone_since from advancing past failed local retire/purge attempts and stop
marking HTTP 200 per-item rejected proposals as already tracked so retries succeed.
…ariants, and bounds

Addresses both fresh PR#352 reviews: pinned HTTPS opener + retired host rejection + bearer validation, multi-page tombstone hold and crash-safe vector/SQLite purge, fail-closed sensitivity/scope/poisoning push filtering, write-before-retire updates, CLI exit codes, and refreshed offline evidence.
Doc-only pin update after refreshing offline-fixtures-team-delta-20261124.json.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

… and compact tests

Matches MemoryEngine.secure_erase repair queueing and acknowledgement for separate VectorIndex backends (verified by new external-index test), fixes strict no-progress pagination guard, resolves all 3 pyright errors, validates bearer before opening SQLite in sync CLI, trims test boilerplate below the 1500-line core cap, and refreshes offline evidence.
Doc-only pin update after refreshing offline-fixtures-team-delta-20261124.json.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner Author

2-Agent Review & Optimization Summary (9d8e6bd2)

Reviewed HEAD: 9d8e6bd2d9326f7769952a35fd9c78619fc84f57
Base SHA: 7d0a2c8a2776b154cd431af944f159f31260dca3
Diff SHA-256: 1c652acd6639f2ddd971fad2f4caa67c6eace0b8aee02c952ddc3930b2ca54b7
GitHub CI snapshot: test + lint (full offline stack) (3.10):IN_PROGRESS, Analyze python:SUCCESS, export:SUCCESS, Analyze javascript-typescript:SUCCESS, test + lint (full offline stack) (3.11):SUCCESS, test + lint (full offline stack) (3.12):IN_PROGRESS, test + lint (full offline stack) (3.13):SUCCESS, test + lint (full offline stack) (3.14):SUCCESS, core + backends typecheck (Python 3.11):SUCCESS, encryption driver gate (Python 3.10):SUCCESS, encryption driver gate (Python 3.11):SUCCESS, encryption driver gate (Python 3.12):SUCCESS, encryption driver gate (Python 3.13):SUCCESS, encryption driver gate (Python 3.14):SUCCESS, core floor (numpy-only, Python 3.9):IN_PROGRESS, coverage gate (Python 3.11):IN_PROGRESS, repo hygiene gate (no stray DBs/logs):SUCCESS, Pi extension (ubuntu-latest, Python 3.10, Node 22.19.0):SUCCESS, Pi extension (windows-latest, Python 3.11, Node 24):SUCCESS, browser accessibility smoke:IN_PROGRESS, docker smoke - path gate:SUCCESS, build + install wheel:SUCCESS, Installed journey (ubuntu-latest, mcp):SUCCESS, Installed journey (ubuntu-latest, server):SUCCESS, Installed journey (windows-latest, mcp):SUCCESS, Installed journey (windows-latest, server):SUCCESS, Installed journey (macos-latest, mcp):SUCCESS, Installed journey (macos-latest, server):SUCCESS, docker build + health smoke:SUCCESS, CodeQL:SUCCESS

Changes & Hardening

Hardened Team delta client transport (build_pinned_https_opener, retired-host rejection, bearer validation without value echo), aligned external VectorIndex repair queue/ack with MemoryEngine.secure_erase, enforced monotonic tombstone sorting and fail-closed watermark hold/stop on multi-page errors, enforced strict no-progress pagination, fail-closed sensitivity/scope/poisoning push filters, write-before-retire updates, CLI pre-service validation and exit 1 on errors, pyright 0 errors, compacted test boilerplate below 1,500 core lines, and refreshed offline evidence (7f42109b2f0c) + README pin.

Fresh 2-Agent Verdicts

  • b432f34d-93f0-421d-a2a0-61f1b2f3cad0 (Reviewer 1: Delta Client & Parity) -> APPROVE
  • 579e5e7e-f239-4d8f-8a42-3213828ed2ba (Reviewer 2: Adversarial Security) -> APPROVE

Local Outside-Judge Verification

  • lint: python -m ruff check engraphis/team_delta.py scripts/sync.py tests/test_team_delta_client.py -> exit 0 (local worktree pr-352)
  • typecheck: python -m pyright --pythonpath <venv>/python.exe engraphis/team_delta.py -> exit 0 (0 errors, 0 warnings)
  • tests: python -m pytest -q tests/test_team_delta_client.py tests/test_sync_cli.py tests/test_benchmark_evidence.py tests/test_documentation_contracts.py tests/test_setup_plugin_distribution.py -> exit 0 (90 passed, 0 failed)

Merge-Gate & Policy Flags

  • Core non-generated diff is 1,460 lines (<1,500), but total diff including offline-fixtures-team-delta-20261124.json (704 lines) exceeds 1,500 lines in merge-gate.ps1.
  • Merge after Coding-Dev-Tools/engraphis-cloud#167 and re-export offline evidence if merged after other engraphis core PRs.

Merge-Gate Readiness

Schema-v2 approval payload prepared (minReviewers: 2, blockers: 0, majors_open: 0); awaiting explicit operator merge authorization (merge-gate.ps1 not run).

…origins

Three High-severity defects in the Team delta client:

* Workspace-wide items (repo=None) were rewritten to the caller's
  --repo, and that repo is hashed into team_content_hash. Alternating
  --repo api and --repo web syncs therefore rewrote a new copy and
  retired the other on every run. Keep item_repo as the server sent it;
  the existing guard already rejects a genuine repo mismatch.
* _existing_team_memories indexed rows from every Team origin under the
  same team_memory_id, so a tombstone from one control plane could
  retire or securely erase rows cached from another. Filter by the
  local rows' team_origin.
* _default_http_post did not catch http.client.HTTPException, so
  IncompleteRead, BadStatusLine, and RemoteDisconnected escaped as an
  unhandled traceback instead of a TeamDeltaError.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

`tests/test_benchmark_evidence.py` hashes every `.py` under `engraphis/`
and `eval/`, so the team_delta changes invalidated the committed registry
artifact and failed the whole Python matrix. Export a new immutable
artifact and repoint the test constants, README prefix, BENCHMARKS.md
name/sha, and the fixture-suite digest. The SVGs and PNGs were
regenerated from the new artifact so their embedded provenance matches.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

This branch has not been deployed

No deployments
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