Skip to content

refactor(spider-storage)!: Rename the ready queue to the inbound queue for consistency with the storage gRPC API and spider-scheduler. - #435

Merged
LinZhihao-723 merged 8 commits into
y-scope:mainfrom
LinZhihao-723:inbound-queue-rename
Aug 11, 2026
Merged

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Aug 10, 2026

Copy link
Copy Markdown
Member

Description

This PR depends on #434.

spider-storage calls its inbound task queue the "ready queue", but every other layer already calls the same thing the "inbound queue": the proto declares service InboundQueueService, spider-scheduler names its half InboundEntry / AsyncInboundQueueReader, and spider-storage itself already has GrpcServiceState::inbound_queue_service_error_handler and a SERVICE_NAME = "InboundQueue" constant sitting a few hundred lines from the ready_queue module. The module is out of sync with the API it implements, and the two vocabularies collide inside single files.

This PR moves storage onto the inbound-queue vocabulary. The governing rule: Inbound* names the queue, its handles, its config, and its module; ready survives only as a lane qualifier and as a job/task state word.

Before After
src/ready_queue.rs src/inbound_queue.rs
ReadyQueueEntry InboundQueueEntry
ReadyQueueConfig InboundQueueConfig
ReadyQueueSender InboundQueueSender
ReadyQueueSenderType InboundQueueSenderType
ReadyQueueSenderHandle InboundQueueSenderHandle
ReadyQueueReceiverHandle InboundQueueReceiverHandle
create_ready_queue create_inbound_queue
ready_queue_sender / ready_queue_receiver inbound_queue_sender / inbound_queue_receiver
InternalError::ReadyQueueInvalidConfig InternalError::InboundQueueInvalidConfig
InternalError::ReadyQueueChannelClosed InternalError::InboundQueueChannelClosed
MockReadyQueueSender, TrackingReadyQueueSender, ReadyMessage MockInboundQueueSender, TrackingInboundQueueSender, InboundMessage
RuntimeConfig::ready_queue RuntimeConfig::inbound_queue

What deliberately does not change

These were considered and kept, so please read them as decisions rather than as misses:

  • Anything on the wire. PollReadyTasks, PollReadyCommitTasks, PollReadyCleanupTasks, ReadyTasks, ReadyTask, and the JobState enum values are unchanged. As a consequence GrpcServiceState's method names stay poll_ready_tasks / poll_ready_commit_tasks / poll_ready_cleanup_tasks, because they are fixed by codegen.
  • State words, not queue words. JobState::{Ready, CommitReady, CleanupReady} and everything derived from them (ensure_/read_/write_commit_ready, recover_from_commit_ready, StaleStateError::JobNoLonger*Ready, the MariaDB state strings), plus TaskState::Ready filtering in get_all_ready_task_indices and ready_task_indices. These name a state, not the queue.
  • Event names. send_task_ready, send_commit_ready, send_cleanup_ready name the event "a task became ready", not the queue it lands in.
  • resend_ready_tasks, build_ready_tasks, ServiceState::poll_*_ready_tasks — these track the RPCs and the tasks, both of which keep their names.
  • Lane names. task_capacity / commit_capacity / cleanup_capacity, recv_tasks / recv_commits / recv_cleanups, and CommitTaskMarker / CleanupTaskMarker are already lane-scoped and carry no ready token.
  • spider-scheduler's RoundRobinConfig keys (ready_task_capacity, commit_ready_task_capacity, cleanup_ready_task_capacity) are a separate config surface and are untouched. Note that values.yaml holds both vocabularies about twenty lines apart, so this is easy to get wrong.

Log messages and comments that describe ready tasks or the PollReadyTasks RPC were also left alone, so that the prose keeps agreeing with the identifiers it describes. Only prose naming the queue was rewritten.

Configuration migration

runtime.ready_queue becomes runtime.inbound_queue in storage.yaml. The Helm chart is updated in lockstep and its version is bumped:

runtime:
  inbound_queue:
    cleanup_capacity: 256
    commit_capacity: 256
    task_capacity: 1048576

Operators with a hand-written storage config, or with a custom Helm values override that sets spiderConfig.storage.runtime.ready_queue, must rename the key. A stale key fails silently: RuntimeConfig does not use deny_unknown_fields, so the old block is dropped without an error or a log line and all three lanes fall back to their defaults of 65536 / 1024 / 1024, against the chart's 1048576 / 256 / 256. No compatibility alias is provided; this is a deliberate clean break, and it is the main thing to call out in the release notes.

Note for reviewers

There is one change that is not a pure rename. InboundQueueSender is two characters longer than ReadyQueueSender, which pushes two test-helper return types past 100 columns, and .rustfmt.toml sets error_on_line_overflow = true while rustfmt will not wrap a return-position generic. A private type TestJcb = SharedJobControlBlock<...> was therefore added inside the #[cfg(test)] modules of state/job_cache.rs and state/service.rs, mirroring the alias that already exists in tests/scheduling_infra.rs.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Ensure all workflows pass.

Summary by CodeRabbit

  • New Features

    • Introduced inbound-queue terminology and configuration across scheduling, storage, task processing, and recovery workflows.
    • Added configurable job-cache cleanup and task-instance-pool settings.
    • Added execution-manager registry settings for scheduler runtime configuration.
  • Improvements

    • Reduced execution-manager heartbeat intervals for faster liveness detection.
    • Adjusted queue capacities to improve runtime resource management.
    • Updated deployment chart metadata and configuration defaults.

@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners August 10, 2026 19:09
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc134a6d-8500-40e3-a9f5-5048f03ff32d

📥 Commits

Reviewing files that changed from the base of the PR and between a9ad42f and 4cb97ac.

📒 Files selected for processing (2)
  • components/spider-storage/src/inbound_queue.rs
  • components/spider-storage/tests/scheduling_infra.rs
💤 Files with no reviewable changes (1)
  • components/spider-storage/tests/scheduling_infra.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/spider-storage/src/inbound_queue.rs

Walkthrough

The change renames the storage ready-queue API to an inbound-queue API. It propagates the new types through runtime, service, job, task-pool, gRPC, recovery tests, scheduling tests, and Helm configuration.

Changes

Inbound Queue Migration

Layer / File(s) Summary
Inbound queue contract and public API
components/spider-storage/src/inbound_queue.rs, components/spider-storage/src/cache/error.rs, components/spider-storage/src/lib.rs, components/spider-scheduler/src/lib.rs
The queue types, factory, configuration, receiver methods, errors, public module, and scheduler documentation now use inbound-queue terminology.
Runtime and service-state wiring
components/spider-storage/src/state/runtime.rs, components/spider-storage/src/state/service.rs, components/spider-storage/src/state/test_utils.rs
Runtime configuration, queue creation, recovery, service state, polling methods, fixtures, and mocks now use inbound-queue senders, receivers, and entries.
Job execution and cache propagation
components/spider-storage/src/cache/job.rs, components/spider-storage/src/state/job_cache.rs, components/spider-storage/src/state/job_cache_gc.rs
Job control blocks, execution state, task scheduling, retries, completion, cancellation, job cache, and cache-GC now propagate inbound-queue sender types.
Task pool and gRPC integration
components/spider-storage/src/task_instance_pool.rs, components/spider-storage/src/grpc.rs
Task re-enqueue operations and gRPC service implementations now use inbound-queue senders and entries.
Scheduling and recovery validation
components/spider-storage/tests/runtime_recovery_test.rs, components/spider-storage/tests/scheduling_infra.rs
Recovery and scheduling tests now construct, dispatch, poll, filter, and assert inbound-queue messages and entries.
Helm runtime configuration
tools/deployment/spider-helm/Chart.yaml, tools/deployment/spider-helm/values.yaml
The chart version, heartbeat intervals, queue capacities, registry settings, inbound-queue configuration, cache-GC settings, and task-instance-pool settings are updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • y-scope/spider#340: Adds the inbound-queue gRPC protocol and scheduler storage client changes aligned with this API migration.
  • y-scope/spider#364: Updates components/spider-storage/src/grpc.rs with inbound-queue service types.
  • y-scope/spider#432: Changes Helm queue and heartbeat configuration in the same deployment files.

Suggested reviewers: sitaowang1998

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: renaming the ready queue to the inbound queue in spider-storage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/spider-storage/src/state/runtime.rs`:
- Around line 31-39: Add #[serde(deny_unknown_fields)] to RuntimeConfig so
obsolete runtime.ready_queue entries are rejected instead of silently ignored,
while preserving defaults for supported fields. Add a deserialization test
covering a YAML configuration containing the stale ready_queue key and assert
that parsing fails.

In `@components/spider-storage/tests/runtime_recovery_test.rs`:
- Around line 356-361: Update all six ServiceState test helpers in
components/spider-storage/tests/runtime_recovery_test.rs at ranges 356-361,
383-388, 418-423, 456-461, 493-498, and 530-535 by adding + 'static bounds to
each of their three generic parameters: InboundQueueSenderType, DbConnectorType,
and TaskInstancePoolConnectorType.

In `@tools/deployment/spider-helm/values.yaml`:
- Around line 78-81: Update the Helm values migration handling for the inbound
queue configuration so an existing previous ready-queue key is explicitly mapped
to inbound_queue, or template rendering fails with an actionable migration
message instead of silently using defaults. Document the required values-file
key update alongside the inbound_queue settings.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 70e6d18d-dd5d-4d82-ab62-d7c8c63de84e

📥 Commits

Reviewing files that changed from the base of the PR and between 00037af and a9ad42f.

📒 Files selected for processing (17)
  • components/spider-scheduler/src/lib.rs
  • components/spider-storage/src/cache/error.rs
  • components/spider-storage/src/cache/job.rs
  • components/spider-storage/src/grpc.rs
  • components/spider-storage/src/inbound_queue.rs
  • components/spider-storage/src/lib.rs
  • components/spider-storage/src/state/job_cache.rs
  • components/spider-storage/src/state/job_cache_gc.rs
  • components/spider-storage/src/state/runtime.rs
  • components/spider-storage/src/state/service.rs
  • components/spider-storage/src/state/test_utils.rs
  • components/spider-storage/src/task_instance_pool.rs
  • components/spider-storage/tests/runtime_recovery_test.rs
  • components/spider-storage/tests/scheduling_infra.rs
  • tools/deployment/spider-helm/Chart.yaml
  • tools/deployment/spider-helm/templates/configmap.yaml
  • tools/deployment/spider-helm/values.yaml

Comment on lines 31 to 39
pub struct RuntimeConfig {
pub db_config: DatabaseConfig,
pub db: DatabaseConfig,
#[serde(default)]
pub ready_queue_config: ReadyQueueConfig,
pub inbound_queue: InboundQueueConfig,
#[serde(default)]
pub task_instance_pool_config: TaskInstancePoolConfig,
pub task_instance_pool: TaskInstancePoolConfig,
#[serde(default)]
pub job_cache_gc_config: JobCacheGcConfig,
pub job_cache_gc: JobCacheGcConfig,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- candidate files ---'
fd -t f -e rs | rg '(^|/)(runtime|config|.*state.*)\.rs$' | head -80

printf '%s\n' '--- RuntimeConfig and queue references ---'
rg -n -C 5 'RuntimeConfig|ready_queue|inbound_queue|deny_unknown_fields|serde\(default\)' components/spider-storage/src components -g '*.rs' | head -300

printf '%s\n' '--- target file outline and relevant source ---'
ast-grep outline components/spider-storage/src/state/runtime.rs
wc -l components/spider-storage/src/state/runtime.rs
sed -n '1,180p' components/spider-storage/src/state/runtime.rs

Repository: y-scope/spider

Length of output: 31548


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- configuration deserialization and loading ---'
rg -n -C 6 'from_(str|slice|reader)|deserialize|ServerConfig|RuntimeConfig|config::|Figment|serde_yaml|toml|deny_unknown_fields|unknown field' . \
  -g '*.rs' -g '*.toml' -g '*.yaml' -g '*.yml' -g '*.json' -g '*.md' | head -500

printf '%s\n' '--- legacy and current configuration names ---'
rg -n -C 4 'ready_queue|inbound_queue' . \
  -g '!target' -g '!node_modules' | head -400

printf '%s\n' '--- storage manifests and test sections ---'
sed -n '1,220p' components/spider-storage/Cargo.toml
sed -n '240,375p' components/spider-storage/src/state/runtime.rs

Repository: y-scope/spider

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
for p in Path('.').rglob('*.rs'):
    text = p.read_text(errors='ignore')
    if 'ServerConfig' in text or 'RuntimeConfig' in text:
        print(p)
PY

Repository: y-scope/spider

Length of output: 706


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- YAML configuration wrapper ---'
cat -n components/spider-utils/src/config.rs

printf '%s\n' '--- dependency declarations ---'
rg -n -C 3 'yaml_serde|serde\s*=|serde_yaml' Cargo.toml Cargo.lock components -g 'Cargo.toml' -g 'Cargo.lock'

printf '%s\n' '--- storage configuration and public exports ---'
cat -n components/spider-storage/src/config.rs | sed -n '1,180p'
cat -n components/spider-storage/src/lib.rs | sed -n '1,80p'
cat -n components/spider-storage/src/bin/grpc_server.rs | sed -n '30,55p'

printf '%s\n' '--- all exact legacy-key occurrences ---'
rg -n --fixed-strings 'ready_queue' . -g '!target' -g '!node_modules' || true

Repository: y-scope/spider

Length of output: 18023


🌐 Web query:

Serde Rust derive deny_unknown_fields unknown fields default ignored documentation

💡 Result:

In Serde, unknown fields are ignored by default when deserializing from self-describing formats such as JSON [1][2][3]. The #[serde(deny_unknown_fields)] container attribute can be added to a struct or enum to change this behavior [1][4]. When this attribute is present, Serde will return an error during deserialization if it encounters any fields that do not match the fields defined in your Rust data structure [1][2]. Important considerations: - Compatibility: This attribute is not supported in combination with the #[serde(flatten)] attribute, either on the container or on the flattened field [1][2][5]. - Scope: This behavior is primarily relevant for self-describing formats (like JSON). For non-self-describing formats (like Bincode), behavior may vary depending on the format's constraints [6].

Citations:


🌐 Web query:

yaml_serde Rust serde deny_unknown_fields unknown fields documentation

💡 Result:

In Rust, the #[serde(deny_unknown_fields)] attribute is a container-level attribute used to control deserialization behavior [1][2]. By default, Serde ignores extra fields in self-describing formats like YAML, which can lead to silent errors if a user makes a typo in a configuration file [1][3]. Applying #[serde(deny_unknown_fields)] to a struct or enum forces the deserializer to return an error if it encounters any fields not explicitly defined in the Rust data structure [1][4]. This is highly effective for catching configuration errors or typos [3][5]. Usage example: rust use serde::Deserialize; #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] struct Config { host: String, port: u16, } Important considerations: 1. Compatibility: This attribute is not supported in combination with #[serde(flatten)], whether on the outer struct or a flattened field [1][6]. 2. Scope: It is a container attribute, meaning it must be placed directly above the struct or enum declaration, not on individual fields [2]. 3. Error Handling: When a field is unrecognized, the deserialization process will fail, and the library being used (such as serde_yaml) will return an error detailing the unknown field and the expected ones [3][7]. While the query mentioned yaml_serde, please note that serde provides these attributes natively, and they are utilized by serde_yaml or other format-specific crates to enforce schema strictness [3][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
from pathlib import Path
import re

runtime = Path("components/spider-storage/src/state/runtime.rs").read_text()
utils = Path("components/spider-utils/src/config.rs").read_text()
server = Path("components/spider-storage/src/bin/grpc_server.rs").read_text()

struct = re.search(
    r"pub struct RuntimeConfig\s*\{(?P<body>.*?)\n\}",
    runtime,
    re.S,
)
assert struct, "RuntimeConfig was not found"
body = struct.group("body")

for field in ("db", "inbound_queue", "task_instance_pool", "job_cache_gc"):
    assert re.search(rf"\bpub\s+{field}\s*:", body), f"missing field: {field}"

assert "ready_queue" not in runtime, "unexpected legacy field or migration in RuntimeConfig"
assert "#[serde(deny_unknown_fields)]" not in runtime, "strict unknown-field handling already exists"
assert "yaml_serde::from_reader" in utils, "YAML loader does not use yaml_serde::from_reader"
assert "ServerConfig::from_yaml_file" in server, "storage entry point does not use ServerConfig::from_yaml_file"

print("RuntimeConfig accepts only inbound_queue as the queue field at the Rust schema level.")
print("The YAML entry point uses yaml_serde::from_reader without a RuntimeConfig unknown-field policy.")
print("No ready_queue migration or alias exists.")
print("A stale runtime.ready_queue key therefore cannot configure inbound_queue.")
PY

Repository: y-scope/spider

Length of output: 450


Reject obsolete queue configuration.

ServerConfig::from_yaml_file uses yaml_serde::from_reader, and RuntimeConfig does not deny unknown fields. If a YAML file contains only runtime.ready_queue, Serde ignores it and inbound_queue uses its default capacities. Add #[serde(deny_unknown_fields)] or implement an explicit migration. Add a deserialization test for the stale key.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/spider-storage/src/state/runtime.rs` around lines 31 - 39, Add
#[serde(deny_unknown_fields)] to RuntimeConfig so obsolete runtime.ready_queue
entries are rejected instead of silently ignored, while preserving defaults for
supported fields. Add a deserialization test covering a YAML configuration
containing the stale ready_queue key and assert that parsing fails.

Comment on lines 356 to +361
async fn register_and_start_job<
ReadyQueueSenderType: spider_storage::ready_queue::ReadyQueueSender,
InboundQueueSenderType: spider_storage::inbound_queue::InboundQueueSender,
DbConnectorType: spider_storage::db::DbStorage,
TaskInstancePoolConnectorType: spider_storage::task_instance_pool::TaskInstancePoolConnector,
>(
service: &ServiceState<ReadyQueueSenderType, DbConnectorType, TaskInstancePoolConnectorType>,
service: &ServiceState<InboundQueueSenderType, DbConnectorType, TaskInstancePoolConnectorType>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 \
  'InboundQueueSenderType: InboundQueueSender \+ '\''static|DbConnectorType: DbStorage \+ '\''static|TaskInstancePoolConnectorType: TaskInstancePoolConnector \+ '\''static' \
  components/spider-storage/src/state/service.rs

rg -n -C 3 \
  'async fn (register_and_start_job|register_job|run_recovered_regular_task|run_single_task_job_to_succeed|assert_regular_task_registration_rejected|assert_job_outputs_on_success)' \
  components/spider-storage/tests/runtime_recovery_test.rs

Repository: y-scope/spider

Length of output: 5072


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '330,555p' components/spider-storage/tests/runtime_recovery_test.rs
printf '\n--- ServiceState declarations and impl bounds ---\n'
sed -n '35,100p' components/spider-storage/src/state/service.rs
printf '\n--- Test generic helper call sites ---\n'
rg -n -C 3 \
  'register_and_start_job|register_job|run_recovered_regular_task|run_single_task_job_to_succeed|assert_regular_task_registration_rejected|assert_job_outputs_on_success' \
  components/spider-storage/tests/runtime_recovery_test.rs

Repository: y-scope/spider

Length of output: 19654


🏁 Script executed:

#!/bin/bash
set -euo pipefail

if ! command -v rustc >/dev/null 2>&1; then
  printf '%s\n' 'rustc unavailable'
  exit 0
fi

tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT

cat >"$tmpdir/missing_bounds.rs" <<'RS'
trait InboundQueueSender {}
trait DbStorage {}
trait TaskInstancePoolConnector {}

struct ServiceState<A: InboundQueueSender + 'static, B: DbStorage + 'static, C: TaskInstancePoolConnector + 'static>(
    std::marker::PhantomData<(A, B, C)>,
);

async fn helper<A: InboundQueueSender, B: DbStorage, C: TaskInstancePoolConnector>(
    service: &ServiceState<A, B, C>,
) {
    let _ = service;
}
RS

cat >"$tmpdir/with_bounds.rs" <<'RS'
trait InboundQueueSender {}
trait DbStorage {}
trait TaskInstancePoolConnector {}

struct ServiceState<A: InboundQueueSender + 'static, B: DbStorage + 'static, C: TaskInstancePoolConnector + 'static>(
    std::marker::PhantomData<(A, B, C)>,
);

async fn helper<
    A: InboundQueueSender + 'static,
    B: DbStorage + 'static,
    C: TaskInstancePoolConnector + 'static,
>(
    service: &ServiceState<A, B, C>,
) {
    let _ = service;
}
RS

printf '%s\n' '--- helper without lifetime bounds ---'
if rustc --edition=2021 --crate-type=lib "$tmpdir/missing_bounds.rs" -o "$tmpdir/missing_bounds.rlib" 2>&1; then
  printf '%s\n' 'unexpectedly compiled'
else
  printf '%s\n' 'failed as expected'
fi

printf '%s\n' '--- helper with lifetime bounds ---'
rustc --edition=2021 --crate-type=lib "$tmpdir/with_bounds.rs" -o "$tmpdir/with_bounds.rlib"
printf '%s\n' 'compiled'

Repository: y-scope/spider

Length of output: 740


🌐 Web query:

Rust reference generic bounds well-formedness struct type parameter bounds function signature

💡 Result:

In Rust, generic bounds specify requirements for type parameters, lifetime parameters, and constants, ensuring that generic items (like structs, functions, or traits) can safely operate on the types provided [1][2][3]. Well-formedness (WF) is a compiler process that validates whether a type or item is constructed in a way that respects its defined bounds and lifetime relationships [4][5][6]. Core Concepts: 1. Generic Bounds: - Trait Bounds: Constrain a type parameter to implement a specific trait, enabling the use of methods, associated types, or constants defined by that trait [1][7][3]. Syntax includes short-form (e.g., <T: Trait>) or where clauses for more complex constraints [1][2][3]. - Lifetime Bounds: Define relationships between lifetimes (e.g., 'a: 'b means 'a outlives 'b) or ensure a type contains no references shorter than a specific lifetime (e.g., T: 'a) [1][4]. 2. Well-Formedness (WF) Checking: - The compiler performs WF checks to ensure that all bounds are satisfied [5][6]. When you define a struct or function, the compiler verifies that the types used within the signature are internally consistent [4]. - For example, if a struct field is &'a T, the compiler implicitly requires that T: 'a (i.e., T outlives 'a) for the struct to be well-formed [1][4]. If this requirement is not met or cannot be inferred, the compiler will demand an explicit bound [1][4]. 3. Function Signatures and Structs: - Struct Definitions: Bounds can be placed directly on the struct's type parameters in the angle brackets or via a where clause [2][3]. When a struct is instantiated, all bounds must hold [1]. - Function Signatures: Similar to structs, functions can impose bounds on their generic parameters [7]. WF checking at the function level ensures that the arguments provided to the function satisfy the declared requirements, allowing the function body to safely utilize the properties guaranteed by those bounds [1][4]. The Rust compiler often infers necessary lifetime bounds, but explicit bounds are required when the compiler cannot determine the necessary constraints from the type definition or signature alone [1][4]. Modern Rust development also utilizes WF obligations during trait resolution to ensure that associated types and trait implementations remain coherent [6].

Citations:


Add 'static bounds to all six ServiceState test helpers.

ServiceState requires all three generic parameters to be 'static. Without these bounds, the test does not compile. Add + 'static to each generic parameter in the listed helper functions.

📍 Affects 1 file
  • components/spider-storage/tests/runtime_recovery_test.rs#L356-L361 (this comment)
  • components/spider-storage/tests/runtime_recovery_test.rs#L383-L388
  • components/spider-storage/tests/runtime_recovery_test.rs#L418-L423
  • components/spider-storage/tests/runtime_recovery_test.rs#L456-L461
  • components/spider-storage/tests/runtime_recovery_test.rs#L493-L498
  • components/spider-storage/tests/runtime_recovery_test.rs#L530-L535
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/spider-storage/tests/runtime_recovery_test.rs` around lines 356 -
361, Update all six ServiceState test helpers in
components/spider-storage/tests/runtime_recovery_test.rs at ranges 356-361,
383-388, 418-423, 456-461, 493-498, and 530-535 by adding + 'static bounds to
each of their three generic parameters: InboundQueueSenderType, DbConnectorType,
and TaskInstancePoolConnectorType.

Comment on lines +78 to 81
inbound_queue:
cleanup_capacity: 256
commit_capacity: 256
task_capacity: 1048576

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Prevent silent fallback during Helm upgrades.

When an existing values file still contains the previous ready-queue key, this chart does not map it to inbound_queue. The storage runtime then uses the default queue configuration, so queue capacity and backpressure behaviour can change without a Helm error.

Add a compatibility mapping, or fail template rendering with an actionable migration message. Document the required values-file update.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/deployment/spider-helm/values.yaml` around lines 78 - 81, Update the
Helm values migration handling for the inbound queue configuration so an
existing previous ready-queue key is explicitly mapped to inbound_queue, or
template rendering fails with an actionable migration message instead of
silently using defaults. Document the required values-file key update alongside
the inbound_queue settings.

sitaowang1998
sitaowang1998 previously approved these changes Aug 10, 2026
@LinZhihao-723
LinZhihao-723 merged commit 18d2bcf into y-scope:main Aug 11, 2026
18 checks passed
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.

2 participants