Skip to content

fix(source): isolate repository caches and installation ownership - #929

Merged
jeff-r2026 merged 19 commits into
Tencent:mainfrom
NianJiuZst:codex/fix-source-cache-identity
Oct 2, 2026
Merged

jeff-r2026 merged 19 commits into
Tencent:mainfrom
NianJiuZst:codex/fix-source-cache-identity

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Complete the cross-team source ownership fix, combining this PR's URL-specific repository cache with the scoped installation implementation originally submitted in #931. Both original contributions and their authorship are retained through the rebase. This also addresses the subsequent shared-checkout, shared-destination, conflicting-producer, and legacy-push review findings.

  • Cache clones and successful-pull timestamps by configured repository URL hash, shared across aliases under the source mutex. Aliases of one URL cannot diverge in cached revision or TTL. Failed refreshes use only that repository's cache and do not advance its TTL

  • Key installation manifests by absolute resource destination and team checkout; record the destination, checkout, repository identity, active skill names, and deployed paths

  • Preflight physical destinations before copying. A different or unidentified producer blocks the conflicting skill; the same repository can share a destination. Existing copies survive newly conflicting targets, conflicted repository replacements preserve the previous installation, and successful replacements release historical paths without mislabeling old content

  • Stale cleanup and removal release only the current installation. Other owners protect shared, symlinked, or overlapping paths. A destination can still remove its scoped installation after another destination removes the alias from shared teamai.yaml. If that alias is re-added for another repository, stale/unidentified installation cleanup preserves the new subscription

  • Reconcile every successful pull against current destinations. Valid empty publications release old claims; same-repository tool-path moves retire obsolete paths. Foreign owners and conflict-retained copies remain protected. Missing/unreadable source config preserves the old installation; tools with no eligible destination gain no false ownership

  • Reject normalization-changing skill identities before deployment and preserve team/builtin-owned directories against canonical nested-name overlap. Removal preflights every required foreign record and deletion target before editing shared YAML

  • Reject empty/root-equivalent, escaping, absolute, drive-relative, and NUL-containing ownership paths and unsafe fallback names before cleanup changes configuration. A second cleanup guard rejects the physical root/ancestors; malformed public names are rejected before deployment

  • Check actual scanned directories before pushing, including Codex's configured/shared-directory difference and nested scans. Malformed, truncated, or unreadable ownership records fail closed for publication and conflicting writes

  • Serialize Git-source add, browse/cache refresh, pull, and removal with the existing atomic lock utility, outside the source-alias namespace. Dry-run reads cache contents without cloning, pulling, or changing timestamps; missing caches are reported explicitly

  • Preserve canonical nested public names. Preflight ambiguous parent/child transitions and exact-path collisions between distinct skill identities before copying anything, including same-repository aliases. Retain the previous installation with explicit manual-review guidance; normal nested updates, disjoint path moves, and exact same-skill sharing still work

  • Keep provenance for retained team/builtin overlaps and source parents protected by another installation's child, including concrete recorded paths from older scoped records. This prevents retained source bytes from becoming local push candidates after another owner leaves

  • Show nested source provenance by actual scoped physical path. Unrelated same-named copies and bundled modules are not adopted; duplicate aliases retain path-specific labels. Unreadable provenance produces an explicit uncertainty warning

English/Chinese usage guides and directory design describe the behavior and limits. skill-data/core/SKILL.md is unchanged from upstream, as requested in review.

Legacy and lifecycle safety

Legacy name-only installed.json cannot prove a deployment root. It is preserved and never adopted as deletion authority. Its names are quarantined from push with an explicit record-path warning, preventing old third-party copies from becoming local publication candidates. This can also withhold an unrelated same-named draft. Review and back up remaining copies, archive legacy tracking only after accounting for every destination, then pull active subscriptions to establish scoped records. Automatic destructive migration is deliberately not performed.

A moved/deleted checkout also does not prove deployed files are abandoned. Such ownership remains protective; new records store the checkout path, and retention/conflict messages identify the record to review. Automatic orphan cleanup remains out of scope.

The source mutex serializes source mutations, but push does not retain it through its entire staging/publication transaction. Full concurrent push/source snapshot isolation remains a P2 non-blocking limitation; avoid running those operations concurrently. This is documented rather than expanding this fix into a broader publication-locking protocol.

Landing relationship

Land #929 first. #931 is a regression-only follow-on based on this complete implementation. Its unique change is the 35-line remove/re-add/shared-cache crossover extension. Both PRs remain open and target main; #931 includes these shared commits until the dependency lands. Rebase #931 after #929 lands if the merge method rewrites the shared commits.

Verification

Current implementation head: 18511bc; dependent test head: 76f4cf5, based on main at 85ff72c.

  • npm run build
  • npm run typecheck
  • npm run lint
  • 530 focused source/provenance/skill-push/path-safety/namespace/status unit tests
  • 94 read-only loader regressions
  • Fifty-two real-CLI source cases on each final head, with retries disabled
  • Full-branch shared-state review and exact-head remote verification

Real-CLI record

npm run build
npx vitest run --config vitest.e2e.config.ts \
  src/__tests__/source-cache-isolation-e2e.test.ts \
  src/__tests__/source-manifest-isolation-e2e.test.ts \
  src/__tests__/source-project-scope-e2e.test.ts \
  src/__tests__/source-shared-destination-e2e.test.ts \
  src/__tests__/source-nested-ownership-e2e.test.ts \
  src/__tests__/source-symlink-ownership-e2e.test.ts \
  src/__tests__/source-push-path-ownership-e2e.test.ts \
  src/__tests__/source-codex-reconciliation-e2e.test.ts \
  src/__tests__/source-root-alias-e2e.test.ts \
  src/__tests__/source-unrecorded-replacement-e2e.test.ts \
  src/__tests__/source-unrecorded-toolpaths-e2e.test.ts \
  src/__tests__/source-ambiguous-foreign-claims-e2e.test.ts \
  src/__tests__/source-alias-enumeration-e2e.test.ts --retry 0

The tests invoke built dist/index.js with temporary HOME directories, the Git provider, local bare remotes reached through HTTPS URL rewrites, and Claude-directory destinations (with Codex routing covered separately by unit tests). Coverage includes same-name/different-URL caches, URL re-add, offline fallback, separate/shared checkouts, shared HOME with same/different aliases, conflicting repository content, last-owner deletion, legacy/foreign push quarantine, dry-run cache immutability, mutex contention/error release, noncanonical name/priority boundaries, foreign-record and physical-root removal preflight, direct-removal protection for team/builtin scripts, empty/absent/unavailable public skill withdrawals, same-repository destination moves, same-URL alias refresh/TTL/offline fallback, stale shared-checkout alias replacement, and local draft preservation. Six new nested-boundary CLI cases cover both parent/child directions across self, same-URL alias, and foreign-repository ownership, including unchanged manifests/bytes, no partial deployment, preview behavior, and recovery after explicit removal. Eight focused boundary tests cover exact physical identity collisions and cleanup-only retained-parent sequences. A built-CLI list/show smoke confirms nested labels, duplicate aliases, and unrelated-copy isolation.

Negative controls reproduce the prior failures: shared-checkout cleanup reports source not found, shared-HOME cleanup deletes the other owner's skill, and a different repository replaces the surviving owner's content. The fixes pass the corresponding regressions. Twenty unsafe ownership/name fixtures were accepted by the previous implementation and are now rejected; the built CLI preserves YAML, tracked files, and invalid records across eight malformed cleanup attempts. Real-CLI negative controls also reproduce stale alias revision rollback and deletion of a re-added shared subscription; both now pass. Eleven additional negative-control failures reproduce empty publication, obsolete paths, false no-tool ownership, and the mutex alias collision; all pass after reconciliation. All six nested-transition negative controls also fail on the previous built CLI and pass with the compatible guard. Additional hosted provider/agent combinations are deferred to CI; no full provider × agent matrix is claimed.

Full unit run on implementation 18511bc (env -u CODEX_HOME GIT_DISCOVERY_ACROSS_FILESYSTEM=1 npx vitest run --maxWorkers 4, writable npm cache): 366 files passed, 4 failed; 7,135 tests passed, 22 failed, 1 skipped. All 22 failures exactly match the separately reproduced untouched-main baseline at 85ff72c: MCP tests see this sandbox's read-only temp-root .git marker when they expect a location outside any repository. An earlier concurrent run also hit one 15-second loader timeout; the focused 94-loader run and isolated full rerun cleared it. No final-only failures remained. This is not an all-green local full-suite claim; exact-head hosted CI is tracked in the PR checks.

Shared-state audit

State Readers Writers / removal
URL-only shared cache and pull timestamp Add/browse/pull across aliases; list cache status Clone/pull under the source mutex; timestamp only after success; removal retains caches
Scoped manifest Pull/removal; current provenance; foreign physical-path protection; push filtering Only the active installation writes/releases its record, under the source mutex
Deployed paths Actual canonical destinations and scanned push candidates Copy after producer-conflict preflight; deletion only without another owner or new replacement path
Team source configuration Active-scope commands Add/remove reread under the mutex and update teamai.yaml; orphan scoped cleanup does not rewrite it
Legacy unscoped manifest Push quarantine only Preserved; never authorizes deletion or invented provenance
Lifecycle mutex Source mutation commands; push busy-state guard Existing atomic acquire and owner-verified release; no new recovery protocol

The existing broad user-scope uninstall remains unchanged. No command or flag additions were made.

Physical destination safety

Scoped records now pin each relative deployment path to its actual post-copy physical destination. Removal, withdrawal, and updates validate every old target before changing files, YAML, or the record. Foreign ownership uses the original pin directly, so repointing a symlink cannot transfer ownership to unrelated content or abandon the original copy. Cleanup rechecks the pin and deletes the canonical target. Copy preflight also accounts for leaf symlinks that copyDir replaces, including lexical ancestors of old or planned nested skills.

Three real-CLI negative controls reproduce deletion on removal/withdrawal and overwrite on refresh; all now pass, including restoring the original link and retrying. Thirty-seven focused pin tests cover stable ancestor/root symlinks, repointed/removed/dangling links, missing leaves, malformed/incomplete metadata, foreign original-path protection, and both leaf-link transition regressions. Existing nested installs, stable new symlink installs, disjoint moves, and same-skill sharing remain supported. Old unpinned records cannot prove historical symlink destinations and require manual review; only explicitly recorded plain historical paths remain compatible.

The automated request to add core-skill text conflicts with the human review instruction to leave that skill unchanged. The final diff honors that instruction; equivalent safety guidance remains in the bilingual usage guides and directory design.

Path-scoped push candidates

Modern records with complete physical pins are excluded only by their actual owned paths. A source foo installed in Claude no longer hides an unrelated Codex foo. Name-only quarantine remains for legacy/unpinned/rootless records and also covers nested basenames; malformed/incomplete pins continue to stop skill push. Twenty-one focused cases cover both scan orders, shared and symlinked paths, nested overlaps, incomplete records, and foreign pinned originals. Three actual-CLI cases verify modern, unpinned, and legacy behavior; the modern case publishes only the independent Codex payload to a local bare fixture repository, leaving source-owned Claude bytes unchanged. Its negative control reproduced the previous silent omission.

Codex duplicate and source-root reconciliation

The ownership preflight remains side-effect free. After all targets and cleanup candidates are validated, the existing Codex resolver reconciles unowned configured/shared duplicates only when both match the incoming source. Owned paths, current records, planned targets, same-physical aliases, the repository cache, and resolved source inputs are protected. Different local copies remain eligible for push; dry-run performs no cleanup.

Skill-root links inside the repository are copied as concrete directories; outside, dangling, or looping root aliases stop before deployment. Older installed skill-root links retain their manifest and referent for manual review, since a physical pin alone cannot grant deletion authority over the link target. Stable tool-destination links and ordinary nested names remain supported; no nested file-link migration is attempted.

Thirty focused reconciliation/root-safety tests pass. Six additional built-CLI cases verify duplicate removal, local-copy preservation, foreign ownership/conflict protection, previews, safe internal aliases, and rejected external aliases. Negative unit controls reproduce both root-link data-loss paths; the valid Codex CLI negative reproduces the missing reconciliation.

Unrecorded historical claims

An installation with any missing or empty recorded skill path cannot authorize updates, withdrawals, removals, or repository replacements. The whole prior record, files, and YAML remain intact with manual-review guidance. Ambiguous foreign scoped and rootless legacy claims likewise veto equal, parent, or child logical names before writes or cleanup, including same-repository aliases; the guard never invents a physical destination. Current tool paths never establish historical deletion or overwrite authority; explicitly recorded plain-path updates remain supported. Ambiguous scoped claims also quarantine matching names and nested basenames across checkouts sharing HOME, so another checkout cannot publish those retained third-party bytes. Complete modern physical pins remain path-only and do not hide unrelated same-named drafts.

Forty-five focused cases and twelve built-CLI cases cover missing, empty, and mixed old paths; known/unknown producers; empty/nonempty replacement publications; shared-HOME push quarantine; previews; no partial installs; exact file/record/YAML preservation; and manual retention rather than inferred cleanup after tool paths change. Negative controls reproduced the old provenance loss, and all corresponding regressions now pass.

The paired foreign-owner guard has 46 focused tests and four real-CLI negative controls: equal-name overwrite with partial deployment, same-repository nested writes, withdrawal deleting a retained foreign child, and rootless-legacy removal deleting retained nested content. All four fail on the preserved pre-guard build and pass on the final build. Nonoverlapping logical names and concrete recorded foreign paths remain compatible. The 52-case final source CLI coverage consists of the 50-case aggregate plus the two alias cases on #929, and one 52-case aggregate on #931.

Complete alias enumeration

Source metadata now enumerates every accepted alias independently of resource-directory ignore rules. .git, node_modules, __pycache__, .pyc, .DS_Store, and names ending in .pyc remain compatible and cannot hide ownership, provenance, quarantine, or ambiguous claims. Ordinary skill resource scanning is unchanged. Forty-nine focused cases pass. Two real-CLI negative controls reproduce a foreign producer overwriting node_modules-owned content and a normal push exporting .git-owned source files; both pass after the fix, including actual fixture publication of only the local draft.

Final hosted results

Both final heads passed hosted CI: #929 at 18511bc and #931 at 76f4cf5. All six Linux/macOS Node jobs, Build, fork-safe E2E, Code Erosion, and Tencent scan succeeded. The credentialed GitHub-provider full-surface job is intentionally skipped for fork PRs.

The latest #929 review reports no findings. The latest #931 review confirms implementation findings are resolved; its remaining P2 asks for the core-skill edit that the human reviewer requested removing. The core skill stays unchanged, with safety guidance in the bilingual usage/design docs. Both PRs remain open for maintainer re-review, with #929 landing first.

@jeff-r2026 jeff-r2026 self-assigned this Sep 30, 2026
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Scope the installation manifest before deleting it — src/source.ts:242. Repository caches are now URL-specific, but installed.json remains globally keyed only by source name. If team Alpha and team Beta both use shared, Beta’s pull overwrites Alpha’s manifest; Alpha’s source remove shared then uses Beta’s manifest for cleanup and deletes it globally. This can remove an unrelated same-named skill from Alpha’s workspace and leaves Beta unable to clean stale source skills on later pulls. The manifest and all its readers/writers must use an identity that distinguishes these subscriptions.

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please resolve the P1 findings

@NianJiuZst
NianJiuZst force-pushed the codex/fix-source-cache-identity branch from ebf2612 to 96029ac Compare October 1, 2026 08:37
@NianJiuZst NianJiuZst changed the title fix(source): isolate subscription repository caches by URL fix(source): isolate repository caches and installation ownership Oct 1, 2026
@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the P1 ownership finding by bringing the scoped-manifest implementation into this PR alongside the URL-specific cache fix. Pull cleanup, source removal, provenance tags, and push exclusions all use the current team checkout plus destination; removal preserves other installations' manifests and shared URL caches. Legacy unscoped records stay untouched.

#929 now carries the complete implementation. #931 depends on it and adds the remove/re-add/shared-cache/offline crossover regression, so the fixes have a clear landing order: #929 first, then #931. Both original implementation commits retain their author attribution.

Build, typecheck, lint, 74 focused unit tests, and all three representative real-CLI source tests pass. The PR description includes exact verification and the separately reproduced full-suite baseline limitations.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Clean every installation tied to the edited team checkout — src/source.ts:237. The command removes the source from the shared teamai.yaml, but cleans and deletes only the current destination’s manifest. If the same team checkout has installed the source into both HOME and a project—or multiple worktrees—removing it from one scope leaves skills and manifests in the others. Those installations can no longer run source remove, because the source is already absent from their shared configuration. Store enough destination information to clean all installations for this team checkout, or retain another cleanup path.

The earlier cross-team manifest-collision finding is resolved by the new team-checkout/destination-scoped manifests. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the shared-checkout cleanup finding and the shared-destination ownership finding from #931 in the combined implementation.

An installation can now run source remove <name> using its scoped manifest after another destination removed the alias from shared teamai.yaml. This leaves that YAML byte-for-byte unchanged. Removal and stale cleanup also retain a physical path while another active scoped installation owns it, across source aliases and symlinked/overlapping destinations; only the current installation releases ownership.

The new CLI regressions fail on the previous implementation and pass with these fixes. Coverage includes shared versus separate team checkouts, remove versus stale cleanup, same versus different aliases at one HOME, unchanged foreign manifests, dry-run, and deletion by the final owner. Validation details and the exact final heads are in the PR description.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Restore the remaining owner’s content when preserving a shared path — src/source.ts:695. If two user-scope installations publish the same skill name from different repositories, the later pull overwrites the shared directory. Removing that later installation now skips deletion because the earlier manifest also owns the path, but leaves the removed source’s files in place instead of restoring the remaining source’s version. The remaining installation therefore points to incorrect content; cleanup must redeploy the surviving owner or prevent conflicting installations from overwriting the same path.

Both earlier manifest-scoping and multi-destination cleanup findings are resolved. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the sequential ownership findings together in #929 and rebased #931's regression-only follow-on on top.

Different repositories can no longer overwrite an already owned shared destination. Conflicts are checked before any copy; existing working copies survive new target conflicts, and repository replacements cannot relabel historical paths. Push checks actual scanned paths, quarantines ambiguous legacy names, and fails closed for malformed/unreadable ownership records. Source mutations use the existing atomic lock; previews no longer mutate repository caches.

Legacy records are deliberately not migrated into deletion authority: their destination is unknown, so doing so would recreate the original unrelated-file deletion risk. They remain preserved, with push quarantine and a documented manual-review path. Missing checkouts are likewise not treated as proof of abandonment. Full concurrent push/source publication isolation remains a documented P2 limitation rather than an unsafe inferred cleanup or a new broad locking protocol.

The descriptions include exact final-head verification, 196 focused unit tests, 94 loader regressions, nine real-CLI cases, negative controls, and the separately reproduced sandbox-only full-suite failures. Landing order remains #929 first, then #931.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Release ownership when a source becomes empty — src/source.ts:538. If a previously installed source removes publicSkills, or all declared skill directories disappear, these early returns bypass stale cleanup and manifest rewriting. The old files remain deployed, and the retained scoped manifest now prevents another repository from installing the same paths indefinitely.
  • [P1 blocking] Remove obsolete destinations for still-public skills — src/source.ts:570. installedPaths starts with every old path and only appends current targets. If tool paths or enabled agents change, a pull copies the skill to its new destination but neither removes nor unrecords the old destination. That stale ownership can subsequently block unrelated source installations from using the abandoned path.
  • [P3 nit] Reserve the lifecycle lock name — src/source.ts:40. .lifecycle-lock passes assertSafeResourceName, but source add --name .lifecycle-lock first creates the lock as a file and then tries to create the source cache beneath that file, so the otherwise-valid alias can never be added.

The three previously reported ownership findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the remaining ownership-release findings in 42cf8f3 (#929); #931 is rebased to aca8b20 and remains the 35-line crossover regression follow-on.

  • A valid config that omits publicSkills, publishes an empty list, or has no remaining published skill directories now releases the prior installation. A missing/unreadable source config still preserves it.
  • Every successful pull records its current paths and retires obsolete destinations even when the repository URL is unchanged. Foreign owners keep their files; conflict-retained copies keep their old records. Another producer can use a released destination without being blocked by a stale claim.
  • The mutex is outside the source-alias namespace, and a source with no eligible installed tool no longer gains false ownership.

Eleven negative-control failures reproduce these cases on the previous implementation. Updated validation: build/typecheck/lint pass; 206 focused tests and 94 read-only-loader tests pass; all 13 real-CLI cases pass on both heads with retries disabled. The full unit run has 6,708 passes, 22 failures, and one skip; all 22 failing test names exactly match the separately reproduced untouched-main sandbox baseline described in the PR body. An isolated loader timeout during concurrent validation passed on its dedicated rerun.

The two latest code findings are covered by unit and real-CLI regressions. Conservative legacy/orphan handling and the documented full push/source transaction-isolation limitation remain unchanged. Exact-head hosted CI is still being followed. Landing order remains #929 first, then #931.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Do not let stale caches overwrite a newer shared installation — src/source.ts:587. Repository identity ignores the source alias, but caches include it. If two aliases reference the same URL and share a destination, one alias can have a newer cache while the other remains within TTL or falls back after a failed pull; the latter is treated as the same producer and overwrites the shared skill with stale content. Removing it then preserves that stale content for the remaining owner.
  • [P1 blocking] Distinguish a stale installation from a re-added alias before removing configuration — src/source.ts:283. With a shared checkout, destination A can remove alias shared, then re-add it for another repository while destination B still has the old manifest. When B runs source remove shared to clean its stale installation, the name-only lookup finds the new subscription and deletes it from teamai.yaml, potentially orphaning A’s new installation. Compare repository identities before rewriting the shared configuration or provide a manifest-only cleanup path.

The previously reported findings are resolved. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Both newly reproduced alias transitions are addressed in 674755b (#929), with the dependent crossover test rebased to bd02c10 (#931).

  • All aliases of the same configured URL now use one hash-keyed clone and pull timestamp under ~/.teamai/source-repos/, guarded by the existing source lifecycle mutex. A TTL hit or failed refresh under another alias cannot select an older alias-specific revision. Removing an alias still never deletes this shared cache. Older alias-scoped caches remain untouched and are not adopted.
  • Removal compares the scoped manifest's repository identity with the current subscription before editing shared teamai.yaml. An old or unidentified installation can clean its own files/record but preserves a re-added subscription, its comments, and the other destination's manifest/files.

The new real-CLI negative controls fail on the previous head: beta rolls revision B back to A, and stale beta removal deletes alpha's replacement URL from YAML. Both pass now. Coverage exercises distinct commits, TTL reuse, offline fallback, removal under both aliases, known/unknown stale identities, and dry-run preservation before any later pull can repair state.

Build/typecheck/lint pass; 207 focused tests and all 94 read-only-loader regressions pass. All 16 source real-CLI cases pass on both heads with retries disabled. The full unit run has 6,709 passes, the same 22 untouched-main sandbox failures, and one skip. The cache readers/writers, TTL, alias removal, replacement, and physical-path transitions were reviewed together. Updated docs retain the explicit legacy/orphan and full push/source transaction-isolation limits.

Exact-head CI and review are still pending. Landing order remains #929, then #931; #931's unique change remains the 35-line crossover regression.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Reject root-equivalent paths before granting deletion authority — src/source.ts:99. The validator accepts installedPaths: { skill: [""] } or "."; cleanup resolves either to baseDir, assertWithinRoot permits equality, and remove() can recursively delete the project root or HOME. Require every recorded path to be a non-empty relative descendant, and validate fallback installedSkills names before cleanup.

The earlier reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

The deletion-authority finding is fixed in b1736a7 (#929), with #931 rebased to f2ed4fd.

Manifest reads now reject empty/root-equivalent, escaping, absolute, drive-relative, and NUL-containing paths, plus unsafe fallback skill names. Invalid records are rejected before source removal changes YAML or files. Cleanup also independently refuses lexical root equality and resolved physical roots/ancestors. Public source names pass the same relative-path safety check before deployment; legitimate nested names remain supported.

Twenty negative validator fixtures were accepted by the previous code and are rejected now. The built CLI also rejects eight malformed cleanup attempts while preserving configuration bytes, the invalid manifest, and the installed skill, and releasing its lock.

Build/typecheck/lint pass. Validation is now 231 focused tests, 94 read-only-loader tests, and 16 real-CLI cases on each head, with retries disabled. The full unit run has 6,733 passes, the same 22 reproduced untouched-main sandbox failures, and one skip. Independent review of the validator and deletion boundaries found no further concrete bypass. Exact-head hosted CI and the new review are still pending.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Validate publicSkills entries as resource names, not merely descendants — src/source.ts:754. isRelativeDescendant() accepts values such as group/../team-skill (and the Windows equivalent). Path resolution then finds and deploys skills/team-skill, while the local-team conflict check compares the unnormalized string, allowing a source repository to overwrite the team-owned team-skill. Require a separator-free resource name or reject any value that changes during normalization.

Previously reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the name-priority and removal-order findings in 417e314 (#929), with #931 rebased to afe9001.

  • Public and recorded skill identities must already be canonical. Normalization-changing segments, repeated separators, backslashes, and trailing slashes are rejected before deployment. Legitimate canonical nested names still work, but may not overlap local-team or builtin skill roots in either direction. The same guard covers deployment, stale cleanup, and direct removal.
  • Source removal builds the full ownership-checked deletion plan before editing YAML. Malformed foreign records and physical-root targets now leave configuration, manifests, and installed files untouched. The existing source mutex protects the ownership plan; no new transaction/lock protocol was added.

Ten negative name fixtures and a real-CLI malformed-peer case reproduce the previous failures. Added coverage also preserves team/builtin script directories when a stale nested source is removed, and verifies ordinary canonical nested deployment/withdrawal still works.

Build/typecheck/lint pass; 244 focused tests and 94 read-only-loader tests pass. All 16 real-CLI cases pass on both heads with retries disabled. The full unit run has 6,746 passes, the same 22 untouched-main sandbox failures, and one skip. Updated descriptions document the current behavior and existing limits. Exact-head hosted CI/review are being followed; landing order remains #929 then #931.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Remove stale descendants when a source changes from a nested skill to its parent — src/source.ts:688. If publicSkills changes from group/child to group, copyDir merges the new parent into the existing directory, then currentOwners treats the parent as overlapping and prevents deletion of the withdrawn child. The obsolete child remains deployed but disappears from the manifest.
  • [P1 blocking] Do not discard ownership merely because a new team skill overlaps it — src/source.ts:684. If a source previously installed group/child and the local team later adds group, cleanup is skipped and the new manifest drops group/child. Its stale files remain inside the team skill untracked and can subsequently be published as team content.

All previously reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst
NianJiuZst force-pushed the codex/fix-source-cache-identity branch from 417e314 to da14bd0 Compare October 1, 2026 15:39
@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the nested ownership and provenance findings in da14bd0 (#929), with #931 rebased to 8362373 on the same implementation and current main (85ff72c).

  • Canonical nested names remain supported. Before any copy, pull rejects ambiguous parent/child boundary changes and exact-path collisions between different skill identities. The previous installation stays intact with manual-review/removal guidance. Ordinary nested updates, disjoint moves, and same-repository/same-skill exact-path sharing still work.
  • Retained files keep their source provenance when protected by team/builtin content or a foreign child installation. Validated fallback paths from older scoped records remain visible to physical ownership and push filtering. Removing a child owner cannot expose the retained parent's source bytes as local content.
  • Status and skill details use actual scoped physical paths for nested source labels, including duplicate aliases. Unrelated same-named copies and bundled modules are not adopted. Unreadable provenance emits an explicit uncertainty warning.
  • Removed all direct changes to skill-data/core/SKILL.md from both PR diffs, as requested. The usage guides and directory design retain the behavior and safety documentation.

Validation on these heads: build, typecheck, and lint pass; 302 focused tests and 94 read-only loader regressions pass; all 22 real-CLI cases pass on each head with retries disabled. The six new parent/child CLI scenarios fail on the prior implementation and pass with this guard. A built-CLI list/show smoke also verifies nested labels, duplicate aliases, and unrelated-copy isolation.

The full local unit run has 6,907 passes, one skip, and the same 22 MCP sandbox failures reproduced on untouched 85ff72c; there are no final-only failures. Updated PR descriptions include the detailed test record and remaining legacy/orphan/concurrency limits. Exact remote heads are verified; new-head hosted CI and review are being followed. Landing order remains #929, then the regression-only #931.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Preserve the installed physical destination before allowing cleanup — src/source.ts:952. Manifests record only a lexical path relative to destinationRoot, and removal resolves that path through the filesystem as it exists now. If an installed tool directory such as ~/.claude/skills is a symlink and is repointed after pull, source remove follows the new ancestor and recursively deletes the same-named directory in the unrelated target. Record the original physical destination and require it to match before deletion.

All previously reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Fixed physical-destination ownership in 9f105c2 (#929); #931 is rebased to 8dcd8aa with only its 35-line crossover regression unique to that PR.

  • Manifests pin actual post-copy physical destinations. Pull, withdrawal, and removal verify all old destinations before any installed-file, YAML, or manifest change. Repointed, removed, dangling, or unverifiable links stop with manual-review guidance.
  • Foreign ownership stays tied to the original pin. Cleanup rechecks it and deletes the canonical target. Copy preflight models leaf-symlink replacement and refuses lexical boundary changes that would abandon an old pin, including an old nested child.
  • Newly installed stable symlink paths and canonical nested names remain supported. Historical unpinned symlink paths cannot establish past ownership and require manual review; plain historical paths remain compatible.

All 37 new focused pin regressions pass, including both leaf-link transition negative controls. Three real-CLI negative controls reproduce the previous deletion/overwrite and now pass, with exact YAML/manifest preservation and successful recovery after restoring the original link. Final validation on both heads: all 25 real-CLI cases pass with retries disabled; build/typecheck/lint pass. There are 339 focused passes plus 94 loader passes. Full units: 6,944 passed, one skipped, and exactly the same 22 sandbox failures reproduced on untouched main 85ff72c.

The core-skill diff remains empty in accordance with the explicit human review instruction. The automated P2 request to add that text back conflicts with this instruction; the bilingual usage guides and directory design carry the safety guidance. Exact-head hosted CI/review are being followed. No PR has been merged or closed.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Scope modern push exclusions by physical path — src/resources/skills.ts:565. getAllSourceSkillNames(localConfig) includes every skill name in the current scoped manifests, and the scan discards matching names before checking sourcePathOwners. For example, if a source installed foo only into Claude, then Codex is installed later with an unrelated local foo, teamai push silently omits the Codex skill despite its path not being source-owned. Restrict name-only quarantine to legacy/unpinned records and use physical ownership for modern manifests.

All previously reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the path-scoped push finding in 3ae5798 (#929), with dependent #931 rebased to ada8cea.

Modern manifests with complete physical pins are now excluded only by owned physical paths. A Claude source foo no longer hides an independent Codex foo. Name-only quarantine is limited to legacy/unpinned or rootless/incomplete ownership and includes nested basenames; malformed pin metadata still fails closed. Scoped provenance labels are unchanged.

The negative real-CLI case reproduces the previous silent omission. The fixed CLI selects and publishes the independent Codex payload to the fixture's local bare repository, while preserving/excluding Claude's source-owned bytes. Legacy and scoped-unpinned cases remain quarantined. All 21 new focused cases and three CLI cases pass.

Final verification: build/typecheck/lint pass; 360 focused tests plus 94 loader regressions pass; all 28 source real-CLI cases pass on each head with retries disabled. The isolated full suite has 6,965 passes, one skip, and exactly the 22 failures reproduced on untouched main 85ff72c. One earlier concurrent loader timeout cleared in both its focused run and the isolated full rerun. Both existing PRs remain open, with #929 first and #931's unique diff still the 35-line crossover test. New-head hosted CI and review are being followed.

The core skill remains unchanged as requested by the human reviewer; the usage guides and directory design retain the documented safety and recovery limits.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Preserve Codex duplicate reconciliation after ownership preflight — src/source.ts:698. Calling resolveSkillDestination without skill.sourcePath disables its verified duplicate cleanup, and the later copy never invokes that cleanup. If identical copies already exist at .agents/skills/foo and .codex/skills/foo, pulling records only the shared path while leaving the configured copy unowned; the next teamai push can classify and publish that source-provided copy as a local skill. Re-run the resolver with sourcePath after all targets pass preflight, or explicitly remove the verified duplicate before recording ownership.

Previously reported findings appear resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Restored safe Codex reconciliation in 4aeefc9 (#929), with #931 rebased to e34c581.

The first resolver pass remains side-effect free. After every ownership/transition and cleanup-candidate check passes, the existing resolver removes an unowned configured duplicate only when it matches both the shared copy and incoming source. Foreign/current owners, planned paths, physical aliases, repository cache, and resolved inputs are protected. Different local copies keep their conflict warning and remain push candidates; dry-run changes nothing.

The same boundary review reproduced source-root link data loss. In-repository root aliases now install concrete directories; outside/dangling/looping root aliases stop before deployment. Previously installed root links keep their manifests and referents for manual review, even when an older pin exists. Ordinary nested names and stable tool-destination symlinks still work. This correction adds no further manifest fields or nested file-link migration.

Thirty focused regressions and six new real-CLI cases pass. The full final validation includes 390 focused tests, 94 loader tests, and all 34 real-CLI source cases on each head with retries disabled. Build/typecheck/lint pass. Full units: 6,995 passed, one skipped, and exactly the same 22 MCP sandbox failures reproduced on untouched main 85ff72c.

Both branches are updated and their dependency remains unchanged: #929 contains the implementation, #931 adds only the 35-line crossover regression. The core-skill diff stays empty as requested by the human reviewer; bilingual usage/design documentation covers the behavior and limits. Following hosted CI and review for these exact heads.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P1 blocking] Do not infer cleanup targets from the current tool configuration — src/source.ts:1099. For a supported scoped manifest without installedPaths, changing toolPaths after installation and then withdrawing/removing the source makes cleanup target the new tool directory. An unrelated same-named local skill there is deleted, while the original source copy remains at its historical location. Unpinned records must not authorize deletion; retain/quarantine them for manual review instead.

All previously reported findings are resolved in the current diff. The PR description includes sufficient real-CLI verification.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Addressed the remaining P1 about old scoped claims without recorded paths in 2b2f74d (#929), inherited by 4706ed7 (#931). Repository replacement now keeps the entire prior installation and warns before fallback adoption or any deployment. Ambiguous scoped names also remain quarantined across checkouts sharing HOME; fully pinned modern records still filter by actual path only. No new deletion authority or guessed migration paths were added.

Validation: 26 focused new cases, 3 new built-CLI cases, and the complete 37-case source CLI suite pass on both heads with retries disabled. The full implementation run has 7,021 passes and the same 22 failures independently reproduced on untouched main in this sandbox; 416 focused plus 94 loader tests, build, typecheck, and lint pass. Hosted checks are following these exact heads.

The core skill remains unchanged as requested by the human reviewer; equivalent guidance is in the bilingual usage guides and directory design. #929 remains the implementation to land first, with #931 retaining only its 35-line crossover extension as the unique change.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Resolved the changed-toolPaths P1 in efd9491 (#929), inherited by 8d1485d (#931). Lifecycle helpers no longer infer historical destinations from current configuration. Any missing or empty old path keeps the entire installation, files, and YAML intact for manual review, including same-repository update/withdrawal/removal and previews. Explicitly recorded plain paths remain supported.

The same missing-history boundary also protected against another checkout: ambiguous foreign scoped and rootless legacy claims now veto equal/parent/child logical names before copying or cleanup. This preserves the old claim without inventing a physical path or allowing same-repository aliases to bypass it. Unrelated names and complete recorded foreign paths retain their usual behavior.

All 16 affected real-CLI negative controls reproduced unsafe overwrite/deletion or lost tracking on the older builds and now pass. Final coverage: 481 focused tests, 94 loader tests, and 50 real-CLI source cases on each branch, retries disabled. Build/typecheck/lint pass. The complete unit run has 7,086 passes, one skip, and exactly the 22 failures independently reproduced on untouched main in this sandbox; hosted exact-head checks are following.

The human-requested core-skill removal remains honored. Bilingual usage/design documentation explains manual review and the conservative legacy limitation; no automatic destructive migration is claimed. #929 still lands first and #931 still adds only the 35-line crossover regression.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Previously reported findings are resolved, and the PR description includes sufficient real-CLI verification.

  • [P1 blocking] Enumerate valid source aliases without resource-directory filtering — src/source.ts:1104. assertSafeResourceName permits aliases such as .git and node_modules, but listDirs() deliberately omits those names. After pulling a source under either alias, all global ownership readers skip its manifest: another repository can overwrite its installed paths, and teamai push can publish its files as local content. Reject these reserved aliases or enumerate source directories without listDirs() filtering.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Fixed accepted-alias enumeration in 18511bc (#929), inherited by 76f4cf5 (#931). All source metadata readers now use an unfiltered directory enumeration; normal resource scanning keeps its existing ignore rules. Previously accepted aliases remain supported. Missing metadata directories are empty, while other enumeration errors propagate rather than silently removing ownership.

All 49 alias-focused cases pass across the six filtered names plus an ordinary control. Both real-CLI negatives reproduce the reported risk on the prior build: a different producer overwrites node_modules-owned files, and a normal push exports .git-owned files to the local fixture remote. Both now pass; only the independent local draft is published.

Final validation: 530 focused tests, 94 loader tests, 52 real-CLI cases on each head, build, typecheck, and lint pass. Full suite: 7,135 passed, one skipped, exactly the same 22 sandbox failures reproduced on untouched main. Both branches retain the #929-first dependency and the unchanged core skill requested by the human reviewer. Following fresh exact-head hosted checks.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

No findings.

  • All previously reported issues are resolved in the current diff.
  • The PR description includes sufficient real-CLI/end-to-end verification for the runtime changes.
  • Per instruction, I reviewed the diff only and did not run or build the PR.

@NianJiuZst

Copy link
Copy Markdown
Contributor Author

Final exact-head CI passed for #929 18511bc and #931 76f4cf5: all six Linux/macOS Node jobs, Build, fork-safe E2E, Code Erosion, and Tencent scan succeeded. The credentialed full-surface job is intentionally skipped for fork PRs.

The latest #929 review has no findings; #931 confirms all implementation issues are resolved and retains only the non-blocking skill-doc request already addressed by following the human instruction to leave the core skill unchanged. Both PRs are conflict-free and remain open for maintainer re-review. Land #929 first; #931's unique diff remains its 35-line crossover regression.

@jeff-r2026
jeff-r2026 merged commit e2ca08f into Tencent:main Oct 2, 2026
13 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…ncent#929)

* fix(source): isolate repository caches by source URL

* fix(source): scope installation manifests to team and destination

* fix(source): allow scoped cleanup after shared subscription removal

* fix(source): retain skill paths owned by another installation

* fix(source): prevent conflicting repositories from replacing shared skills

* fix(source): enforce ownership on lifecycle and push paths

* fix(source): keep cache previews read-only

* fix(source): release withdrawn and retargeted ownership

* fix(source): share URL revisions and preserve re-added aliases

* fix(source): reject unsafe ownership paths before cleanup

* fix(source): preflight removal and preserve team skill boundaries

* fix(source): retain provenance for protected installations

* fix(source): preserve nested installation boundaries and provenance

* fix(source): pin installed physical destinations before cleanup

* fix(source): quarantine pinned installations by physical path

* fix(source): reconcile Codex duplicates after ownership preflight

* fix(source): retain ambiguous claims across repository replacements

* fix(source): require recorded destinations for lifecycle mutations

* fix(source): enumerate every accepted ownership alias
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.

2 participants