Skip to content

first working beta version - #4

Merged
ataibarkai merged 37 commits into
mainfrom
atai/0714/demogif
Jul 19, 2023
Merged

ataibarkai merged 37 commits into
mainfrom
atai/0714/demogif

Conversation

@ataibarkai

Copy link
Copy Markdown
Contributor

No description provided.

yungscotia pushed a commit to yungscotia/cia-platform-copilotkit that referenced this pull request Jun 6, 2025
johnprg pushed a commit that referenced this pull request Dec 23, 2025
[Docs] Sidebar (Light+Dark mode)
jpr5 added a commit that referenced this pull request Apr 18, 2026
…ip + isMainPath catch coverage

R17-3 #4: validateAll EACCES test now asserts r.status === 3 strictly. The prior expect([1,3]).toContain defeated the fix it was meant to guard — accepting the pre-fix behavior (1). Restructured the fixture to chmod the parent dir (not the file) so statSync in collectDepsFromDir fails EACCES → infra: true → UnreadableInputError → EXIT_UNREADABLE (3) actually fires. chmod'ing the file routed through readFileSync (not-infra parseError → EXIT_DRIFT), never exercised the fix.

R17-3 #2: parseRequirementsTxt dropped-line test uses '==1.0.0' — an operator-leading line with no package name is GUARANTEED to be dropped by parseRequirementsLine (leading [A-Za-z0-9] required). Replaced the silent early-return guard with an invariant assertion that fails loudly if the fixture ever stops producing a drop.

R17-3 #3: parsePyprojectToml skipped-entry test drops the early-return guard; the Poetry git-only inline table deterministically hits the skipped branch. Added an invariant assertion on detailed.skipped.length.

R17-3 #11: printReport within-stream order tests now compare findLastIndex(earlier-group) vs findIndex(later-group). findIndex-only compared first-match only, which would pass even with interleaving. Fixture includes 2 OK + 2 SKIP (and 2 WARN + 2 FAIL) so the stronger assertion has teeth.

R17-3 #5: EACCES tests' silent `return;` on root replaced with `it.skipIf(isRoot)` at declaration time. The runtime 'filesystem does not enforce chmod' branch now emits a console.warn so the skip is visible in test output rather than a silent green.

R17-3 #6: Added isMainPath catch-branch test. vi.spyOn(path, 'resolve') throws once; asserts result is false, process.exitCode === EXIT_INTERNAL (2), and stderr log contains '[isMainPath] path.resolve failed'. Previously this branch had no coverage — a bare catch {} regression would pass all existing tests.
jpr5 added a commit that referenced this pull request Apr 18, 2026
…use-chain walk, literal-union exit codes

- R19-2 #4: runParity wraps body in try/catch, returns EXIT_INTERNAL instead of re-throwing. In-process callers (tests, composed CLIs) now always get a numeric exit code matching ValidateParityExitCode. Previously auditPackage's wrapped-Error throw could surface as an exception.
- R19-2 #6: formatErrorChain helper walks .cause chain depth-first with visited-ref guard and depth cap; replaces bare err.stack||err.message in both runParity's internal catch and main()'s top-level catch. Root causes no longer lost.
- R19-5 #9: exit code constants marked 'as const'; exported ValidateParityExitCode literal union for type-safe pattern matching.
- Test: new in-process runParity case asserts return value 4 (no throw) and stderr carries outer context + 'caused by:' + root cause.
jpr5 added a commit that referenced this pull request Apr 18, 2026
…rn, not warning-string substring

Previously auditPackage classified provenance anomalies by scanning
warnings[] for the substrings `unreadable-candidates` and `"<slug>"`.
Any reword of the human-readable warning text (typo fix, i18n,
docstring edit) would silently reclassify unreadable-examples as
missing-examples — infrastructure failures would disappear behind a
content-shaped signal.

resolveExamplesSource now returns a structured
ExamplesSourceResult { source, unreadableForSlug }. auditPackage
consumes `unreadableForSlug` directly for classification and the
warning text stays purely human-readable (never parsed).

FX30-C Fix 1 (R29-2 H1 + R29-1 #4).
shaneholloman pushed a commit to shaneholloman/copilotkit that referenced this pull request Apr 21, 2026
…te integration slug; sort-ordered preview selection

- Extract findFrameworksWithCell into @/lib/docs-render so the docs
  catch-all and framework-scoped catch-all share one implementation
  instead of carrying a near-identical local copy in each (finding CopilotKit#3).
- Validate /docs/integrations/<slug> against the registry with
  notFound() when the slug is unknown. Previously a crafted URL like
  /docs/integrations/fake-framework silently fell through to an empty
  nav tree, indistinguishable from a valid integration with no scoped
  content (finding CopilotKit#4).
- Sort integrations by sort_order then slug before picking the
  animated preview URL. Registry iteration order alone isn't
  deterministic w.r.t. the visual priority the docs UI shows
  everywhere else, so the preview now matches (finding CopilotKit#5).
jenningsloy318 pushed a commit to JMaiGC/CopilotKit that referenced this pull request May 8, 2026
…ls-async pills

Adds deterministic fixtures to d5-all.json (loaded before feature-parity.json
so it wins match precedence) for the Phase 1A genuine-pass cells:

- hitl-in-app refund #12345 and escalate #12347 pills: each emits a
  request_user_approval tool call on the first turn, then branches via
  sequenceIndex on the second turn (0 = approve response, 1 = reject
  response). Test ordering (serial mode in the spec) drives which branch
  is claimed first per pill pair.

- frontend-tools-async project-planning, auth, and reading pills: each
  emits a query_notes tool call so the async client-side handler runs
  against NOTES_DB and renders project-planning / auth / reading-tagged
  matches. The reading pill's 2nd-turn narration locks the canonical
  leading phrase per spec test CopilotKit#4.

Replaces nothing — purely additive. The dedicated pill-prompt entries
beat the broad 'plan' and showcase-assistant catch-all entries that were
silently winning before.
jenningsloy318 pushed a commit to JMaiGC/CopilotKit that referenced this pull request May 8, 2026
…ls-async to genuine assertions

hitl-in-app — 7 explicit tests (1 skip):

- Page-load and pill-render tests retained.
- New refund #12345 approve/reject pair asserts the deterministic
  fixture leading phrases ("I am processing the $50 refund" vs
  "refund request was not approved").
- New escalate #12347 approve/reject pair asserts "Escalated ticket
  #12347" vs "Not escalated".
- The describe block runs in serial mode so the approve test
  (sequenceIndex 0 in the fixture) always runs before the reject test
  (sequenceIndex 1) for each pill.
- Downgrade #12346 stays skipped per spec (broken upstream as of
  2026-05-07).

frontend-tools-async — 4 explicit tests:

- Page-load test asserts composer + 3 pills.
- Project-planning, auth, and reading pills each click and assert the
  Notes DB card renders with the correct keyword heading and the
  per-note testid rows that the async handler returned. Anti-regression
  assertions catch the previous fixture-priority bugs (generic-plan
  boilerplate, showcase-assistant catch-all).
- Reading pill locks the full canonical shape per spec test CopilotKit#4: keyword,
  match count, note title, content lines, tag chip, and the assistant
  narration leading phrase.

No production-code testid changes — the existing dialog and notes-card
testids cover every assertion. Fixture work lives in d5-all.json (prior
commit).
jpr5 added a commit that referenced this pull request Jun 12, 2026
jpr5 added a commit that referenced this pull request Jun 12, 2026
…s treated as stale, not pinned (CF7-F3 #4)

decodeCellCommError's staleness gate (cell-model.ts:697) compared only
`now - parsed > staleAfterMs`, which is never true for a future-dated
observedAt — clock skew or a corrupt producer timestamp would pin the
unreachable/pending overlay indefinitely, the same permanent-phantom
failure mode the FF7 unparseable-timestamp skip prevents. A timestamp
more than COMM_ERROR_FUTURE_SKEW_TOLERANCE_MS (5min) ahead of now is
now skipped like an unparseable one; skew within tolerance still
surfaces (pinned by a companion test so the guard can't over-correct).
huangyingting pushed a commit to repomesh/CopilotKit that referenced this pull request Jun 12, 2026
…-side parity (SU7-F1/F2/F3)

SU7-F1 — backend host pattern hardening:
- F1.1  Reject bare trailing ?/# in the backend host pattern
- F1.2  Strip internal tab/CR/LF from the backend host pattern
- F1.3  Warn when ignoring an empty-string local backend override
- F1.4  Reject empty-userinfo @ in the backend host pattern authority
- F1.5  Keep __proto__ keys as data in local-backend maps
- F1.6  Commit the local-backends memo key only after the value computes
- F1.7  Trim local backend overrides before validation and name the real
        rejection
- F1.8  Honest FATAL when the pattern host is a stray scheme fragment
- F1.9  Canonicalize the pattern authority for parity with the override
        path
- F1.10 Acknowledge the staging-to-prod fail-open in the pattern fallback
- F1.11 Harden backend-url/local-backends-env test hygiene

SU7-F2 — runtime-config & client-config edge cases:
- F2.1  Branch POSTHOG_HOST rejection reasons (scheme/degenerate/parse-
        failure) instead of the catch-all mislabel
- F2.2  Reject loopback BASE_URL/DOCS_HOST in production instead of the
        silent http:// prepend
- F2.3  Key the DOCS_HOST fallback once-guard on (mode, shellHost, value)
        and mode-prefix all value-only guard keys
- F2.4  Reject a present-but-empty posthogKey in the client config reader
- F2.5  Drop the trailing slash from SSR_PLACEHOLDER_URL for structural
        parity with server values
- F2.6  Attribute the DOCS_HOST slash-strip to readDocsHost itself
- F2.7  Normalize trailing-dot FQDN spellings in the docs self-host loop
        guard (both compare sides)
- F2.8  Harden console spies to capture all log args; pin the full all-env
        config shape; converge SSR simulation on vi.stubGlobal

SU7-F3 — script-side parity, table classification & test isolation:
- F3 CopilotKit#1  Handle a missing reference integration per the error contract
- F3 CopilotKit#2  Port the runtime backend-host-pattern normalization into the
         generator — scheme/trailing-slash strip, degenerate fallback,
         NEXT_PUBLIC fallback
- F3 CopilotKit#3  Treat non-mapping manifest parses (empty/null/scalar/array YAML)
         as validation errors, not TypeErrors
- F3 CopilotKit#4  Label a missing/unreadable constraints.yaml per the stderr+exit(1)
         error contract
- F3 CopilotKit#5  Align atomic-write tmp naming with the test harness straggler-
         sweep convention; guard main() on direct invocation
- F3 CopilotKit#6  Correct the determineCellStatus unshipped docstring; replace
         stale hardcoded cell counts with formulas
- F3 CopilotKit#7  Isolate the pattern suite on a per-suite tmpdir harness; snapshot
         the generator's full write set
- F3 CopilotKit#8  Classify discarded duplicate wildcards as duplicates — hoist the
         owner check above the destination warns
- F3 CopilotKit#9  Reject a root ("/") EXACT seo-redirect source — homepage-hijack
         twin of the root-wildcard guard
- F3 CopilotKit#10 Reject seo-redirect entries with non-printable-ASCII source/
         destination — close the silent-dead-entry class
- F3 CopilotKit#11 Strip trailing slashes in normalizePosthogHost before the scheme
         test
- F3 CopilotKit#12 Message-filter the empty-slug-set error count; pin the single
         matcher entry
jpr5 added a commit that referenced this pull request Jun 15, 2026
… + headless-complete + LGP-canonical naming (#5427)

## Summary

BIA D6 component port (#4 from PR #5413 followup list). Companion to PR
#5407 (claude-sdk-python), PR #5413 (initial BIA D6), PR #5421 (BIA D6
small follow-ups). Brings BIA closer to LGP gold-standard parity.

### What's in

- **tool-rendering**: 5 LGP-mirrored companion components
(`weather-card`, `flight-list-card`, `stock-card`, `d20-card`,
`custom-catchall-renderer`) + extracted `tool-renderers.tsx` wiring.
**D6 GREEN.**
- **headless-complete**: 2 new components (`stock-card`, `chart-card`) +
`get_revenue_chart` server tool + LGP-aligned 4 pill suggestions +
`data-message-role` on bubble cascade + `get_weather` tool name fix in
tool-renderers. Turns 1 (weather) + 2 (stock) GREEN.
- **roll_dice → roll_d20 rename** across BIA backend + reasoning-chain
references (LGP canonical naming).
- **aimock fixtures**: BIA-namespaced `tool-rendering.json` updated +
`tool-rendering-reasoning-chain.json` realigned to the rename.
- **PARITY_NOTES**: documents the server-tool reprompt loop
architectural gap blocking turns 3+4 of headless-complete.

### Known issue (documented in PARITY_NOTES.md, out-of-PR-scope)

headless-complete turns 3 (highlight_note) and 4 (revenue_chart) RED due
to BIA's TanStack multi-turn server-tool reprompt cycle + aimock
userMessage-keyed fixtures looping until timeout. Three remediation
options identified — all require changes outside this PR's scope (BIA
agent architecture / aimock matcher precedence / fixture matcher
gating).

### Test plan

- [x] Local `--direct` D6 on tool-rendering: GREEN (2.8s)
- [x] Local `--direct` D6 on headless-complete: turns 1+2 GREEN, turns
3+4 RED (documented)
- [x] CI green on PR
jpr5 added a commit that referenced this pull request Jun 18, 2026
…0 reservation, bin/showcase slots) (#5543)

## Summary

Fixes the `--isolate` slot picker in `showcase/scripts/cli/_common.sh`
and adds a new `bin/showcase slots` inspector subcommand. Resolves five
compounding bugs that made multi-agent local testing unreliable.

## Bugs fixed

1. **`SHOWCASE_ISO_SLOT=<N>` env var was ignored.** The picker walked
0→N regardless. Now: validates input (positive integer, `1 ≤ N ≤ 45`,
slot 0 rejected as base stack), tries exactly that slot, fails loudly on
conflict.
2. **No port-probe before commit.** Picker `mkdir`'d a slot dir without
checking whether the slot's host ports were free. A slot whose dir was
absent but whose ports were taken (foreign Docker project, host service
like macOS AirPlay on 5000) was picked then failed at `docker compose
up`. Now: `lsof`-probe every candidate port before committing the claim;
rmdir + try next on conflict.
3. **Slot 8 / port 5000 collision on macOS.** Base dashboard port `3200`
+ slot 8 offset `+1800` = `5000`, permanently bound by macOS Control
Center's AirPlay Receiver. Shifted dashboard base port `3200 → 3210`
across `docker-compose.local.yml` and `showcase/harness/src/cli/*.ts` so
slot 8 → port `5010` (free).
4. **Slot ownership desync across 3+ independent owners.** Picker
checked only the dir; sweeper checked dir+pid+containers; neither
checked foreign ports. New unified `_slot_state` returns all 4 axes
(dir/pid/liveness/ports/offset/project); new `bin/showcase slots`
exposes the state via table / `--json` / `--free --brief` filters.
5. **Parallel pre-claim deadlock dissolved** by bugs 1+2+4 — per-session
pinning via env var + accurate port-probe + atomic `mkdir` lock
self-resolves contention.

## Implementation

- New helpers in `_common.sh`: `_slot_offset_ports`, `_slot_liveness`
(extracted from sweeper), `_slot_ports_free` (with own-project
docker-listener filter), `_slot_state` (composite axis report).
- Rewritten `_claim_isolate_slot`: pinned-path (validate / try / die
loudly) and auto-pick-path (1..MAX_SLOT, rmdir + skip on port-held).
Slot 0 reserved with explicit die message.
- `ISOLATE_MAX_SLOT=45` centralized as a constant.
- Dashboard host port shift `3200 → 3210` across 6 files (compose + 4
harness TS + comment updates).
- New `cmd-slots.sh` plugin (auto-discovered by `bin/showcase`): default
table, `--json` (JSONL), `--free` (filter to claimable slots), `--brief`
(numeric IDs only).

## Tests

**Bats — 54/54 GREEN** in `showcase/scripts/__tests__/isolate.bats`:

- 12 pre-existing tests updated for slot-0-reservation contract
(reap-evidence assertions preserved; only slot-number / port-offset
expectations updated).
- 11 new tests added:
  - lsof stub + foundation smoke (test #0)
- Pinning behavior tests #1-3 (success, live-die, validation incl.
0/foo/99)
- Port-probe tests #4-7 (stale-reap, `_slot_offset_ports 8 → 5010 ≠
5000`, foreign-process skip, own-project no-skip)
- Composite tests #8-10 (`_slot_state` 5 axes, `bin/showcase slots`
output, concurrent claim distinct slots)
- lsof-graceful test (#54): `_slot_state emits ports=? when lsof is
unavailable`

**Vitest — 17/17 GREEN** in
`showcase/harness/src/cli/control-plane-run.test.ts` (port-shift stub
consistency).

**Value-test (live local, plan §6 scenarios) — all 3 PASS:**

- **Scenario A:** On the test host Docker was holding slot 9's ports, so
the picker correctly REFUSED `SHOWCASE_ISO_SLOT=9` with per-port
diagnostics (proving the fail-loud half of the contract). Re-ran with
`SHOWCASE_ISO_SLOT=15` (first free slot) and the pin was honored
cleanly: `ISOLATE_SLOT=15`, `OFFSET=3200`. Both halves of the pin
contract verified.
- **Scenario B:** Slots 1-7 pre-occupied with live pids + Python
listener on `127.0.0.1:5010` (slot 8's dashboard port) → picker logged
"Slot N ports held" + "trying next" for each conflict, walked past 9..13
(Docker-held), and landed on slot 14 with `OFFSET=3000`. No silent
collision.
- **Scenario C:** `bin/showcase slots` matches reality: slot 0 →
`OFFSET=+0 PROJECT=showcase (base)`; pre-claimed slot 5 → `DIR=present
PID=<pid> LIVE=live PORTS=held OFFSET=+1200 PROJECT=showcase-iso5-test`.
`--free --brief` outputs only fully-claimable slot IDs (44 in this run,
slot 5 excluded).

## Code review

Full 7-agent cr-loop with `pr-review-toolkit` reviewers (Round 1 +
confirmation round). 4 subject-scope load-bearing findings fixed:
- `_reap_isolate_slot` arg shape in pinned-path retry
- `_slot_state` base-stack offset (slot 0 → `+0`, not `+200`)
- TESTING.md item 8/9 column-name accuracy (matches actual `SLOT DIR PID
LIVE PORTS OFFSET PROJECT` header)
- `bin/showcase slots` lsof-graceful degradation (inspector reports
`PORTS=?` instead of dying when `lsof` is missing)

Plus 1 trivial comment-phrasing fix (race-comment wording). ~50
pre-existing harness/compose findings partitioned out-of-subject and
deferred to follow-up PRs (see below). Procedure 3 bucket-(c) promotion
audit returned zero PROMOTE_TO_A items — full convergence.

## Follow-up PRs (out-of-subject, separate subjects)

These coherent subjects surfaced during CR but belong to distinct PRs
(the diff merely brushed against them for the `3200→3210` shift):

- **d1** — Harness `up()` / `doctor` should health-check
`harness-control-plane` (port 8081). `_slot_offset_ports` includes 8081;
`INFRA_PORTS` in `doctor.ts` / `lifecycle.ts` does not.
- **d2** — `doctor.ts` port + image diagnostic loud-failure pass
(`checkStaleImages`, `checkPorts`, `isPortListening`,
`checkDepotInterception` swallow errors).
- **d3** — `lifecycle.ts` error-surfacing pass (broad catches in
`loadPortsFile`, `isRunning`, `compose`, `healthCheck`, `diffLogs`,
etc.).
- **d4** — `docker-compose.local.yml` healthcheck error visibility
(`.catch(() => process.exit(1))` swallows; dashboard `/` returns 307).
- **d5** — `apply_isolation` Python rewriter fail-loud pass (no
`re.subn` count checks, hand-rolled YAML demos parser).
- **d6** — Centralize infra port literals (currently duplicated in 4
places).
- **d7** — `lifecycle.ts:11-13` stale `ops/` path comment (file lives at
`harness/`).
- **d8** — `cmd_slots --json` `pid` field typing (string vs number) —
settle when first JSON consumer appears.

## Test plan

- [x] `bats showcase/scripts/__tests__/isolate.bats` → 54/0
- [x] `pnpm vitest run src/cli/control-plane-run.test.ts` (in
`showcase/harness/`) → 17/0
- [x] `pnpm exec tsc --noEmit` (in `showcase/harness/`) → clean
- [x] `oxfmt --check showcase/` → clean
- [x] `docker compose -f showcase/docker-compose.local.yml config` →
valid YAML
- [x] Local value-test scenarios A/B/C from plan §6 → PASS
huangyingting pushed a commit to repomesh/CopilotKit that referenced this pull request Jun 18, 2026
…command, and lsof-graceful inspector

- Update 12 slot-0-assumption tests for slot-0 reservation contract
- Add lsof stub and foundation smoke for isolate.bats
- Tests CopilotKit#1-CopilotKit#3: slot pinning behavior
- Tests CopilotKit#4-CopilotKit#7: port-probe and stale-reap behavior
- Tests CopilotKit#8-CopilotKit#10: slot state, slots subcommand, concurrent claim
- New test for _slot_state ports=? when lsof unavailable
tylerslaton added a commit that referenced this pull request Jul 9, 2026
…ud helper

CR-loop confirmation-round #4 findings:

- validator: `resolvesForMode` (renamed from `typesCoversMode`) now applies to
  EVERY condition, not just `types`. A partial object under `node`/`default`
  (active in both modes) no longer silently covers the mode it lacks —
  resolution falls through to the sibling, catching the untyped-JS #3324 shape
  there. This completes the per-mode model.
- helper: `withTypesConditions` throws on a non-object `exports` (bare string /
  array) instead of iterating it into a corrupt map; `typedTarget` now warns
  loudly when a JS target has no adjacent declaration (was silent, contradicting
  the helper's own fail-loud contract); idempotency skips only the helper's own
  `{ types: <string>, ... }` output, so a hand-authored types-first PARTIAL
  object is normalized (its untyped sibling gets a `types`). UMD / `.d.mts` docs
  corrected; `ctx.pkg: unknown` documented as intentional (weak-type constraint).
- tests: node/default partial fall-through regression; types-first-partial
  normalization; a helper->validator round-trip; a console.warn assertion for
  the missing-declaration path; split the untouched-target test into silent
  (non-JS) and warning (JS) cases.
- react-native: dropped a pre-existing duplicate `@ag-ui/client` external.

Call sites: resolvesForMode (internal, walk + recursion; grep-confirmed no
`typesCoversMode` refs); withTypesConditions signature unchanged, and the new
throw/warn never fire on tsdown's real input (object map, packageJsonPath
present, dts:true).

36 tests pass; validator typechecks; validate:exports exits 0; native-loader
builds of react-core + react-native unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
tylerslaton added a commit that referenced this pull request Jul 10, 2026
…ud helper

CR-loop confirmation-round #4 findings:

- validator: `resolvesForMode` (renamed from `typesCoversMode`) now applies to
  EVERY condition, not just `types`. A partial object under `node`/`default`
  (active in both modes) no longer silently covers the mode it lacks —
  resolution falls through to the sibling, catching the untyped-JS #3324 shape
  there. This completes the per-mode model.
- helper: `withTypesConditions` throws on a non-object `exports` (bare string /
  array) instead of iterating it into a corrupt map; `typedTarget` now warns
  loudly when a JS target has no adjacent declaration (was silent, contradicting
  the helper's own fail-loud contract); idempotency skips only the helper's own
  `{ types: <string>, ... }` output, so a hand-authored types-first PARTIAL
  object is normalized (its untyped sibling gets a `types`). UMD / `.d.mts` docs
  corrected; `ctx.pkg: unknown` documented as intentional (weak-type constraint).
- tests: node/default partial fall-through regression; types-first-partial
  normalization; a helper->validator round-trip; a console.warn assertion for
  the missing-declaration path; split the untouched-target test into silent
  (non-JS) and warning (JS) cases.
- react-native: dropped a pre-existing duplicate `@ag-ui/client` external.

Call sites: resolvesForMode (internal, walk + recursion; grep-confirmed no
`typesCoversMode` refs); withTypesConditions signature unchanged, and the new
throw/warn never fire on tsdown's real input (object map, packageJsonPath
present, dts:true).

36 tests pass; validator typechecks; validate:exports exits 0; native-loader
builds of react-core + react-native unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mxmzb added a commit that referenced this pull request Aug 11, 2026
The #4893 entry-surface guard timed out nondeterministically at full test
parallelism ("Test timed out in 5000ms" on `await import("../headless")`),
which four independent agents each worked around with --testTimeout or
--maxWorkers=2. A flaky hard gate is a gate people learn to ignore.

Measured, not guessed. The import is a one-time module-graph load whose
VARIANCE — not its mean — broke the default budget: ~0.7-1.1s for this file
alone and ~0.9-1.8s inside the full 22-file suite (n=8 each), but 4568ms on
the run straight after a cold `nx build`, i.e. 91% of the 5000ms budget spent
on an otherwise idle machine. The cost is resolve/transform plus cold-page-
cache I/O over the ~283 KB of workspace dist that vitest.config.mjs inlines
via `server.deps.inline: [/@copilotkit/]` (core ~218 KB, react-core
v2/headless ~55 KB, v2/context, shared); bare-Node `import()` of the
equivalent prebuilt dist is 461ms, so evaluation is not the expensive part.

Four separate tests each awaited that same import, so all four raced one
cost against one budget — and when the first lost the race the other three
inherited its in-flight import and timed out with it, which is why the
observed signature was three simultaneous failures rather than one. They now
share a single explicitly-budgeted `beforeAll`, so the cost lives in exactly
one place and each test reports ~0ms.

The hook is nested rather than top-level on purpose: its failure domain must
cover only the tests that need the module, or an import failure would take
down the fs-only graph tests too — the same blast-radius problem as blind
spot #4, just relocated into a hook.

No assertion is weakened: comment stripping, import()/require() extraction,
the exact resolved-graph pin and the revived existence test are untouched,
and the guard still fails on a real violation (injecting a lazy
`import("@copilotkit/react-core/v2")` into src/streaming-fetch.ts trips 3
assertions; reverted).

Verification: 5 consecutive full-suite runs at DEFAULT parallelism, no
--maxWorkers or --testTimeout override, 271/271 passing in 3.97-5.87s wall
each; plus 3 concurrent full suites (30 workers on 10 cores) all green, and
one pass at load average 235. `check-types` clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…te integration slug; sort-ordered preview selection

- Extract findFrameworksWithCell into @/lib/docs-render so the docs
  catch-all and framework-scoped catch-all share one implementation
  instead of carrying a near-identical local copy in each (finding CopilotKit#3).
- Validate /docs/integrations/<slug> against the registry with
  notFound() when the slug is unknown. Previously a crafted URL like
  /docs/integrations/fake-framework silently fell through to an empty
  nav tree, indistinguishable from a valid integration with no scoped
  content (finding CopilotKit#4).
- Sort integrations by sort_order then slug before picking the
  animated preview URL. Registry iteration order alone isn't
  deterministic w.r.t. the visual priority the docs UI shows
  everywhere else, so the preview now matches (finding CopilotKit#5).
JadeCong pushed a commit to CloudEngineHub/CopilotKit that referenced this pull request Oct 10, 2026
…-time review

Addresses 5 Important review findings on the Task 5 commit plus 2
controller rulings.

1. CopilotChat.tsx's run-activity effect listed `copilotkit.headers` in
   its deps. A builder's snapshot object churns on every resolve, so a
   run followed by any re-render tore down and rebuilt the standalone
   run-activity store's subscription for no reason (extra
   setContext/stop/start, and a detachActiveRun when wake-reconnect was
   active). Fixed to `copilotkit.ɵheadersGeneration`, matching
   use-threads.tsx's existing pattern.

   Controller ruling: `HeaderSourceResolver.accept()` (core) now keeps
   the previous snapshot object when a resolve's normalized result is
   shallow-equal to it (same keys, same values), so `core.headers`
   only gets a new reference when a header value actually changed --
   this is what makes headers-as-a-dep safe anywhere in react-core/vue/
   angular, not just in the one call site fixed above.

2. The 20-rerenders memo-stability test had no `publicApiKey`, so
   `ɵwithHeaderDefaults`'s empty-defaults passthrough masked a
   deps-only mutation (adding `headersProp` to the deps without
   touching the factory). Added a `publicApiKey` row: with real
   defaults present, `ɵwithHeaderDefaults` wraps in a NEW closure on
   every call, so a deps-only "obvious fix" now genuinely breaks it.

3. The R3 annotation test was circular: the mock had no
   `copilotkit.headers` snapshot, and the mock `ɵruntimeFetch` wrote
   its header AFTER spreading `init.headers`, so a reintroduced stale
   spread would have been silently overwritten either way. Rewrote it
   to give the mock a snapshot with a key the current source cannot
   produce, and assert that key is ABSENT from the sent request (the
   mock no longer masks a regression). Added the missing
   use-learning-containers coverage: both Effect 1's mount emit and
   Effect 2's cleanup/reset emit now have their own snapshot-absence
   test.

4. StrictMode rows only asserted `/info` called once. Added: the
   connection actually reaches Connected, the `/info` request's
   Authorization matches the builder's resolved value (including the
   async row), a `connect()` spy proving the mount effect really
   double-invoked (2 calls), a 4th row (inline builder + publicApiKey),
   and a 50ms (not 30ms) settle window.

5. Controller ruling: `headersRef.current = headersProp` is now
   assigned during render, not inside a passive `useEffect`. React
   fires a child's effects before its parent's own effects
   (bottom-up); if only the provider's effect updated the ref, a child
   effect that fires a request in the SAME commit as a new builder
   closure would still read the previous commit's closure. Verified
   with a plain (non-proxied) HttpAgent -- deliberately NOT wrapped
   with `ɵruntimeFetch`, so `prepareAgentHeadersForRun`'s one
   synchronous resolution is the only place the token can land, with
   no send-time safety net to mask the race.

Mutation checks (all restored after confirming failure):
- CopilotKit#1: CopilotChat.tsx dep reverted to `copilotkit.headers` -> new
  run-activity test failed (3 unwanted setContext/start/stop calls
  instead of 0).
- CopilotKit#1 (core ruling): `accept()` reverted to always replace the
  snapshot -> both new core-header-source tests failed (`toBe` on
  object identity).
- CopilotKit#2: `headersProp` added to the deps array only (factory untouched)
  -> the "with publicApiKey" row failed (20 setHeaders calls); the
  "no publicApiKey" row still passed, exactly as the review predicted.
- CopilotKit#3: put `copilotkit.headers ?? {}` back in use-learn-from-user-action
  and in both use-learning-containers effects -> all three new
  snapshot-absence tests failed.
- CopilotKit#4: commented out `copilotkit.connect()` in the reconnect effect ->
  all 4 StrictMode rows failed on the new Connected-status assertion.
  (A `setHeaders({})` or `setRuntimeUrl` toggle in the effect's own
  cleanup, as the review suggested by example, does NOT reproduce a
  failure here: the effect's setup unconditionally re-applies every
  setter before calling `connect()` again on the second StrictMode
  invoke, so anything a mutation confined to cleanup changes gets
  healed by the very next setup pass. Documented so a future pass
  doesn't re-attempt the same example expecting it to fail.)
- CopilotKit#5: moved `headersRef.current = headersProp` back into a passive
  `useEffect` -> the new same-commit test failed (`agent.headers`
  carried the stale "Bearer tok-1" instead of "Bearer tok-2").

Verification:
- `NX_NO_CLOUD=true pnpm nx run @copilotkit/react-core:test --skip-nx-cache`
  -> 159 files / 1747 tests, all green.
- `NX_NO_CLOUD=true pnpm nx run @copilotkit/core:test --skip-nx-cache`
  -> 81 files / 1002 tests, all green.
- `NX_NO_CLOUD=true pnpm nx run @copilotkit/core:check-types --skip-nx-cache`
  and `NX_NO_CLOUD=true pnpm nx run @copilotkit/react-core:check-types --skip-nx-cache`
  -> both clean.
- Core dist rebuilt (`nx run @copilotkit/core:build --skip-nx-cache`)
  after the header-source.ts change, before re-running react-core.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

1 participant