forked from cflmy/deepseek-harness
docs(cordis): document isolate fallback and root symbol access
This commit is contained in:
1 parent
798d3586bb
commit
1b45ca1a9e
8 files changed
+46
-37
No files matched your search
@@ -12,11 +12,11 @@
|
||||
en: 18c7f34127f5c5fc
|
||||
zh: fa37a391e9c49f24
|
||||
/context/ctx-isolate-name-label:
|
||||
en: e086cbc07d463960
|
||||
zh: 7912984e036dbae9
|
||||
en: 4b61ce02474b983b
|
||||
zh: 5ab2948ddcff2687
|
||||
/context/ctx-intercept-name-config:
|
||||
en: e4a9d3a55ed550fc
|
||||
zh: 85ebe8f0d30770e3
|
||||
en: 7efc60c71ddc4a6e
|
||||
zh: 58dd647c41c10897
|
||||
/context/ctx-baseurl:
|
||||
en: 29c28e7558cea0ad
|
||||
zh: 9b591e449c1bfd72
|
||||
@@ -36,8 +36,8 @@
|
||||
en: ceb197529207a8ed
|
||||
zh: 7d444c03f8be0f0d
|
||||
/context/static-members/context-root:
|
||||
en: ad7203bb4b3533fe
|
||||
zh: 02b867b883050548
|
||||
en: 7616dd841e4f04cb
|
||||
zh: 2f1a3bdb9ed1f6f7
|
||||
/context/static-members/context-effect:
|
||||
en: 6c3b77ace7d4fda3
|
||||
zh: 470c685819275d5f
|
||||
@@ -45,11 +45,11 @@
|
||||
en: 1c97248eeabea2d0
|
||||
zh: 08eadac6a0871429
|
||||
/context/static-members/context-isolate:
|
||||
en: 471d09c9440bf738
|
||||
zh: eecc52f4e5984dbf
|
||||
en: 6c490ac1293b0315
|
||||
zh: 51d371b38de7773a
|
||||
/context/static-members/context-intercept:
|
||||
en: 57e806faa3abfff6
|
||||
zh: 3d32af39e2019758
|
||||
en: d3f44b89b641a11b
|
||||
zh: b88177e0a59ef9a5
|
||||
/context/static-members/context-is-value:
|
||||
en: 0ef94fa412edfe17
|
||||
zh: 30b64cd2fbb2d12e
|
||||
|
||||
@@ -46,6 +46,9 @@ The child prototypally inherits every property of this context; own properties o
|
||||
* resolve against the new label instead of the parent's, so a different
|
||||
* implementation can be provided without affecting the parent scope.
|
||||
* Passing the same `label` to two `isolate()` calls joins their scopes.
|
||||
* The returned context and plugins started below it never fall back to the
|
||||
* enclosing plugin's injected `name`, even when `label` equals the parent's
|
||||
* label; until a provider in the new scope supplies `name`, reading it throws.
|
||||
*
|
||||
* @param name — the service name to isolate.
|
||||
* @param label — scope label to join; defaults to a fresh unique symbol.
|
||||
@@ -56,14 +59,14 @@ isolate(name: string, label?: symbol)
|
||||
|
||||
Create a child context with an independent service scope for `name`.
|
||||
|
||||
Below the returned context, reads and writes of the service `name` resolve against the new label instead of the parent's, so a different implementation can be provided without affecting the parent scope. Passing the same `label` to two `isolate()` calls joins their scopes.
|
||||
Below the returned context, reads and writes of the service `name` resolve against the new label instead of the parent's, so a different implementation can be provided without affecting the parent scope. Passing the same `label` to two `isolate()` calls joins their scopes. The returned context and plugins started below it never fall back to the enclosing plugin's injected `name`, even when `label` equals the parent's label; until a provider in the new scope supplies `name`, reading it throws.
|
||||
|
||||
- `name` — the service name to isolate.
|
||||
- `label` — scope label to join; defaults to a fresh unique symbol.
|
||||
|
||||
**Returns** a child context whose `name` service resolves in the new scope.
|
||||
|
||||
[Source](../../vendor/cordis/src/context.ts#L123)
|
||||
[Source](../../vendor/cordis/src/context.ts#L126)
|
||||
|
||||
### ctx.intercept(name, config)
|
||||
|
||||
@@ -94,7 +97,7 @@ Plugins loaded under the returned context see `config` merged into the service's
|
||||
|
||||
**Returns** a child context carrying the additional intercept entry.
|
||||
|
||||
[Source](../../vendor/cordis/src/context.ts#L142)
|
||||
[Source](../../vendor/cordis/src/context.ts#L145)
|
||||
|
||||
### ctx.baseUrl
|
||||
|
||||
@@ -156,11 +159,11 @@ The plugin registry. Its methods are mixed onto `ctx` (`ctx.plugin`, `ctx.inject
|
||||
### Context.root
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the root context (see the `Context[symbols.root]` property). */
|
||||
/** Symbol key of the root context: `ctx[Context.root]` is the application's root context, shared by every child context. */
|
||||
static readonly root: unique symbol
|
||||
```
|
||||
|
||||
Symbol key of the root context (see the `Context[symbols.root]` property).
|
||||
Symbol key of the root context: `ctx[Context.root]` is the application's root context, shared by every child context.
|
||||
|
||||
[Source](../../vendor/cordis/src/context.ts#L44)
|
||||
|
||||
@@ -189,22 +192,22 @@ Symbol key for a context's listener filter, consulted on every event dispatch.
|
||||
### Context.isolate
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the isolation map (see the `Context[symbols.isolate]` property). */
|
||||
/** Symbol key of the isolation map: `ctx[Context.isolate]` maps each service name to its scope label. */
|
||||
static readonly isolate: unique symbol
|
||||
```
|
||||
|
||||
Symbol key of the isolation map (see the `Context[symbols.isolate]` property).
|
||||
Symbol key of the isolation map: `ctx[Context.isolate]` maps each service name to its scope label.
|
||||
|
||||
[Source](../../vendor/cordis/src/context.ts#L50)
|
||||
|
||||
### Context.intercept
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the intercept map (see the `Context[symbols.intercept]` property). */
|
||||
/** Symbol key of the intercept map: `ctx[Context.intercept]` maps each service name to its intercept metadata. */
|
||||
static readonly intercept: unique symbol
|
||||
```
|
||||
|
||||
Symbol key of the intercept map (see the `Context[symbols.intercept]` property).
|
||||
Symbol key of the intercept map: `ctx[Context.intercept]` maps each service name to its intercept metadata.
|
||||
|
||||
[Source](../../vendor/cordis/src/context.ts#L52)
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ extend(meta = {}): this
|
||||
* resolve against the new label instead of the parent's, so a different
|
||||
* implementation can be provided without affecting the parent scope.
|
||||
* Passing the same `label` to two `isolate()` calls joins their scopes.
|
||||
* The returned context and plugins started below it never fall back to the
|
||||
* enclosing plugin's injected `name`, even when `label` equals the parent's
|
||||
* label; until a provider in the new scope supplies `name`, reading it throws.
|
||||
*
|
||||
* @param name — the service name to isolate.
|
||||
* @param label — scope label to join; defaults to a fresh unique symbol.
|
||||
@@ -58,14 +61,14 @@ isolate(name: string, label?: symbol)
|
||||
|
||||
创建一个子上下文,使 `name` 拥有独立的服务作用域。
|
||||
|
||||
在返回的上下文之下,对服务 `name` 的读写会根据新标签解析,而不再根据父上下文的标签解析,因此可以提供不同的实现而不影响父作用域。将同一个 `label` 传给两次 `isolate()` 调用,可使二者加入同一作用域。
|
||||
在返回的上下文之下,对服务 `name` 的读写会根据新标签解析,而不再根据父上下文的标签解析,因此可以提供不同的实现而不影响父作用域。将同一个 `label` 传给两次 `isolate()` 调用,可使二者加入同一作用域。返回的上下文及在其下启动的插件都不会回退到外层插件注入的 `name`,即使 `label` 与父上下文的标签相同也是如此;在新作用域中有提供者提供 `name` 之前,读取它会抛出错误。
|
||||
|
||||
- `name`:要隔离的服务名称。
|
||||
- `label`:要加入的作用域标签;默认为一个新建的唯一 symbol。
|
||||
|
||||
**返回**一个子上下文,其 `name` 服务在新作用域中解析。
|
||||
|
||||
[源码](../../vendor/cordis/src/context.ts#L123)
|
||||
[源码](../../vendor/cordis/src/context.ts#L126)
|
||||
|
||||
### ctx.intercept(name, config)
|
||||
|
||||
@@ -96,7 +99,7 @@ intercept(name: string, config: any): this
|
||||
|
||||
**返回**一个携带额外拦截条目的子上下文。
|
||||
|
||||
[源码](../../vendor/cordis/src/context.ts#L142)
|
||||
[源码](../../vendor/cordis/src/context.ts#L145)
|
||||
|
||||
### ctx.baseUrl
|
||||
|
||||
@@ -158,11 +161,11 @@ registry: RegistryService
|
||||
### Context.root
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the root context (see the `Context[symbols.root]` property). */
|
||||
/** Symbol key of the root context: `ctx[Context.root]` is the application's root context, shared by every child context. */
|
||||
static readonly root: unique symbol
|
||||
```
|
||||
|
||||
根上下文的 symbol 键(见 `Context[symbols.root]` 属性)。
|
||||
根上下文的 symbol 键:`ctx[Context.root]` 是应用的根上下文,所有子上下文共享它。
|
||||
|
||||
[源码](../../vendor/cordis/src/context.ts#L44)
|
||||
|
||||
@@ -191,22 +194,22 @@ static readonly filter: unique symbol
|
||||
### Context.isolate
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the isolation map (see the `Context[symbols.isolate]` property). */
|
||||
/** Symbol key of the isolation map: `ctx[Context.isolate]` maps each service name to its scope label. */
|
||||
static readonly isolate: unique symbol
|
||||
```
|
||||
|
||||
隔离映射的 symbol 键(见 `Context[symbols.isolate]` 属性)。
|
||||
隔离映射的 symbol 键:`ctx[Context.isolate]` 将每个服务名称映射到其作用域标签。
|
||||
|
||||
[源码](../../vendor/cordis/src/context.ts#L50)
|
||||
|
||||
### Context.intercept
|
||||
|
||||
```ts cordis-catalog
|
||||
/** Symbol key of the intercept map (see the `Context[symbols.intercept]` property). */
|
||||
/** Symbol key of the intercept map: `ctx[Context.intercept]` maps each service name to its intercept metadata. */
|
||||
static readonly intercept: unique symbol
|
||||
```
|
||||
|
||||
拦截映射的 symbol 键(见 `Context[symbols.intercept]` 属性)。
|
||||
拦截映射的 symbol 键:`ctx[Context.intercept]` 将每个服务名称映射到其拦截元数据。
|
||||
|
||||
[源码](../../vendor/cordis/src/context.ts#L52)
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ describe('Schemastery input projection', () => {
|
||||
expect(accepts(result, { children: [{ children: [] }] })).toBe(true)
|
||||
expect(result.limitations.join(' ')).toContain('recursive default')
|
||||
expect(result.definitions.testRecursive0).not.toHaveProperty('anyOf')
|
||||
expect(accepts(result, { __jsExpr: 'ctx.root' })).toBe(true)
|
||||
expect(accepts(result, { __jsExpr: 'ctx[Symbol.for("cordis.root")]' })).toBe(true)
|
||||
expect(accepts(result, { children: [{ __jsExpr: 'ctx.child' }] })).toBe(true)
|
||||
expect(accepts(result, { children: [3] })).toBe(false)
|
||||
expect(JSON.stringify(result)).not.toContain('"uid"')
|
||||
|
||||
@@ -34,7 +34,7 @@ const SOURCE_LINK_POLICY: CordisCatalogPolicy = {
|
||||
foundationTypeNames: new Set(),
|
||||
typeLinkExemptions: {},
|
||||
inheritedEvents: [{ name: 'ready', summary: 'Ready.', source: 'vendor/cordis/src/events.ts:9' }],
|
||||
inheritedServices: [{ name: 'ctx.root', summary: 'Root.', source: 'vendor/cordis/src/context.ts:12' }],
|
||||
inheritedServices: [{ name: 'ctx.events', summary: 'Events.', source: 'vendor/cordis/src/context.ts:12' }],
|
||||
}
|
||||
|
||||
describe('Typert-backed Cordis catalog', () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** Cordis rc.11 updates retain dependency ownership and publish only current configuration. */
|
||||
/** Cordis lifecycle since rc.11 (vendored Core): updates retain dependency ownership and publish only current configuration. */
|
||||
import type { Awaitable } from '@deepseek-ai/cosmokit'
|
||||
import { Context, FiberState } from '@deepseek-ai/cordis'
|
||||
import { describe, expect, it, onTestFinished, vi } from 'vitest'
|
||||
@@ -110,7 +110,7 @@ describe('Cordis rc.11 lifecycle', () => {
|
||||
await isolated.plugin((child) => { expect(child.rc11View).toBe('inner') })
|
||||
await withdraw()
|
||||
expect(owner.rc11View).toBe('outer')
|
||||
// The isolated context does not fall back to the injected view once its own provision is withdrawn.
|
||||
// Since rc.12, the isolated context does not fall back to the injected view once its own provision is withdrawn.
|
||||
expect(() => isolated.rc11View).toThrow('without inject')
|
||||
})
|
||||
await ctx.plugin((owner) => {
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@ Keep this log exhaustive — every divergence from upstream must be listed. Each
|
||||
- **V4 · Vendored TypeScript source internal specifiers**: changed local relative imports/exports from upstream's specifier shape to explicit `.ts` specifiers so TypeScript rewrites emitted JS to `.js` while declarations keep explicit, NodeNext-safe `.ts` specifiers. This includes `loader/src/config/isolate.ts` using `declare module './entry.ts'`. Core's upstream source already uses explicit `.ts` specifiers. Type-only dependencies use `import type` or inline `type` modifiers so ESM output does not retain erased interfaces.
|
||||
- **V5 · `schemastery/tsdown.config.ts` and `logger-console/tsdown.config.ts`**: ours, not upstream files — per-package build-shape overrides (dual ESM+CJS output; separate node/browser entries) for the repo-root tsdown build. They read the JS emitted under `lib/types` and then write the publish runtime entries under `lib/`. Like the regenerated tsconfigs, they are not part of the upstream sync surface.
|
||||
- **V6 · `cordis/src/fiber.ts` lifecycle hardening**: locally closes three reentrant disposal gaps. An effect's owner-list wrapper is registered before its setup body runs, so an unload begun from inside setup awaits setup and every collected cleanup; synchronous setup failure removes the wrapper and rolls back collected cleanup. Async cleanup stays owner-visible until quiescence, and Cordis's internal effect composition joins an already-running cleanup while repeated public disposer calls retain their upstream single-shot result. Effect creation is rejected while the owner is `UNLOADING` (while `PENDING` and `LOADING` remain legal), preventing cleanup-time registrations from escaping the unload snapshot. Child fibers register and receive their parent-owned disposer before `internal/plugin` publication, resolve dependency declarations added by that notification before activation, drain effects attached while pending, and contain teardown-notification failures per observer so one callback cannot starve peers or interrupt ownership cleanup.
|
||||
- **V7 · Cordis, Loader and Timer JSDoc enrichment**: added `@param`/`@returns` tags and contract documentation (disposal semantics, waterfall veto, bail conditions, error cases) across the public plugin-author surface — `Context` (class, statics, and the `Context` interface properties incl. `[Context.root]`), module re-exports, shared utility helpers, `EventsService`, `Fiber`, `ValidationError` and its path helpers, `RegistryService`, `ReflectService`, `Service` and its intercept-metadata members, `LoggerService` and their `declare module './context.ts'` overloads. The upstream line comment on `reflect.ts`'s exported `locate()` is rewritten as JSDoc. Loader documentation covers `loader/src/{index,internal,config/entry,config/group,config/isolate,config/tree,config/utils}.ts`, including entry ownership, tree mutation methods, and the `!!js` discriminator. The upstream `EventsService.dispatch()` deprecation annotation is omitted: DSH enumerates callbacks to contain each observer failure independently, which the typed dispatch methods do not provide. Timer retains its local class and helper summaries; its README is local documentation because the upstream package has none. Comment-only; no code changes. Motivation: the website API-reference generator renders these docs and hard-errors on undocumented members. Retire this entry when the enrichment is upstreamed to the fork.
|
||||
- **V7 · Cordis, Loader and Timer JSDoc enrichment**: added `@param`/`@returns` tags and contract documentation (disposal semantics, waterfall veto, bail conditions, error cases) across the public plugin-author surface — `Context` (class, statics, the `isolate()` rule that isolated scopes never fall back to an injected view, and the `Context` interface properties incl. `[Context.root]`), module re-exports, shared utility helpers, `EventsService`, `Fiber`, `ValidationError` and its path helpers, `RegistryService`, `ReflectService`, `Service` and its intercept-metadata members, `LoggerService` and their `declare module './context.ts'` overloads. The upstream line comment on `reflect.ts`'s exported `locate()` is rewritten as JSDoc. Loader documentation covers `loader/src/{index,internal,config/entry,config/group,config/isolate,config/tree,config/utils}.ts`, including entry ownership, tree mutation methods, and the `!!js` discriminator. The upstream `EventsService.dispatch()` deprecation annotation is omitted: DSH enumerates callbacks to contain each observer failure independently, which the typed dispatch methods do not provide. Timer retains its local class and helper summaries; its README is local documentation because the upstream package has none. Comment-only; no code changes. Motivation: the website API-reference generator renders these docs and hard-errors on undocumented members. Retire this entry when the enrichment is upstreamed to the fork.
|
||||
- **V9 · `hmr/src/index.ts` module-watcher readiness and native paths**: realpath the existing watch base, classify framework modules and attach listeners before reporting readiness, and compare config paths using both canonical and configured spellings. This preserves Node module-cache identity across Windows short-name paths and filesystem aliases. The main watcher uses `ignoreInitial: true` so startup reads do not trigger another refresh; exact profile patch watching is owned by `packages/boot/hmr/src/watch-config.ts`. The Include change listener logs a rejected `Include.refresh()` instead of leaving the rejection unhandled; the rejection reports unsaved runtime changes while Include keeps its running tree. Covered by `packages/boot/hmr/tests/watch-config.spec.ts` and `scripts/cordis-vendor-hmr-include.spec.ts`.
|
||||
- **V10 · Vendored Node-compatible TypeScript**: marked erased imports explicitly across `cordis`, `loader`, `include`, `hmr`, and `schemastery` so Node's native TypeScript transform does not request types as runtime exports. Schemastery's source uses an ESM default export and its package declares `type: module`. Conditional exports select `.mjs` for import and `.cjs` for require; without them, concurrent imports under module-hook hosts reach the CJS entry and can race its require of ESM Cosmokit (`ERR_REQUIRE_ESM_RACE_CONDITION`).
|
||||
- **V11 · Include patch and YAML exports**: `include/src/index.ts` exports upstream `applyPatches` as `applyEntryPatches` and the `!!js` YAML dialect as `entryListSchema`, so `dsh --dump-config` composes entries with the same algorithm that mounting uses. Covered by `packages/boot/app-boot/tests/config-reload.spec.ts` and `scripts/cordis-entry-commit.spec.ts`.
|
||||
|
||||
Vendored
+7
-4
@@ -18,7 +18,7 @@ export interface Context {
|
||||
[symbols.root]: this
|
||||
/** Isolation map: service name → scope label. Lookups for a name resolve within its label. */
|
||||
[symbols.isolate]: Dict<symbol>
|
||||
/** Intercept map: service name → config merged into that service's per-plugin config. */
|
||||
/** Intercept map: service name → intercept metadata merged into that service's resolved metadata. */
|
||||
[symbols.intercept]: Dict
|
||||
/** Base URL used to resolve relative plugin/module specifiers, if the runtime sets one. */
|
||||
baseUrl?: string | undefined
|
||||
@@ -40,15 +40,15 @@ export interface Context {
|
||||
* contexts without mutating their parent.
|
||||
*/
|
||||
export class Context {
|
||||
/** Symbol key of the root context (see the `Context[symbols.root]` property). */
|
||||
/** Symbol key of the root context: `ctx[Context.root]` is the application's root context, shared by every child context. */
|
||||
static readonly root: unique symbol = symbols.root
|
||||
/** Symbol key under which a disposer exposes its {@link EffectMeta} diagnostics tree. */
|
||||
static readonly effect: unique symbol = symbols.effect
|
||||
/** Symbol key for a context's listener filter, consulted on every event dispatch. */
|
||||
static readonly filter: unique symbol = symbols.filter
|
||||
/** Symbol key of the isolation map (see the `Context[symbols.isolate]` property). */
|
||||
/** Symbol key of the isolation map: `ctx[Context.isolate]` maps each service name to its scope label. */
|
||||
static readonly isolate: unique symbol = symbols.isolate
|
||||
/** Symbol key of the intercept map (see the `Context[symbols.intercept]` property). */
|
||||
/** Symbol key of the intercept map: `ctx[Context.intercept]` maps each service name to its intercept metadata. */
|
||||
static readonly intercept: unique symbol = symbols.intercept
|
||||
|
||||
/**
|
||||
@@ -115,6 +115,9 @@ export class Context {
|
||||
* resolve against the new label instead of the parent's, so a different
|
||||
* implementation can be provided without affecting the parent scope.
|
||||
* Passing the same `label` to two `isolate()` calls joins their scopes.
|
||||
* The returned context and plugins started below it never fall back to the
|
||||
* enclosing plugin's injected `name`, even when `label` equals the parent's
|
||||
* label; until a provider in the new scope supplies `name`, reading it throws.
|
||||
*
|
||||
* @param name — the service name to isolate.
|
||||
* @param label — scope label to join; defaults to a fresh unique symbol.
|
||||
|
||||
Reference in new issue
Block a user