Cotal TypeScript packages
    Preparing search index...

    Function agentCredsDir

    • THE CHOKE POINT (§2 rule 1): <root>/.cotal/auth/creds/space.<hex> — this space's agent-secret dir, having moved any pre-P1 root-scoped files into it first.

      Every path and key below resolves through here, which is what makes "migrate on first touch" reach every flow rather than the ones someone remembered to update. A caller that builds join(agentCredsRoot(root), …) itself has reintroduced the read-fallback §2 rejects.

      THE MIGRATION IS PER FILE, and that is rule 2 met rather than dodged. P7 moves a fixed set of five kinds; this set is OPEN — one file per agent per kind, discovered by enumeration — so "the move is one renameSync" holds per FILE here instead of per kind. Each file is therefore wholly legacy or wholly canonical across a crash, and a crash midway through the set leaves a mixture that the next first touch simply finishes. That is §2.1's cause one, self-healing, and it needs no repair verb.

      Rules 3 and 4 come from the shared choke point unchanged, which is the point of calling it: rule 4 is re-asked per file rather than once for the set, so the cost is one tenant-count read per file MOVED. That is bounded by the one-time migration of a root — after it, the set is empty and the only cost is the enumeration — and it buys a single implementation of the rule instead of a sweep-shaped copy of it.

      Parameters

      Returns string