Commit Graph
4 Commits
Author SHA1 Message Date
babasado 178e201e55 fix(cluster): bound admission work and release command locks promptly 2026-10-19 07:57:08 +02:00
Divarion_D 9e118da975 test: run the unit suite on MariaDB only, and on the panel's own stack
The suite ran on in-memory SQLite, an engine production never uses: it hid
column lengths, MySQL-only syntax and type coercion (the identity bug fixed in
the previous commit passed CI that way). SQLite is gone:

- TestDb connects only to MariaDB/MySQL (XCVM_TEST_DB_DSN/_USER/_PASS; root over
  the local socket, else 127.0.0.1:3306). Each instance gets a throwaway
  schema, dropped with it, in the installer's sql_mode, with an explicit
  connect timeout (a boot under test can zero default_socket_timeout).
- InstallSchema and the tests take the production DDL as is: the SQLite
  reducers, the keys they re-added, the faked information_schema and the
  sqliteCreateFunction() stand-ins are removed; test DDL is MySQL DDL.
- ReplicaBootTest, DbConnectRefusalTest and LazyDatabaseHandlerTest reach the
  test server instead of SQLite files; RecordingFinalizer no longer swallows
  an information_schema failure "for tests on SQLite".
- `make test-db` starts a throwaway mariadb:11.4 (tmpfs) for a machine without
  a server; the CI PHPUnit job gets the same as a service.

The suite also runs on a panel host with the bundled PHP and its own php.ini:
tests reach the code through MAIN_HOME, not `<repo>/src`; repository checks
and process-isolated tests (ionCube Loader + OPcache CLI segfault on a script
read from stdin) are in the skip-on-panel group; xcvm_test_child_php() starts
a child that fakes \XC_VM without the real extension; Redis-down tests use
RedisManager::useConnector() instead of an eval'd \XC_VM.

Stale opt-in tests fixed on the way: the real-agent provisioning test answers
the agent-started check, the extension integration test sends the typed starts
and reads the binary signature raw, a fake producer starts as PHP_BINARY, and
the certbot test waits for the line its background command writes.
2026-10-04 16:12:23 +03:00
obscuremind 38c3d2d061 fix(cluster): read keys, signatures and sealed records as stored
Database::get_row()/get_rows() pass every value through clean_row(), whose
HTML escaping (< > to entities, \r to \n) and trim() corrupt binary data.
The cluster read its node keys, epoch records, sealed tokens, enrol-code
keys and MACs, and command payloads and signatures that way, so:

- about half of all commands reached the agent with a signature that no
  longer verified ("refused: bad signature");
- an epoch record (up to 2 KB) almost always came back altered, so a node's
  first token could not be opened (TOKEN_EXPIRED, RECORD:epoch_record);
- a node whose signing or box key held one of those bytes could never
  authenticate or be sealed to.

Database gains get_raw_rows()/get_raw_row(), which return the rows as
stored, and every cluster read of a binary column or a signed document uses
them. The admin pages keep the escaped fetch.

TestDb now escapes like Database, so the tests see what production sees:
before this fix, 70 cluster tests failed under it.
2026-09-30 15:53:30 +00:00
Claude 0f260b8ceb fix(cluster): send commands the extension signs, and never lose one silently
- node.rpc and node.root carry action in the envelope, as the extension's
  registry requires; enqueue() lifts it out of the caller's payload, and
  cluster:exec, the root inbox and RootPin read it there.
- enqueue() checked nothing: Database::query() answers a refused INSERT
  with false, so a duplicate seq or dedupe_key returned a cmd_id for a
  row never stored and ClusterRoute reported success. It now checks the
  write, retries with a fresh seq, and throws after ATTEMPTS tries;
  ClusterRoute logs every command the channel does not take.
- tests/Support/cluster_commands.json is the extension's registry, pinned
  by digest; CommandBusRegistryTest builds every type MAIN sends and checks
  it against the file, and FakeClusterCrypto refuses what the extension
  refuses instead of signing anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rdv7hXd8RWhLHoj5Ma2ZqY
2026-09-28 11:50:10 +00:00