Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/clippy-baseline.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157
168
2 changes: 1 addition & 1 deletion src/eslint-baseline.linux.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5432
5431
18 changes: 18 additions & 0 deletions src/shared/generated/events/EventClassChannelStrategy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

/**
* Channel-strategy for an event class — how the event-name maps to an airc
* channel when `broadcast: true`. The transport consults this at emit time.
*
* - `Local` — no broadcast (paired with `broadcast: false`).
* - `Global` — mesh-wide single channel (e.g. `#presence`).
* - `ByRoomId` — event payload must carry `roomId`; routed to that
* room's airc channel.
* - `ByPeerId` — event payload must carry `peerId`; routed to a
* peer-targeted channel (DM-like).
* - `Custom` — caller-supplied channel resolver runs at emit time.
* (The resolver itself can't cross the wire — it's a per-process
* function ref — so on the TS side the resolver is registered
* separately from the Rust-canonical config.)
*/
export type EventClassChannelStrategy = "local" | "global" | "byRoomId" | "byPeerId" | "custom";
40 changes: 40 additions & 0 deletions src/shared/generated/events/EventClassConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EventClassChannelStrategy } from "./EventClassChannelStrategy";
import type { EventClassUnknownSchemaPolicy } from "./EventClassUnknownSchemaPolicy";

/**
* Caller-supplied event-class declaration. All optional fields fill with
* conservative defaults (no broadcast, no airc cost).
*/
export type EventClassConfig = {
/**
* Distribute this event class through the airc transport in addition
* to the local + WebSocket transports?
*
* `false` (default) — local + WebSocket only. Zero airc cost.
* `true` — also durable on the airc log; reaches cross-machine
* subscribers via the AircEventTransport (L1-2).
*/
broadcast: boolean,
/**
* How the event-name + payload map to an airc channel when broadcast
* is `true`. Defaults to `Local` when `broadcast: false`, otherwise
* required (validation throws on missing-when-broadcast).
*/
channel?: EventClassChannelStrategy,
/**
* Wire-format schema version. Subscribers fail loud on unknown
* versions per `on_unknown_schema`. Bump when the payload shape
* changes incompatibly.
*/
schemaVersion: string,
/**
* Action when a subscriber receives an event whose declared
* `schemaVersion` doesn't match its build. Default `Fail`.
*/
onUnknownSchema?: EventClassUnknownSchemaPolicy,
/**
* Optional human-readable description for `grid/show-event-classes`
* and similar introspection. Not load-bearing at runtime.
*/
description?: string, };
8 changes: 8 additions & 0 deletions src/shared/generated/events/EventClassUnknownSchemaPolicy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

/**
* Behavior when a subscriber receives an event with a `schemaVersion`
* it doesn't recognize. Default `Fail` matches the standing project rule
* of never silently swallowing evidence.
*/
export type EventClassUnknownSchemaPolicy = "warn" | "fail";
9 changes: 9 additions & 0 deletions src/shared/generated/events/ResolvedEventClassConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EventClassChannelStrategy } from "./EventClassChannelStrategy";
import type { EventClassUnknownSchemaPolicy } from "./EventClassUnknownSchemaPolicy";

/**
* Canonical, post-validation form of an event-class declaration.
* What the registry stores + what the TS side caches.
*/
export type ResolvedEventClassConfig = { name: string, broadcast: boolean, channel: EventClassChannelStrategy, schemaVersion: string, onUnknownSchema: EventClassUnknownSchemaPolicy, description: string, };
8 changes: 8 additions & 0 deletions src/shared/generated/events/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Auto-generated barrel export — do not edit manually
// Source: generator/generate-rust-bindings.ts
// Re-generate: npx tsx generator/generate-rust-bindings.ts

export type { EventClassChannelStrategy } from './EventClassChannelStrategy';
export type { EventClassConfig } from './EventClassConfig';
export type { EventClassUnknownSchemaPolicy } from './EventClassUnknownSchemaPolicy';
export type { ResolvedEventClassConfig } from './ResolvedEventClassConfig';
4 changes: 2 additions & 2 deletions src/shared/generated/governor/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Auto-generated barrel export — do not edit manually
// Source: workers/continuum-core/src/governor/types.rs (ts-rs)
// Re-generate: cargo test --lib --features metal,accelerate governor::
// Source: generator/generate-rust-bindings.ts
// Re-generate: npx tsx generator/generate-rust-bindings.ts

export type { CadenceMultipliers } from './CadenceMultipliers';
export type { CascadeAction } from './CascadeAction';
Expand Down
191 changes: 187 additions & 4 deletions src/shared/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,197 @@ export type { UsageMetrics } from './ai';
export type { VideoInput } from './ai';
export * from './airc';
export * from './code';
export * from './cognition';
// cognition: explicit exports (has duplicate types)
export type { AIDecisionContext } from './cognition';
export type { AIGatingDecision } from './cognition';
export type { AIGatingDecisionFactors } from './cognition';
export type { AdaptiveThroughputPlan } from './cognition';
export type { AdaptiveThroughputRequest } from './cognition';
export type { AdversarialPatternDecline } from './cognition';
export type { AnalysisError } from './cognition';
export type { AuditEntry } from './cognition';
export type { AuditEntryKind } from './cognition';
export type { EmbedToolsRequest } from './cognition';
export type { EmbedToolsResponse } from './cognition';
export type { GatingConversationMessage } from './cognition';
export type { GatingMessageContent } from './cognition';
export type { GatingRagContext } from './cognition';
export type { GatingRagMetadata } from './cognition';
export type { GatingRecipeStrategy } from './cognition';
export type { GatingTriggerMessage } from './cognition';
export type { GenerateResponseAdmissionPolicy } from './cognition';
export type { GenerateResponseRequest } from './cognition';
export type { GenerateResponseResult } from './cognition';
export type { HostCapability } from './cognition';
export type { ProbeError } from './cognition';
export type { HwCapabilityTier } from './cognition';
export type { LeverCall } from './cognition';
export type { LeverName } from './cognition';
export type { LocalOrCloudPolicy } from './cognition';
export type { MediaItemLite } from './cognition';
export type { ModelRequirement } from './cognition';
export type { NativeBatchOutcome } from './cognition';
export type { ParsedToolBatch } from './cognition';
export type { PersonaMediaConfigLite } from './cognition';
export type { PersonaRenderRequest } from './cognition';
export type { PersonaResponse } from './cognition';
export type { PersonaTurnPlan } from './cognition';
export type { PriorContribution } from './cognition';
export type { ProposalRating } from './cognition';
export type { RateProposalsRequest } from './cognition';
export type { RateProposalsResponse } from './cognition';
export type { RatingContext } from './cognition';
export type { RatingMessage } from './cognition';
export type { RecentMessage } from './cognition';
export type { RecipeDefinitionShape } from './cognition';
export type { RecipeGenerateHints } from './cognition';
export type { RecipeGenerationRequest } from './cognition';
export type { RecipeGenerationResponse } from './cognition';
export type { RecipePersonaCandidate } from './cognition';
export type { RecipeRagSourcePolicy } from './cognition';
export type { RecipeTemplateInfo } from './cognition';
export type { RecipeTurnBatchPlan } from './cognition';
export type { RecipeTurnBatchRequest } from './cognition';
export type { RecipeTurnTrigger } from './cognition';
export type { RedundancyCheckRequest } from './cognition';
export type { RedundancyDecision } from './cognition';
export type { ResolutionError } from './cognition';
export type { ResolvedModel } from './cognition';
export type { ResourceAdmissionPolicy } from './cognition';
export type { ResourceClass } from './cognition';
export type { ResponderDecision } from './cognition';
export type { ResponseDecision } from './cognition';
export type { ResponseProposal } from './cognition';
export type { SemanticSearchResult } from './cognition';
export type { SemanticSearchToolsRequest } from './cognition';
export type { SharedAnalysis } from './cognition';
export type { SharedAnalysisIntent } from './cognition';
export type { SharedRagSourcePlan } from './cognition';
export type { ShouldRespondRequest } from './cognition';
export type { SiliconResidencyRequirement } from './cognition';
export type { TargetSilicon } from './cognition';
export type { ThreatDetectionReport } from './cognition';
export type { ThreatEvidence } from './cognition';
export type { ThreatFrame } from './cognition';
export type { ThreatFrameKind } from './cognition';
export type { ThreatPatternKind } from './cognition';
export type { ThreatRefusalAuditPayload } from './cognition';
export type { ThreatSeverity } from './cognition';
export type { ThreatSignal } from './cognition';
export type { ThroughputJob } from './cognition';
export type { ThroughputLaneBudget } from './cognition';
export type { ThroughputLease } from './cognition';
export type { ThroughputLeaseRevocationPolicy } from './cognition';
export type { ThroughputLeaseSnapshot } from './cognition';
export type { TokenUsage } from './cognition';
export type { ToolDescription } from './cognition';
export type { ToolEmbedding } from './cognition';
export type { ToolError } from './cognition';
export type { ToolExecutionContext } from './cognition';
export type { ToolInvocation } from './cognition';
export type { ToolOutcome } from './cognition';
export type { ValidateResponseDecision } from './cognition';
export type { ValidateResponseRequest } from './cognition';
export type { VisionDescribeOptions } from './cognition';
export type { VisionDescribeRequest } from './cognition';
export type { VisionDescription } from './cognition';
export * from './comms';
export * from './dataset';
export * from './forge';
export * from './genome';
export * from './events';
// forge: explicit exports (has duplicate types)
export type { AlloyHardware } from './forge';
export type { AlloySource } from './forge';
export type { BenchmarkDef } from './forge';
export type { CorpusRef } from './forge';
export type { ForgeArtifact } from './forge';
export type { ForgeRecipe } from './forge';
export type { HardwareProfile } from './forge';
export type { PriorBaseline } from './forge';
export type { QuantTier } from './forge';
// genome: explicit exports (has duplicate types)
export type { AccessDenied } from './genome';
export type { AcquireSource } from './genome';
export type { ArtifactId } from './genome';
export type { ArtifactRef } from './genome';
export type { CandidateArtifact } from './genome';
export type { CapabilityQuery } from './genome';
export type { CompositionHint } from './genome';
export type { CompositionRef } from './genome';
export type { DomainHint } from './genome';
export type { EngramRef } from './genome';
export type { EvictionPolicy } from './genome';
export type { EvictionRecord } from './genome';
export type { FreshnessTarget } from './genome';
export type { LoRALayerRef } from './genome';
export type { MoEExpertRef } from './genome';
export type { OutcomeWindow } from './genome';
export type { PageFault } from './genome';
export type { PageHandle } from './genome';
export type { PageKind } from './genome';
export type { PageOffset } from './genome';
export type { PageRef } from './genome';
export type { PeerId } from './genome';
export type { PersonaId } from './genome';
export type { Provenance } from './genome';
export type { RankedPool } from './genome';
export type { RecallBudget } from './genome';
export type { RecallContext } from './genome';
export type { RecallError } from './genome';
export type { RecallScope } from './genome';
export type { RecallScore } from './genome';
export type { RecallScoreWeights } from './genome';
export type { RecallTrace } from './genome';
export type { ResidencyHint } from './genome';
export type { ResidentPage } from './genome';
export type { TaskKind } from './genome';
export type { TierCapacity } from './genome';
export type { TierError } from './genome';
export type { TierRole } from './genome';
export type { TrajectoryHint } from './genome';
export type { TrustClass } from './genome';
export type { WorkingSet } from './genome';
export type { WorkingSetCapacity } from './genome';
// governor: explicit exports (has duplicate types)
export type { CadenceMultipliers } from './governor';
export type { CascadeAction } from './governor';
export type { CascadeThresholds } from './governor';
export type { ConcurrencyCaps } from './governor';
export type { ConsolidationSchedule } from './governor';
export type { FederationCadence } from './governor';
export type { GovernorPolicy } from './governor';
export type { GovernorSnapshot } from './governor';
export type { HardwareClass } from './governor';
export type { PowerSource } from './governor';
export type { PressureSignal } from './governor';
export type { SpeculationLevel } from './governor';
export type { ThermalClass } from './governor';
export type { ThermalSeverity } from './governor';
export type { TierSizes } from './governor';
export * from './gpu';
export * from './grid';
// grid: explicit exports (has duplicate types)
export type { GridNode } from './grid';
export type { NodeCapability } from './grid';
export type { TransportAddress } from './grid';
export type { TrustLevel } from './grid';
export * from './inference';
// inference_capability: explicit exports (has duplicate types)
export type { BackendChoice } from './inference_capability';
export type { BlockReason } from './inference_capability';
export type { InferenceCapability } from './inference_capability';
export type { InferenceKind } from './inference_capability';
export type { LatencyClass } from './inference_capability';
export type { QwenModelMetadata } from './inference_capability';
export type { ResidencyEvidence } from './inference_capability';
export type { ResidencyGateResult } from './inference_capability';
// inference_llm: explicit exports (has duplicate types)
export type { CompositionPlan } from './inference_llm';
export type { FirstTokenEmitted } from './inference_llm';
export type { GenerationBudget } from './inference_llm';
export type { InferenceComplete } from './inference_llm';
export type { InferenceRequest } from './inference_llm';
export type { InferenceRequestId } from './inference_llm';
export type { ResidencyFault } from './inference_llm';
export type { SamplingParams } from './inference_llm';
export * from './ipc';
export * from './live';
export * from './logger';
Expand Down
4 changes: 2 additions & 2 deletions src/shared/generated/inference_capability/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Auto-generated barrel export — do not edit manually
// Source: workers/continuum-core/src/inference_capability/types.rs (ts-rs)
// Re-generate: cargo test --lib --features metal,accelerate inference_capability::
// Source: generator/generate-rust-bindings.ts
// Re-generate: npx tsx generator/generate-rust-bindings.ts

export type { BackendChoice } from './BackendChoice';
export type { BlockReason } from './BlockReason';
Expand Down
38 changes: 37 additions & 1 deletion src/system/core/shared/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import { RouterRegistry } from './RouterRegistry';
import { BaseEntity } from '../../data/entities/BaseEntity';
import { ElegantSubscriptionParser, type SubscriptionFilter } from '../../events/shared/ElegantSubscriptionParser';
import { jtagWindow, jtagGlobal } from '../types/GlobalAugmentations';
// L1-1: event-class registry — hot-path sync peek for transport hints.
// Async warm-up is delegated so the first emit on an undeclared class
// doesn't block the emit; the next emit benefits from the warm cache.
import { peekEventClassCache, getEventClass } from '../../events/shared/EventClass';

// Verbose logging helper (works in both browser and server)
const verbose = () => {
Expand Down Expand Up @@ -168,6 +172,26 @@ export class Events {
}
}

// L1-1: consult the event-class registry. Sync peek only — the hot
// emit path can't afford an IPC round-trip per call. If the class
// is declared and cached, attach the hints to the payload so
// downstream transports (L1-2 AircEventTransport) can route it.
// If the cache is cold, kick off a fire-and-forget warm-up; the
// NEXT emit benefits. If the class is undeclared, no hints attached
// and behavior is identical to pre-L1-1 (local + WebSocket only).
const cachedClass = peekEventClassCache(eventName);
if (cachedClass === undefined) {
// Fire-and-forget warm-up. We deliberately do NOT await — the
// current emit goes through with no hints; subsequent emits hit
// the warm cache. Errors are surfaced (NOT swallowed) so a broken
// IPC manifests as a visible warning rather than mysteriously-missing
// routing hints.
getEventClass(eventName).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[Events] EventClass lookup failed for '${eventName}': ${msg}`);
});
}

// Router found - use full EventBridge routing
// Create event payload
const eventPayload: EventBridgePayload = {
Expand All @@ -183,7 +207,19 @@ export class Events {
data: eventData as Record<string, unknown>,
originSessionId: options.sessionId ?? context.uuid,
originContextUUID: context.uuid,
timestamp: new Date().toISOString()
timestamp: new Date().toISOString(),
...(cachedClass
? {
eventClass: {
name: cachedClass.name,
broadcast: cachedClass.broadcast,
channel: cachedClass.channel,
schemaVersion: cachedClass.schemaVersion,
onUnknownSchema: cachedClass.onUnknownSchema,
description: cachedClass.description,
},
}
: {}),
};

// Create event message
Expand Down
17 changes: 16 additions & 1 deletion src/system/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,19 @@
*/

export { SYSTEM_EVENTS, type SystemEventData, type SystemEventName } from './shared/SystemEvents';
export { EventManager, type EventsInterface } from './shared/JTAGEventSystem';
export { EventManager, type EventsInterface } from './shared/JTAGEventSystem';

// L1-1: Event-class declaration registry (Rust-truth, TS-cached).
// See docs/grid/GRID-MIGRATION-ROADMAP.md, GRID-BUS-ARCHITECTURE §2.2.
export {
declareEventClass,
getEventClass,
peekEventClassCache,
listEventClasses,
resolveEventChannel,
_resetEventClassCacheForTests,
type EventClassConfig,
type EventClassChannelStrategy,
type EventClassUnknownSchemaPolicy,
type ResolvedEventClassConfig,
} from './shared/EventClass';
Loading
Loading