Skip to content

Run relationship worker only for queued evaluations - #725

Draft
RANGROO wants to merge 2 commits into
unstablefrom
codex/relationship-worker-efficiency
Draft

Run relationship worker only for queued evaluations#725
RANGROO wants to merge 2 commits into
unstablefrom
codex/relationship-worker-efficiency

Conversation

@RANGROO

@RANGROO RANGROO commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • remove relationship-worker supervision from foreground prompt construction
  • start the detached worker only after a relationship evaluation is successfully queued
  • apply the update-chance gate before listener/database/context work
  • stop creating retired initialization jobs and drain any pre-upgrade rows once at worker startup
  • reuse the relationship map already loaded for context filtering
  • remove per-iteration idle trace writes

Why

context_pre.php checked or launched the worker on every prompt. A cold live trace spent about 228 ms in that startup path before relationship context was built. The daemon also polled both evaluation and retired initialization queues every two seconds and appended two idle trace lines per loop.

Performance evidence

  • identical 500-iteration context benchmark against the live database: 0.4368 ms average on unstable, 0.2354 ms on this branch (about 46% lower)
  • deployed context probe: 3.293 ms, 588 context characters, and no worker process or PID file created
  • explicit deployed worker-start probe: 23.579 ms foreground call
  • deployed idle-daemon probe: 0 relationship-worker log bytes added over five seconds

Validation

  • PHP lint: all seven changed PHP files
  • PHPUnit: RelationshipTypeValidationTest.php — 13 tests, 37 assertions
  • git diff --check
  • static routing probes confirm prompt context does not start the worker, the chance gate precedes listener resolution, comm.php no longer queues retired initialization, and the steady daemon loop is evaluation-only
  • deployed source/runtime SHA-256 hashes match for all six runtime files
  • deployed runtime PHP lint passes for all six runtime files
  • local HerikaServer settings endpoint returns HTTP 200
  • live relationship evaluation and initialization queues were empty before and after the probes

Local deployment

Deployed the six runtime PHP files from branch tip fef3aa7795753145177215bdbe0f774d5168d2b6 to /var/www/html/HerikaServer. Apache was stopped only for the file copy and is healthy afterward. Configuration, databases, logs, caches, uploads, and CHIM client artifacts were not replaced.

Compatibility and overlap

  • no schema migration or version bump
  • existing relationship state remains prompt-visible even when automatic updates are skipped
  • HerikaServer keeps one-time compatibility draining for old initialization rows
  • StobeServer and DialecticServer were not changed because their legacy initialization flows still perform meaningful conversion work
  • path overlap with PRs Ground Soulgaze narration and report capture status #709 and ✅ Add multi-NPC Background Life combat and loot #690 was reviewed; their overlapping async_queue.php / processor/comm.php hunks concern retry/Soulgaze and Background Life behavior, not this retired-init removal

Known limits

  • no in-game conversation or live Relationship LLM evaluation was triggered
  • broader HistoricContextTest / CommTest database suites are blocked on both unstable and this branch by the existing sql::escapeLiteral() failure in debug/db_updates.php

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