Skip to content

session archive: drop redundant index-lock wrappers and own-key the platform facts lookup #1325

Closed

Description

@SaulMoro

The two bugs this issue first described are fixed on main by #1334:

  • Concurrent teamai session push runs no longer race on the git publication. withSessionPublicationLock now serializes publication.
  • A save that fails before the index rename no longer leaves an orphan transcript and metadata pair. The pair is rolled back.

What remains is cleanup in the same code, left over from #1302 and still present after #1334.

Redundant index-lock wrappers

Six callers still wrap the self-locking archive methods in withSessionIndexLock:

  • src/session-flow/session-cmd.ts:216, :289, :313, :319
  • src/session-flow/session-migrate-cmd.ts:479
  • src/session-flow/session-cmd-shared.ts:252

So a busy archive surfaces in two ways. One is a { status: 'busy' } result from the wrapper. The other is Error('Session archive is busy…') from the method (src/session-flow/sync.ts:449). If writeArchive returned the status and the wrappers were dropped, the AsyncLocalStorage re-entry that exists only for this nesting could go too.

Inherited keys in sessionPlatformFacts

sessionPlatformFacts('constructor'), 'toString' and '__proto__' return an inherited property instead of undefined, because the lookup indexes a plain object (src/session-flow/adapters/platform-facts.ts:127). The one production caller validates the tool first, so nothing reaches it today. An Object.hasOwn check would close it and remove the cast on that line.

Activity

  1. added
    bugSomething isn't working
    help wantedExtra attention is needed
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on Oct 23, 2026
  2. changed the title [-][bug] session push: concurrent pushes race on git, and a failed archive write leaves orphan files[/-] [+]session archive: drop redundant index-lock wrappers and own-key the platform facts lookup[/+] on Oct 23, 2026
  3. XY-code1 commented on Oct 25, 2026

    @XY-code1
    Contributor

    Hi, I'd like to work on this. I'll keep the change scoped to the two remaining items: reject inherited keys in sessionPlatformFacts, then remove the redundant external index-lock wrappers while preserving the existing busy result/error behavior and concurrency coverage. I'll verify the full call graph before removing the AsyncLocalStorage re-entry path, and include focused regressions plus typecheck/lint/test results.

  4. SaulMoro commented on Oct 25, 2026

    @SaulMoro
    CollaboratorAuthor

    This was generated by AI during triage.

    Status: #1375 covers both remaining items (own-key lookup in sessionPlatformFacts, and removing the external index-lock wrappers and the re-entry path) and is approved at ea4ca4a. It closes this issue when it merges. The two publication bugs were fixed earlier in #1334.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions