Skip to content

Bound sync and VM resource configuration - #2500

Open
branarakic wants to merge 14 commits into
testnet-canaryfrom
fix/issue-2058-numeric-resource-bounds
Open

Bound sync and VM resource configuration#2500
branarakic wants to merge 14 commits into
testnet-canaryfrom
fix/issue-2058-numeric-resource-bounds

Conversation

@branarakic

@branarakic branarakic commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Unsafe or non-finite sync/VM settings could create unbounded queues, concurrency and retry windows, or turn an oversized timer into a rapid loop. Apply shared safe-integer bounds, environment → config → default precedence, and unchanged explicit zero modes. Malformed containers and contradictory partition allocations still fail validation.

Construction resolves one immutable startup policy before wallet/store allocation. Startup diagnostics and execution use that policy; resolved agent config omits consumed raw admission, snapshot and reconciler inputs through a typed key definition shared by runtime projection, the declared type and the startup assertion. The input object is not mutated. Public snapshot and catch-up helpers retain their mutable return contracts and existing callbacks; only the private startup copy is frozen.

Admission resolution is pure. The process-wide queue derives W1 capacity from its queued/running entries: matching policies report exact ceilings; mixed policies or an idle queue report unknown ceilings. Creating another agent, including failed construction, cannot overwrite active capacity. Existing per-entry admission limits and process-global sharing remain unchanged. RFC-64 boot scopes are projected once per agent; live Edge subscriptions contribute compact reservation booleans. The standalone configured-scope resolver remains compatible, including copied policies.

Validation: the latest revision passes 111 resource, real-startup and backpressure tests. The Edge-scope test invokes the real tracking method and replaces the array on removal; it detects a cached-array mutation that the preceding test allowed. Earlier revisions passed 238 tests across nine resource, real-startup, admission, recovery, catch-up, telemetry and coalescing suites. Five targeted regressions fail on the preceding head. They cover mutable catch-up settings, failed second construction, two-agent capacity, pure disabled-policy resolution and interleaved ownership. Package-root runtime and declaration checks cover mutable public settings and canonical internal fields. Agent/CLI builds, lint, test inventory and SPARQL checks pass. Local startup uses NoChain and loopback.

The larger scheduler ownership redesign remains tracked in #2512; this change does not redefine cross-agent admission sharing.

Closes #2058.

Comment thread packages/agent/test/resource-limits.test.ts Outdated
Comment thread packages/agent/src/resource-limits.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/sync/backpressure.ts
Comment thread packages/agent/src/sync/catchup-policy.ts
Comment thread packages/agent/src/dkg-agent.ts Outdated
Comment thread packages/agent/src/resource-policy.ts Outdated
Comment thread packages/agent/src/resource-policy.ts Outdated
Comment thread packages/agent/src/resource-policy.ts Outdated
Comment thread packages/agent/src/sync/catchup-concurrency.ts
Comment thread packages/agent/src/sync/backpressure.ts Outdated
Comment thread packages/agent/src/sync/responder/snapshot-policy.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/sync/responder/snapshot-policy.ts Outdated
Comment thread packages/agent/src/sync/responder/sync-handler.ts
Comment thread packages/agent/test/catchup-concurrency.test.ts
Comment thread packages/agent/src/dkg-agent.ts Outdated
@branarakic
branarakic requested a review from Jurij89 as a code owner September 7, 2026 22:42
Comment thread packages/agent/src/sync/catchup-pass-policy.ts Outdated
Comment thread packages/agent/src/dkg-agent-lifecycle.ts
Comment thread packages/agent/src/dkg-agent-types.ts
Comment thread packages/agent/src/sync/backpressure.ts Outdated
Comment thread packages/agent/test/sync-policy.test.ts
Comment thread packages/agent/src/dkg-agent.ts Outdated
Comment thread packages/agent/test/sync-backpressure.test.ts Outdated
Comment thread docs/agent-resource-limits.md
Comment thread packages/agent/src/dkg-agent-lifecycle.ts Outdated
Comment thread packages/agent/src/sync/priority-admission-queue.ts Outdated
# Conflicts:
#	packages/agent/src/dkg-agent-base.ts
Comment thread packages/agent/src/sync/backpressure.ts Outdated
Comment thread packages/agent/src/sync/priority-admission-queue.ts Outdated
legacyPublicFallback: rfc64PublicCatalogControls.autoPublishPolicy,
acceptedPolicies: rfc64CatalogBootstrap?.acceptedPolicies ?? [],
});
const selectedRecoveryContextGraphIds = resolveRfc64SelectedRecoveryContextGraphIdsV1(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Issue: The RFC-64-to-admission wiring is bypassed by the tests

What's wrong
This new constructor-only integration determines whether selected RFC-64 recovery receives reserved sync capacity, but no test exercises the derivation through DKGAgent.create. The existing admission test starts after the seam by manually injecting the expected selected graph, so it would remain green if the constructor stopped deriving the graph or filtered it incorrectly.

Example
Create a real agent with an eligible RFC-64 policy and complete SWM provider, without manually setting selectedRecoveryContextGraphIds. Assert that its resolved admission policy contains the selected graph and that saturated unrelated background recovery cannot consume its reserved slot. Also cover an ineligible execution plan or missing complete provider.

Suggested direction
Add a constructor-level regression test that derives the reservation from RFC-64 inputs and verifies both eligible and excluded scopes.

For Agents
Add coverage near resource-limits-startup.test.ts or the RFC-64 agent integration tests. Exercise DKGAgent.create with actual RFC-64 bootstrap inputs, preserve the legacy-execution-plan filtering semantics, and prove that the resulting resourcePolicy.admission drives selected-scope reservation without directly injecting selectedRecoveryContextGraphIds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants