Working on Vector#
Vector is developed in one repository: the packages (kinetis/vector
and @kinetis/vector-ui, and the AI companion kinetis/vector-ai) and
the demo application (The demo application) that consumes them the way an
adopter would.
Every command on this page runs from demo/, with the stack up and
seeded, and with the monorepo’s overlay named:
export COMPOSE_FILE=docker-compose.yml:docker-compose.monorepo.yml
docker-compose.yml is the published demo’s own stack (The demo application),
which installs the packages from Packagist and npm.
docker-compose.monorepo.yml goes on top of it here: it mounts the
whole repository at /workspace, points Composer at
backend/composer.monorepo.json (COMPOSER), and runs the standalone
admin in the pnpm workspace. Without COMPOSE_FILE, pass both files
instead: docker compose -f docker-compose.yml -f docker-compose.monorepo.yml up --build -d. A command that creates
containers (up, run, build) without the overlay recreates them as
the published demo’s, which cannot see packages/.
Layout#
packages/vector/ kinetis/vector: registry, REST API, jobs, the queue dashboard (src/Queues/), MCP tools, migration stubs
packages/vector-ui/ @kinetis/vector-ui, the Nuxt layer, the AI UI included; its Vitest suite in test/nuxt/
hosted/ the hosted bundle's build entry: the layer alone, built into dist/static
packages/vector-ai/ kinetis/vector-ai: AI configuration, sealed provider keys, the ai settings group, filters, the assistant and its approvals, writing help, bulk rewrites, the usage ledger, migration stubs
demo/docker-compose.yml the published demo's stack: app, worker, scheduler, nginx, frankenphp, mysql, postgres, redis; node; oha on demand
demo/docker-compose.monorepo.yml this repository's overlay: the repository mounted, composer.monorepo.json, node in the pnpm workspace, e2e
demo/docker/ the PHP images (PHP-FPM and FrankenPHP) and their shared extension recipe, nginx, the Caddyfile, php.ini
demo/bin/ check-frankenphp and benchmark, for the FrankenPHP worker service
demo/backend/ the demo application: composer.json requires the exact releases (the published demo's); composer.monorepo.json installs them from ../../packages
src/Auth/ both sign-ins, their throttling, the vector and mcp group middleware, impersonation
src/Console/ demo:seed, and demo:queue-flaky, which queues the flaky job below
src/Jobs/ SyncWarehouseStockJob, a job that fails on purpose, for the queue dashboard
src/Http/Diagnostics/ GET /_demo/runtime, the development-only runtime report bin/check-frankenphp reads
src/Domain/ the shop's entities, on MySQL; Support/ the support desk's, on PostgreSQL
src/Vector/ the demo's resources, actions, widgets, dashboards and settings groups
migrations/ the shop, the queue and failed-jobs tables and Vector's tables (queue metrics included) for MySQL
migrations/admin/ Vector's tables for PostgreSQL, on the connection admin
migrations/support/ the support desk, on the connection support
bootstrap.php JWT keys, CORS for the standalone UI, the Vector bindings
public/vector-extensions/ the demo's runtime UI extensions
translations/ the demo's labels
tests/ PHPUnit (App\Tests\)
demo/frontend/ the demo Nuxt app: extends @kinetis/vector-ui
demo/e2e/ the end-to-end suite: Playwright, both admin modes
demo/README.md, AGENTS.md the published demo's own README and agent contract, with LICENSE, CHANGELOG.md and composer.json
docs/ this manual (Sphinx, MyST Markdown)
bin/orbitron-mcp launches the Orbitron MCP server for demo/backend, through demo/bin/orbitron-mcp with the overlay
Controllers, commands, entities and resources anywhere under App\,
Kinetis\Vector\ or Kinetis\VectorAi\ are discovered; there is no
registry to edit. Nothing
under packages/ may reference App\.
The demo is published on its own, as kinetis/vector-demo (the mirror
of demo/, Releasing), so its two Composer files differ only
where the monorepo needs them to:
backend/composer.json, the published demo’s, requireskinetis/vectorandkinetis/vector-aiat exactly the versions inpackages.manifest.json, from Packagist, and runs PHPStan and Psalm over the demo’s own sources. It has no lock:docker compose upresolves it aftercomposer create-project.backend/composer.monorepo.json, which the overlay selects withCOMPOSER, is the same file withpathrepositories for the two packages, each required asdev-main as X.Y.0at its manifest’s minor version (kinetis/vector-airequireskinetis/vector^1.0, which the alias satisfies), and the scripts that cover the packages too (phpstan.monorepo.neon,psalm.monorepo.xml,infection:vector,infection:queues). Its lock iscomposer.monorepo.lock.
node scripts/validate-versions.mjs holds the two files to that, and
node scripts/bump.mjs moves both. A dependency added to one goes into
the other in the same change.
Path packages install as symlinks, but vendor/composer/installed.json
keeps each package’s composer.json as it was at the last install.
After changing one, its extra.kinetis keys especially, reinstall it so
discovery sees the change:
docker compose exec app composer update kinetis/vector kinetis/vector-ai
Nothing the published demo ships may reach into the rest of the
repository: node scripts/validate-monorepo.mjs fails on a relative
path to packages/, /workspace/packages or a pnpm workspace:
dependency in any file under demo/ that demo/.gitattributes does not
mark export-ignore. The files only this repository uses (the overlay,
composer.monorepo.json and its lock, the monorepo QA configurations
and e2e/) are marked so, and the published archive leaves them out.
Updating the demo’s PHP dependencies#
Dependabot does not update demo/backend: an update has to move both
Composer files and the monorepo’s lock together, and release the demo.
To raise a dependency, or add one:
Make the same change in
backend/composer.jsonandbackend/composer.monorepo.json(node scripts/validate-versions.mjsrefuses any other difference between them).Update the lock under the overlay, which points Composer at
composer.monorepo.json, socomposer.monorepo.lockmoves:docker compose exec app composer update <vendor/package> --with-dependenciesRun the tests and static analysis above, then bump the demo, whose path is
demo/, after writing its CHANGELOG entry:node scripts/bump.mjs vector-demo patch
kinetis/vector and kinetis/vector-ai are the exception: their
versions follow the packages’ own bumps, which bump.mjs writes into
both files (Releasing).
Migrations#
kinetis/migrations records the sha256 of a migration file when it runs
the migration, and refuses to run anything while an applied migration’s
bytes differ from that record. So a published stub
(packages/vector/resources/migrations/, and vector-ai’s) and a
migration committed to the demo are immutable, comments and attributes
included. A schema change is a new timestamped migration: a .mysql.stub
and a .pgsql.stub in the package, and its copies in
demo/backend/migrations/ and demo/backend/migrations/admin/, as the
existing ones are laid out. A cosmetic change to an existing migration is
not made at all.
Tests#
docker compose exec app vendor/bin/phpunit # the API and the PHP package
docker compose exec -e VECTOR_TEST_DB_CONNECTION=default app vendor/bin/phpunit # the same, Vector's tables on MySQL
docker compose exec node pnpm test # the UI layer: Vitest, no server
docker compose exec node pnpm typecheck # vue-tsc over the layer and its tests
docker compose run --rm e2e # the admin in a browser, both modes
bin/check-frankenphp # the application under FrankenPHP worker mode
PHPUnit runs with Vector’s tables on PostgreSQL, where backend/.env
puts them, and again on MySQL. It handles its requests in-process and
goes through neither web server. bin/check-frankenphp checks the
running worker on :8081 (The demo application). frankenphp keeps the code it
booted with, so run docker compose restart frankenphp after a PHP
change, before checking it.
The UI layer’s Vitest suite is in packages/vector-ui/test/nuxt/. Each
file runs inside a Nuxt app built from the layer (@nuxt/test-utils,
happy-dom), so auto-imports, app config, the i18n plugin, Vuetify and
Pinia behave as they do in the admin. It covers the formatters and
client rules, the API client in both authentication modes, the auth
store, the schema and resource clients, and the generated form
(VxResourceForm) with its 422 mapping. API calls go to endpoints the
test registers (test/nuxt/endpoints.ts); nothing needs a server.
pnpm typecheck runs vue-tsc in strict mode over the layer, its tests
included.
bin/benchmark replaces the demo data when given --seed=N and needs
the stack to itself. Run it alone, then restore the stock data set
before PHPUnit:
docker compose exec --user www-data app vendor/bin/kinetis demo:seed --fresh
The end-to-end suite needs the hosted bundle installed
(The demo application) and writes to the demo databases, so run it on its own,
never beside PHPUnit. It signs in as its own admin, e2e@vector.local,
and clears that account’s saved preferences before each test, so it and
a person using the demo do not disturb each other. The AI specs run
only with the demo’s fake provider configured and
VECTOR_E2E_FAKE_AI=1 passed to the run, so they never call a real
model. See demo/e2e/README.md.
Documentation screenshots#
The screenshots in docs/_static/screenshots/ come from the end-to-end
spec demo/e2e/tests/screenshots.standalone.spec.ts, one pair per
screen: <name>-light.png and <name>-dark.png. A page embeds both,
with pydata’s only-light and only-dark classes, so the docs show the
one matching their own theme. The spec is skipped unless
VECTOR_SCREENSHOTS=1, so the normal run captures nothing.
The AI captures ask the demo’s scripted fake provider, so each run
shows the same answers: configure it in backend/.env
(VECTOR_AI_PROVIDERS=demo and VECTOR_AI_DEMO_TYPE=fake, Setup)
and pass VECTOR_E2E_FAKE_AI=1 to the run, which says that is the
provider. To regenerate the screenshots, start from the stock data set and the
queue dashboard’s failed jobs, then capture:
docker compose exec --user www-data app vendor/bin/kinetis demo:seed --fresh
docker compose exec --user www-data app vendor/bin/kinetis demo:queue-flaky --count=20 --failure=40
docker compose run --rm -e VECTOR_SCREENSHOTS=1 -e VECTOR_E2E_FAKE_AI=1 e2e test tests/screenshots.standalone.spec.ts
Before it opens a page, the spec makes what the seed does not, through
the admin API as e2e@vector.local (demo/e2e/support/screenshot-data.ts):
an Audit for SKU-00014: a price edit, its publishing and an Adjust stock run;
the saved views Low stock (shared) and Drafts;
a finished Excel export of the products, and a tags import with one refused row, with their notifications.
The capture of the assistant proposing a change turns Assistant may propose changes on through the same API, and puts the AI settings back after it.
Each of these is made only when it is missing, so a second run adds
nothing; demo:seed --fresh removes them again, since it empties
Vector’s audit trail, saved views, jobs and notifications (see
The demo application’s Seed data for everything it empties). Run the capture after
the flaky jobs have failed, so the Failed jobs tab has rows.
The tickets calendar needs no data of its own: the seed dates its tickets back from the day it ran, so the capture opens the month before the newest ticket was opened, a whole month of due dates.
The field reference’s images come from the same spec, in its fields
group: docs/_static/screenshots/fields/<page>-light.png and
-dark.png, named after the field’s page under docs/fields/. Each is
an element screenshot of one field, [data-layout-field], the layout’s
cell for it: its input on a demo record’s form, or its value on the
record page for a field no form edits (Id, Computed, HasOne,
HasMany). Input add-ons such as writing help are hidden, so the images
do not depend on the AI provider. The support desk’s records are named
by id, like the shop’s, since a fresh seed numbers both from 1. To
capture only these:
docker compose run --rm -e VECTOR_SCREENSHOTS=1 e2e test tests/screenshots.standalone.spec.ts --grep "docs screenshots fields"
A page embeds a pair with the {figure} directive, not {image}:
sphinxcontrib-images replaces {image} with its lightbox, and a field’s
small image needs none. Both the figure’s :figclass: and the image’s
:class: carry only-light or only-dark: the first hides the whole
figure in the other theme, and the second keeps the dark theme from
dimming a dark image.
The capture itself drives the standalone admin at 1440×900, in English,
as e2e@vector.local. Both images of a pair come from one prepared page:
the spec switches the emulated prefers-color-scheme in place. This
relies on Settings → Branding → Default theme staying System. The
capture saves nothing: it cancels every dialog and form, and aborts and
fails on any request from the page that is not a read, except the
assistant’s, the plain-language filter’s and writing help’s own
requests, which change no record. The assistant’s proposal stays
pending: deciding it would be aborted. Review the changed images before
committing them.
Static analysis and builds#
docker compose exec app composer phpstan
docker compose exec app vendor/bin/kinetis build
docker compose exec node pnpm lint
docker compose exec node pnpm --filter frontend generate
PHPStan runs at level 8 over the demo, packages/vector/src and
packages/vector-ai/src (phpstan.monorepo.neon, which includes the
published demo’s phpstan.neon and adds the packages), with three Kinetis rules and kinetis/neuron’s
NoWorkerUnsafeNeuronRule, which flags the Neuron features that block,
fork or keep state in a worker. NoStaticPropertiesRule flags a static property,
which outlives every request a worker handles; NoBlockingIoRule flags
a call that blocks the event loop instead of yielding;
NoProcessGlobalsRule flags exit and die, the request superglobals,
and the SAPI header, cookie and session functions, all of which bypass
the PSR-7 request and response. tests/bootstrap.php is exempt from the
superglobal check, because it sets each test worker’s environment before
boot. The rules catch three specific mistakes; they do not prove a change
is correct on a persistent worker.
docker compose exec app composer psalm # Psalm, types and taints; writes backend/psalm.sarif
Psalm covers the demo’s src/ and migrations/,
packages/vector/src and packages/vector-ai/src (psalm.monorepo.xml;
the published demo’s psalm.xml covers its own two), at its level 7 (Psalm’s 1 is its strictest).
Psalm 7 checks types and taints in one run. Request input reaches this
code through PSR-7 and the framework’s hydration, and SQL runs through
Kinetis’s own links. Psalm knows neither as a taint source or sink, so a
clean taint run only covers flows from PHP’s own sources to PHP’s own
sinks. Overriding and implementing methods carry #[\Override], and
Psalm enforces it.
Mutation testing#
docker compose exec app composer infection:workers # the workers' databases, first
docker compose exec app composer infection # the demo's src/, the longest run
docker compose exec app composer infection:vector # Vector's Registry and Query
docker compose exec app composer infection:queues # Vector's queue dashboard, src/Queues/
Infection runs the PHPUnit suite against each mutant and fails below the
minMsi and minCoveredMsi floors in backend/infection.json5,
backend/infection.vector.json5 and
backend/infection.queues.json5. The last runs only the queue
dashboard’s tests (tests/Vector/Queues).
infection runs PHPUnit on backend/phpunit.xml, the published demo’s,
whose <source> is the demo’s src/ alone. infection:vector and
infection:queues run it on backend/phpunit.monorepo/phpunit.xml
(their phpUnit.configDir), the same configuration with Vector’s
sources in <source>: Infection keeps that element as it is for its
initial run, so a source directory it leaves out has no coverage and
none of its mutants run. The monorepo file is export-ignored; keep the
rest of it in step with backend/phpunit.xml.
The mutated tests write to the databases, so each Infection worker runs
on stores of its own. Infection numbers its worker processes in
TEST_TOKEN, and when that is set backend/tests/bootstrap.php points
worker N at the MySQL database vector_N, the PostgreSQL databases
vector_admin_N and vector_support_N, Redis databases 2N (the cache)
and 2N+1 (the jobs queue) and a temporary directory of its own
(backend/tests/worker-stores.php). composer infection:workers drops,
recreates, migrates and seeds those databases for workers 1 to 4, as root
on MySQL; run it before each mutation-testing run. Without
TEST_TOKEN (PHPUnit on its own, and Infection’s initial run of the
suite) the tests use the base databases.
infection:vector and infection:queues run four workers.
infection runs one, on worker 1’s stores: its whole suite includes
tests that share state outside them. None of these runs touches the base
databases beyond what PHPUnit itself does, but all of them still need them
seeded, so run them one at a time, never beside PHPUnit or the
end-to-end suite. A killed mutant stops its test before the test puts its
rows back, so afterwards a worker’s databases can hold missing order
lines, changed product prices and stock, a leftover hosted-test tag,
and, in Vector’s own tables, a store lowStockThreshold of 0 and saved
product views; composer infection:workers starts them over.
The reports go to backend/infection.log, backend/infection.vector.log
and backend/infection.queues.log, each with a .summary.log
beside it.
Infection stops its initial run of the suite at the first line the suite
writes to STDERR, and reports PHPUnit’s exit code as 143, the SIGTERM it
sent. The queue dashboard’s worker tests fail jobs on purpose, and the
framework’s development logger writes each failure through
error_log(), which the CLI sends to STDERR. So
infection.queues.json5 sets initialTestsPhpOptions to
-d error_log=/dev/null for that run. Do the same for any config whose
tests log.
pnpm lint runs ESLint over every TypeScript and Vue file in the
workspace: the UI layer and its hosted app, the demo frontend and the
end-to-end suite. One flat config at the repository root,
eslint.config.mjs, uses @nuxt/eslint-config on its own, so linting
needs no nuxt prepare. Each package also has its own pnpm lint
against that config. TypeScript is pinned to ~6.0.3 because
typescript-eslint supports TypeScript only below 6.1.
Continuous integration#
The workflows in .github/workflows/ run on pushes to main and on
pull requests, each for the paths it covers:
ci.yml: one job per PHP version (8.4, 8.5) and placement of Vector’s tables (MySQL, PostgreSQL), each in the demo’s own PHP image with MySQL, PostgreSQL and Redis as services:composer validate --strictfor the packages’ and the demo’scomposer.jsonfiles,composer audit, and the PHPUnit suite on that placement (as above); the MySQL jobs also run PHPStan and Psalm (one run, ordinary and taint issues together). One more job on PHP 8.4 removeskinetis/queue-failed-jobsfrom the demo, boots Vector without it and runsFailedJobsNotInstalledTest, along with the queue tests that need nothing of that package;pnpm lint,pnpm typecheck,pnpm test,pnpm test:scripts, andpnpm generate:hostedfollowed bynode scripts/check-vector-ui-pack.mjs --packed, which fails unless npm would packvector-bundle.jsonand every file it lists;node scripts/validate-docs-catalogue.mjsand the strict build of this manual; and the published demo on its own:git archiveofdemo/(the tree its mirror is split to, less whatdemo/.gitattributesexport-ignores) extracted outside the checkout, itscomposer.jsonvalidated, installed without a lock with this commit’s two packages as path repositories at their manifest versions, then migrated, seeded and run through its own PHPUnit, PHPStan and Psalm. Any path from the demo into the rest of the repository fails it.monorepo-validate.yml:node scripts/validate-monorepo.mjs: noApp\reference underpackages/, and nothing the published demo ships reaching outsidedemo/.versions.yml:node scripts/validate-versions.mjs: a pull request that changes files underpackages/vectorbumpsvectorinpackages.manifest.jsonby one step, withnode scripts/bump.mjs. One that changes files underpackages/vector-uibumps bothvector-uiandvector, sincekinetis/vectorpins the UI release (packages/vector/resources/ui.json, whichbump.mjs vector-uimoves). Any change underpackages/vector,packages/vector-ai,packages/vector-uiordemo/bumpsvector-demotoo, which includes every package’s path; see Releasing.infection.yml:composer infection:workers, thencomposer infection:vectororcomposer infection:queues, when Vector’s Registry, Query or Queues or the mutation setup changes, and on a push tomainthat changespackages.manifest.json(a version bump, which the release gate waits on); the mutated files are split over parallel jobs, each passing floors of its own and, for Registry and Query,--filter. The queue dashboard is one job of its own.sonarqube.yml: the PHPUnit suite under pcov, its coverage ofpackages/vector/srcreported to SonarQube Cloud with its quality gate.semgrep.yml: Semgrep SAST;.semgrepignorelists the reviewed false positives.
deploy-docs.yml publishes this manual to kinetis.dev/vector/docs/
when docs/ changes on main.
Adding, removing, moving or retitling a page under docs/ changes its
entry in docs/_extra/catalogue.json in the same pull request: its
path, title, a one-line description and the package that owns it.
node scripts/validate-docs-catalogue.mjs fails until they agree; the
rules are in
Monorepo tags and the docs catalogue.
release.yml publishes from main only after its gate,
scripts/release-gate.mjs, has seen every workflow above pass on the
release commit’s push to main; release.yml and deploy-docs.yml
are the only workflows it does not wait for. A new workflow must be
added to the gate’s REQUIRED_WORKFLOWS or EXCLUDED_WORKFLOWS, or
pnpm test:scripts fails. See Releasing.
See also#
The demo application: the stack and its services.
AI coding agents: the same work with an AI coding agent.