12 Commits
Author SHA1 Message Date
Waleed 293ec1b7e1 improvement(workflow-code): server hardening, flaky test root causes, and agent DX across the source loop (#10287)
Server: dry runs charged to the plan budget and slot, create-from-source answers 429 when slots are full, the Code tab has its own slot lane, staged blobs count against the payer's storage quota (consumed on apply, never renewed by reads), file deletes carry a revision precondition, row limits refuse only growth, joined table transactions keep their timeouts, and blocks/edges/subflows load in a stable created_at,ctid order. DX: group help for the source loop, a primer covering renames, failures and test runs, JSON-only output, run errors mapped back to source file and line, --stop-after/--from-block by name, webhook URLs after deploy, GitHub Actions annotations and step summary, exit 15 for a partial write, table names on every table route, status that agrees with the dry run, and quieter output. Flaky tests fixed at the root (keep-alive races, sleep-based waits). Migration 0469 adds a nullable staged_blob.consumed_at.
2026-11-21 07:05:36 -08:00
Waleed 85ea094e7a chore(redis): require Redis and remove the no-Redis fallbacks (#10272)
* chore(redis): require Redis and remove the configuration fallbacks

* chore(redis): remove the remaining no-Redis paths across the app, realtime, setup and deploy config

* fix(redis): resolve rate-limit storage lazily and address review findings

* improvement(redis): address review threads and simplify the leftovers of the fallback removal

* fix(redis): keep unit tests off a real Redis and update integration tests for lazy channels

* chore(redis): drop stale fallback references after rebasing
2026-11-20 19:56:20 -08:00
Emir KarabegandWaleed Latif 06faa0747f improvement(auth): unify sign-in and access pages (#9461)
* feat(auth): implement isolated Paper design system

* chore(auth): remove design-tool attribution

* fix(auth): preserve navigation and desktop layout in redesign

* fix(auth): consolidate fields and localize icons

* fix(auth): resolve review findings and complete layout isolation

* fix(auth): preserve invitation loading and branding boundaries

---------

Co-authored-by: Waleed Latif <walif6@gmail.com>
2026-10-30 10:06:24 -07:00
Waleed c41323b70d fix(billing): re-read the usage gate often once a payer nears its limit (#9091)
* fix(billing): re-read the usage gate often once a payer nears its limit

The usage gate cached a within-limit admission for five minutes, so a payer
who crossed the limit kept running executions and copilot steps for up to
that long. On a free plan that is unbilled spend; on a capped plan it bills
past the cap. An admission is now held for 10s when the payer or the acting
member has less headroom than the larger of $25 and 20% of the limit (every
free-plan payer), and for the full five minutes otherwise. The direct-v1
account verdict cache follows the same rule.

* test(billing): drive the gate-cache clock with faked timers instead of real waits
2026-10-15 15:57:17 -07:00
Waleed b958bfcc7c improvement(naming): rename sandbox-tasks to sandboxes and standardize file names (#9044)
* improvement(naming): rename sandbox-tasks to sandboxes and drop folder-name stutter in execution files

* improvement(naming): standardize file names to the folder and role conventions

Renames every check:file-names baseline entry (stutter and redundant-suffix) so the
baseline is empty, plus the same rule's uncaught cases: grandparent-domain prefixes in
application/ and orchestration/ folders, loose stores moved to stores/<feature>/store.ts,
non-hook files dropped from the use-* prefix, and application context/errors outliers.

* improvement(naming): resolve rename ambiguities and stale file references from review
2026-10-14 14:58:14 -07:00
Siddharth GanesanandVikhyath Mondreti f525ff2feb feat(mothership): add super-user Plan and knowledge graph settings with benchmark tooling (#8637)
* feat(mothership): authorize private cross-workspace memory scopes

* feat(desktop): add gated macOS computer use

* fix(desktop): preserve generated computer-use contracts

* fix(desktop): cancel computer use when its renderer exits

* fix(desktop): complete native computer tool lifecycle

* fix(desktop): support rich editors and verified Mac input batches

* fix: preserve desktop observations through recovery and report app focus

* Gate Search Assistant integration lookups with AppConfig (#8301)

* Enable read-only integration lookups for Search Assistant

* Preserve inherited tool versions in generated integration docs

* Align provider tests with Search read-only operations

* Gate Search integration tools with AppConfig

* Preserve dev test runner isolation during promotion

* Default Plan chats to independently saved Opus 5.5 Medium preferences

* Remove default Mship execution cutoff and expose Slack agent prerequisites

* fix(catalog): preserve credential gates for automation discovery

* Add workspace specification benchmarks with isolated Plan evaluation

* Add private knowledge graph selection in settings

* Retain benchmark run history with comparisons and human review

* chore: redeploy Sim after benchmark configuration update

* Add superuser benchmark console with selected-user execution

* Inspect benchmark workspaces incrementally and search generated specs

* Remove benchmark cutoffs and renew active stage leases

* Generate benchmark redactions from exact passages

* Create owned conversations for every benchmark execution

* Preserve partial benchmark answers for human review

* Grade benchmark mechanics with verified reference resolution

* Reconcile Plan feature with staging contracts and validation gates

* Expose the Graphiti rollout gate through authorized memory scope

* Share benchmark super-user eligibility with Plan and knowledge graphs

* fix(plan): address eligibility, benchmark state and desktop review findings

* feat: compare benchmark planner models with saved scores

* test: align Plan composer and desktop fixtures with staging

* fix(desktop): keep disabled computer use dormant

* fix(plan): enforce benchmark and native action admission

* fix(plan): preserve secret metadata during benchmark reads

* fix(plan): isolate embedded CLI and checkpoint benchmark stages

* fix(desktop): bound native requests and completion images

* fix(plan): revalidate access and retain benchmark state

* fix(plan): qualify persisted effort integration fixtures

* fix(db): reconcile benchmark migrations with staging retirement

* fix(db): preserve table change log in benchmark migration chain

* fix(benchmarks): delete artifacts with their execution target

* fix(mothership): isolate benchmark state and preserve tool completions

* fix(desktop): preserve action evidence in unload completions

* fix(desktop): keep projected parent references valid

* fix(computer): preserve uncertainty and label permission controls

* test(mothership): await actual tool cancellation completion

* fix(plan): resolve review findings and trigger initialization

* docs(triggers): point Linq guidance at the builder module

* fix(plan): preserve fork scope and benchmark redaction boundaries

* fix(plan): retry retained completions and guard benchmark drafts

* fix(computer): stop completion delivery at identity reset

---------

Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
2026-10-13 16:24:27 -07:00
Waleed 18b175035c chore(tests): ratchet real wall-clock waits in unit tests (#8954)
* chore(tests): ratchet real wall-clock waits in unit tests (check:test-patterns real-wait)

New `real-wait` rule in scripts/check-test-patterns.ts flags a unit test that
waits on the wall clock with no fake timers in scope:

- `sleep`/`interruptibleSleep` resolved through their `@sim/utils/helpers`
  import binding (aliases included; skipped when the file mocks that module),
- `setTimeout` from `node:timers/promises`,
- `new Promise((resolve) => setTimeout(resolve, ms))` and variants whose timer
  callback resolves the promise (reject-only timeout guards are not waits).

Zero or omitted delays are macrotask flushes and are not flagged. Fake timers
cover a wait when an earlier `vi.useFakeTimers()` in an enclosing function or
the module, or a `beforeEach`/`beforeAll` of an enclosing describe or the
module, fakes `setTimeout` (`toFake: ['Date']` and `shouldAdvanceTime: true`
do not). Integration and *.live.test.ts files are exempt: their waits are on
real services. Each occurrence is a numbered entry, capping the count per file.

`--update --init-rule <rule>` admits the one-time baseline for a rule the
baseline does not track yet; `--update` stays shrink-only. Baseline: 121
real-wait entries across 46 files (72 -> 193 total).

* fix(tests): keep a real-wait flagged before the fake-timer install in its own hook

A beforeEach/beforeAll that installs fake timers covered its whole suite,
including waits earlier in the same hook body, which run on the real clock.
Only waits after the install in that hook are exempt now; tests and other
hooks in the suite keep the exemption.

* fix(tests): make real-wait's fake-timer exemption exact and drop --init-rule

- Remove `--update --init-rule`: it admitted entries for any rule with no
  remaining baseline entries. `--update` is strictly shrink-only again; the
  real-wait entries enter once, in this PR's baseline diff.
- `vi.useRealTimers()` ends the exemption from where it runs, including a
  nested suite restoring real timers after an outer hook faked them.
- A clock installed in `beforeEach` no longer covers `beforeAll`/`afterAll`
  or earlier sibling `beforeEach` hooks; `beforeAll` no longer covers earlier
  sibling `beforeAll` hooks.
- Only `vi.useFakeTimers()` with no config, or a literal config proven to fake
  setTimeout without shouldAdvanceTime, exempts a wait.
- Namespace imports (`helpers.sleep`, `timers.setTimeout`) are flagged.

* chore(tests): make the wait-export table read-only

* fix(tests): let a module-scope fake-timer install cover helper functions declared above it

Functions run only after the module loads, so a module-scope vi.useFakeTimers()
(or vi.useRealTimers()) applies to every function body regardless of source
order; module-scope waits still follow source order.

* fix(tests): exempt helpers from a module-scope fake-timer install only when nothing ran before it

A helper called at module scope before vi.useFakeTimers() waits on the real
clock. A module-scope install now reaches function bodies only when every
earlier module-scope statement is load-safe (imports, function/class
declarations, type-only statements, vi.mock/doMock/hoisted, and variables
whose initializers call nothing); otherwise source order applies. A
module-scope vi.useRealTimers() still reaches every function body.

* fix(tests): skip only helpers called before a module-scope fake-timer install

Any unrelated module-scope call (const run = vi.fn()) used to drop the
helper exemption. Now a module-scope vi.useFakeTimers() covers every function
body except a helper (function declaration or variable bound to a function)
that earlier module-scope code calls directly by name; calls through other
helpers are not traced. WAIT_EXPORTS and HOOK_KINDS are as const.

* fix(tests): recognize module-scope helpers whose initializer is wrapped in a type assertion

helperName now unwraps as/satisfies/non-null/parenthesized initializers with
the shared unwrap helper, so a wrapped arrow called before a module-scope
vi.useFakeTimers() stays flagged.
2026-10-12 21:40:04 -07:00
Waleed c55698a728 chore(ci): fail closed on missing test Redis in CI and skip unused pg16 service (#8938)
- readTestRedisUrl throws when CI is set and TEST_REDIS_URL is missing, so
  Redis-gated integration suites can no longer pass by skipping
- start the postgres:16 service only on integration (push, 1/4), the one job
  whose step uses it
- move the two env-gated smoke files that no workflow enables to *.live.test.ts
  and shrink the test-patterns baseline accordingly
2026-10-12 13:10:56 -07:00
Waleed b2cd2a93d2 chore(tests): tighten check:test-patterns and shrink its baseline (#8886)
* chore(tests): tighten check:test-patterns and shrink its baseline

- Exempt *.live.test.ts from global-remock and local-factory: live suites bind
  real boundaries (real Postgres via a re-mocked @sim/db).
- Fail when a central mock vi.mocks an @/ module id that no longer resolves;
  repoint copilot-http to @/lib/mothership/request/http (renamed in #8208)
  and drop executor.mock's mocks of deleted modules. The check also scans
  vitest.setup.ts, whose mock and alias of the deleted @/stores/console/store
  are removed.
- Gate local-helper on the workspace depending on @sim/testing.
- redundant-hook inspects every afterEach statement and the leading run of a
  beforeEach (a later reset can deliberately discard setup's own calls).
- New module-scope-stub rule: module-scope vi.stubGlobal/stubEnv/spyOn is
  undone before the first test; delete the six dead fetch stubs.
- Rewrite @sim/testing @example barrel imports to direct paths.
- Replace real sleeps with fake timers in file-doc-store and update-cost.
- Convert table-constants and sim-search-connectors local factories to the
  central mocks; fold v1-route's subscription/rate-limiter duplicates into
  billingSubscriptionMock/rateLimiterMock.

Baseline: 140 -> 92 entries.

* fix(tests): catch exported and type-asserted module-scope stubs, and cover the stub and hook rules with fixtures
2026-10-10 01:05:58 -07:00
Waleed f20b5b451c fix(settings): decouple access settings from usage analytics (#8828)
* fix(settings): decouple access settings from usage analytics

* fix(billing): refuse expired reads and recover transaction timeouts

* chore(settings): simplify ledger fixture and correct plan documentation

* fix(settings): use neutral read-error feedback consistently

* refactor(settings): share the named plan and seat response type
2026-10-08 21:32:41 -07:00
Vikhyath Mondreti a1e573aed0 chore(search): remove legacy indexed enterprise search (#8528)
* chore(search): remove legacy indexed enterprise search

* fix(search): preserve live onboarding and Slack scope policies

* fix(search): close retired document writes and refresh Search consent

* fix(search): preserve ordinary knowledge base classification
2026-10-01 13:03:01 -07:00
Waleed 4e17dceda0 chore(tests): consolidate test patterns — shared Vitest base, central @sim/testing mocks, check:test-patterns, lean agent docs (#8309)
* chore(tests): consolidate test patterns — shared Vitest base, central @sim/testing mocks, check:test-patterns, lean agent docs

* fix(tests): discover central mocks from their declarations and accept the async-import form

* fix(tests): address review — mock fidelity, docs, and guards

* docs(tests): restore the heavy-graph, global-mock and permanent-implementation rules and small doc pointers
2026-09-25 16:36:13 -07:00