fix(apiproxy): ensure the recorded composition before reading the baseline

`session.history` built its projection baseline in `historyStateFor` and only
then awaited `presenterScopeFor`, which is what ensures the recorded preset's
standing mount. The unit table is process-wide while the units themselves are
registered by preset rows, so on a first cold read the baseline was serialized
before `todos` (and every other preset-owned key) existed, and every later read
served a complete one. Until this branch, a web lane happened to mount a preset
in `beforeAll` for unrelated reasons, which hid the ordering.

The baseline is now a thunk the handler reads after the scope resolves. Also
covers the roster-less early return of the unjoined-agent warning, which the
per-file coverage gate reported uncovered.
This commit is contained in:
Yichen Jiang
2026-08-10 23:33:26 +08:00
parent fe221be572
commit 8d7c4380aa
2 changed files with 44 additions and 10 deletions
@@ -515,6 +515,19 @@ describe('replacing a composition', () => {
expect(warnings).toEqual([])
})
it('says nothing when the deployment configures no roster at all', async () => {
// Presets are optional: every surface except the Web bundle keeps its
// model-facing rows in the host plane, so an agent with a chain of one is
// exactly right there and the diagnostic must stay silent.
const rosterless = await harness({ default: 'standard', roots: [] })
const warnings: string[] = []
rosterless.logger.warn = ((message: unknown) => { warnings.push(String(message)) }) as typeof rosterless.logger.warn
await rosterless.agents.create({ sessionId: SessionId('sess-no-roster') })
expect(warnings).toEqual([])
})
it('composes an agent that had nothing installed', async () => {
// An agent created without a preset has no binding to re-link, so the
// switch is its first bind — exactly a mount — and once bound only the