chore(storage,workspace): gates — coverage, catalogs, bilingual note

- Per-file 100% coverage across the five new packages (invariant
  companion suites, failure-injection negatives, lifecycle and
  malformed-medium branches).
- Canonical README Model Experience / Known Limitations sections; new
  storage/ and workspace/ group READMEs; packages/README.md rows (budget
  ceiling raised 760 → 790 for the two new groups).
- Cordis catalog/type-link registrations, service-role classification,
  and regenerated catalogs/graphs for the new services and events.
- Agent Note: English body + i18n pairing record; design-sketch fences
  opted out of doc-typecheck as ignore-check.
- Two exactOptionalPropertyTypes/discriminant fixes in new tests.

doc-sync (24 gates), typecheck, hygiene, and the five-package suite
(92 tests) all pass.
This commit is contained in:
imccyu
2026-07-24 22:49:57 +08:00
parent 80b3b6d917
commit 0559e0207e
33 changed files with 1333 additions and 58 deletions

View File

@@ -45,14 +45,14 @@ export class JsonStorageBackend implements StorageBackend {
constructor(private readonly root: string) {}
readonly kv: KvFacet = {
open: (descriptor: KvUnitDescriptor): Promise<KvUnit> => {
if (this.closed) return Promise.reject(new StorageError('closed', 'json backend is closed'))
// The body up to the first await runs synchronously, so the opening-slot
// reservation below still excludes a concurrent open of the same unit.
open: async (descriptor: KvUnitDescriptor): Promise<KvUnit> => {
if (this.closed) throw new StorageError('closed', 'json backend is closed')
validateDescriptor(descriptor)
if (this.open.has(descriptor.name) || this.opening.has(descriptor.name)) {
// Double-open is a caller bug, not a medium condition.
return Promise.reject(
new Error(`unit '${descriptor.name}' is already open; a unit has exactly one live handle`),
)
throw new Error(`unit '${descriptor.name}' is already open; a unit has exactly one live handle`)
}
const opening = this.openUnit(descriptor)
this.opening.set(descriptor.name, opening)

View File

@@ -14,7 +14,13 @@ import { writeAtomic } from './atomic.ts'
import { parse, serialize } from './format.ts'
import type { UnitState } from './format.ts'
/** Open (load or lazily create) one unit backed by `path`. */
/**
* Open (load or lazily create) one unit backed by `path`.
* @param descriptor - Static identity and shape of the unit.
* @param path - Absolute unit file path under the backend root.
* @param onClose - Backend callback releasing the unit's open-slot.
* @returns the opened unit.
*/
export async function openJsonUnit(
descriptor: KvUnitDescriptor,
path: string,