Skip to content

test(core): reproduce hot reload regressions - #37427

Closed
kitlangton wants to merge 2 commits into
v2from
test/hot-reload-regressions
Closed

kitlangton wants to merge 2 commits into
v2from
test/hot-reload-regressions

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds deterministic red tests for two V2 hot-reload blockers:

This is intentionally a draft, red-test PR. It establishes the contracts and keeps the failures visible while fixes are developed separately.

Before / After

Before

A domain rebuild calls its State.finalize callback, the callback publishes *.updated, and only afterward does State assign the rebuilt snapshot. A client reacting to the event can immediately refetch the previous agent, command, skill-source, or provider/model catalog.

A fresh process importing the public skill module can enter skill -> permission -> session -> skill; Session.SkillNotFoundError eagerly reads SkillV2.ID while that binding is still uninitialized.

A watcher update for .opencode/commands/review.md rediscovers the same Config entry list, so Config.reload returns before publishing config.updated; config-backed plugins never rescan the changed file.

After this test PR

The required behavior is executable and currently red:

  • every observed update event must imply that the corresponding read API exposes the new snapshot
  • every public Core module must be safe to import first in a fresh process

How

  • packages/core/test/agent.test.ts reads the registered agent immediately after agent.updated.
  • packages/core/test/command.test.ts reads the registered command immediately after command.updated.
  • packages/core/test/skill.test.ts reads registered skill sources immediately after skill.updated.
  • packages/core/test/catalog.test.ts reads the provider immediately after catalog.updated.
  • packages/core/test/config/config.test.ts publishes a watcher update for a file inside a Config directory and waits for config.updated.
  • packages/core/test/public-import.test.ts imports @opencode-ai/core/skill in a fresh Bun process so module caching cannot hide the cycle.
sequenceDiagram
    participant State
    participant Events
    participant Client
    participant API

    State->>State: build next snapshot
    State->>Events: publish *.updated
    Events->>Client: invalidate catalog
    Client->>API: list immediately
    API-->>Client: previous snapshot
    State->>State: assign next snapshot
Loading

Scope

This PR does not fix either failure and is not merge-ready while the tests are red.

Missing but non-regressed hot-reload surfaces are tracked separately:

Testing

Expected red tests:

bun run --cwd packages/core test test/agent.test.ts --test-name-pattern "after agent changes are visible"
bun run --cwd packages/core test test/catalog.test.ts --test-name-pattern "after catalog changes are visible"
bun run --cwd packages/core test test/command.test.ts --test-name-pattern "after command changes are visible"
bun run --cwd packages/core test test/skill.test.ts --test-name-pattern "after skill source changes are visible"
bun run --cwd packages/core test test/config/config.test.ts --test-name-pattern "changed files inside config directories"
bun run --cwd packages/core test test/public-import.test.ts

The first four observe the previous snapshot. The Config test times out waiting for config.updated. The public-import test observes ReferenceError: Cannot access 'ID' before initialization.

Passing validation:

bun turbo typecheck --concurrency=3
bunx prettier --check packages/core/test/agent.test.ts packages/core/test/catalog.test.ts packages/core/test/command.test.ts packages/core/test/skill.test.ts packages/core/test/config/config.test.ts packages/core/test/public-import.test.ts
git diff --check

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant