feat(events): a trigger can start a run
Rust PLAN_REDESIGNS §14.3.12 (D370), stage 9 of §14.3. A definition's published version may carry `starts`: a trigger, a condition and a cooldown. A matching firing creates a run of it, now. - spec: `starts` validated by the phase gate's own function (same grammar, same dormant rule; a dormant start refuses publish), a cooldown from 0m to 7d (30m default), at most ten, event.* refused. - events/starts.js: the emit path's third subscriber, beside dispatch and the gate observer. An unverified version starts nothing; one run at a time per definition and the cooldown are one conditional UPDATE on the new event_trigger_starts table; the occurrence key makes one firing reported twice one run. Ignored firings are counted by why. - event_runs.origin: the firing (trigger, label, time, subject, matched condition, declared variables), also on the run.created audit line. - Editor: a "Started by the game" panel using the gate's condition builder, with the ignored-firings line. Run console: "Started because ... fired". - No module contract change and no MODULE_API bump. Tests: eventStarts (server 21, client 8); eventRunnerSql +7 against a real MariaDB (75/75); Module-uo proof on uo.champ.boss_up against the dev database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
@@ -52,6 +52,9 @@ const resourcesDb = require('../src/model/events/eventRunResources.db')
|
||||
const participantsDb = require('../src/model/events/eventRunParticipants.db')
|
||||
const seriesDb = require('../src/model/events/eventSeries.db')
|
||||
const gatesDb = require('../src/model/events/eventPhaseGates.db')
|
||||
// Rust PLAN_REDESIGNS §14.3.12: the editor's shape reads the trigger-start state.
|
||||
// The same rule as every leg above, a fifth time.
|
||||
const triggerStartsDb = require('../src/model/events/eventTriggerStarts.db')
|
||||
const activity = require('../src/model/activity/activity.model')
|
||||
const db = require('../src/utils/db')
|
||||
|
||||
@@ -69,6 +72,7 @@ for (const [name, mod] of [
|
||||
['logDb', logDb],
|
||||
['seriesDb', seriesDb],
|
||||
['gatesDb', gatesDb],
|
||||
['triggerStartsDb', triggerStartsDb],
|
||||
['settingsDb', settingsDb],
|
||||
['budgetDb', budgetDb],
|
||||
['resourcesDb', resourcesDb],
|
||||
@@ -96,6 +100,7 @@ function installStubs() {
|
||||
log: [],
|
||||
series: new Map(),
|
||||
gates: [],
|
||||
triggerStarts: new Map(),
|
||||
settings: new Map(),
|
||||
budget: new Map(),
|
||||
resources: [],
|
||||
@@ -295,6 +300,7 @@ function installStubs() {
|
||||
// it merely made the file slow. Worth the comment: when the runner or a model
|
||||
// gains a leg, every file that stubs the layer under it needs the stub.
|
||||
gatesDb.listForRun = async (runId) => store.gates.filter((g) => g.run_id === runId)
|
||||
triggerStartsDb.forDefinition = async (id) => store.triggerStarts.get(id) || null
|
||||
|
||||
logDb.listForRun = async (runId) => store.log.filter((l) => l.run_id === runId).reverse()
|
||||
logDb.write = async ({ runId, stepId = null, kind, phase = null, detail = null }) => {
|
||||
|
||||
Reference in New Issue
Block a user