Context
Found while reviewing neomjs/neo-agent-brain#1086. TextEmbeddingService.configSnapshot needs a setter that validates and throws on a live config. A reactive configSnapshot_ could not host that setter: after the throw, the rejected value is the config's value. Brain therefore carries plain accessors in a shared seam (neomjs/neo-agent-brain#1092), partly for this reason. It was first captured as a defect-note on 2026-10-17.
The Problem
A reactive config whose beforeSet hook rejects by throwing keeps the rejected value. Probe on Neo 13.1.0 in Node:
class Probe extends Neo.core.Base {
static config = {className: 'Probe.ThrowingBeforeSet', foo_: null}
beforeSetFoo(value) { if (value === 'bad') throw new TypeError('rejected'); return value }
}
Neo.setupClass(Probe);
const p = Neo.create(Probe);
p.foo = 'good';
try { p.foo = 'bad' } catch {}
p.foo Any validation-by-throw on a reactive config is unsafe today, so consumers route around reactive configs. That is the opposite of what the class system is for.
The Architectural Reality
- The generated setter in
src/Neo.mjs (autoGenerateGetSet, dev e0704c93bb) works in three steps:
- Step 2 writes the candidate to the private backing property ("Create a temporary state for beforeSet hooks"), which reaches
Config#setRaw.
- Step 3 reverts it ("Restore state for change detection").
- The revert runs after the hook returns, and on the
undefined cancel path.
- The surrounding
try has only a finally, which resumes the EffectManager. A throw from beforeSet<Key> therefore skips both reverts, and the getter (me[_key] → config.get()) returns the candidate.
- Design authority,
src/core/Base.mjs config-hook JSDoc: "beforeSetMyConfig(newValue, oldValue): Executed before a new value is set. Can be used for validation or transformation. Returning undefined from this hook will cancel the update." The setter's own comments call the step-2 write a temporary state.
The Fix
In the generated setter, when beforeSet<Key> throws, restore the backing property to oldValue and rethrow the same error. No afterSet runs and no subscriber is notified, matching the cancel path except that the caller sees the error.
Acceptance Criteria
Out of Scope
- Transactional
set({a, b}), where configs applied before a later throw stay applied. That is a separate question.
- Brain's plain accessors (neomjs/neo-agent-brain#1092). They stay valid; this fix makes a reactive slot possible again, not required.
Related
neomjs/neo-agent-brain#1086 · neomjs/neo-agent-brain#1092
Live latest-open sweep: checked the latest 20 open neo issues at 2026-10-18T01:37:47Z; no equivalent ("beforeSet throw", "beforeSet validation", "setter restore throw": no hits). A2A in-flight sweep: the last 12 messages, all statuses; no overlapping claim. Memory Core rationale sweep: no prior decision. Own assignments: none on this surface.
Origin Session ID: 71ff10c1-2fda-4f34-ad65-7d53bf3d2ef8
Retrieval Hint: "reactive config beforeSet throws rejected value installed setRaw restore"
Context
Found while reviewing neomjs/neo-agent-brain#1086.
TextEmbeddingService.configSnapshotneeds a setter that validates and throws on a live config. A reactiveconfigSnapshot_could not host that setter: after the throw, the rejected value is the config's value. Brain therefore carries plain accessors in a shared seam (neomjs/neo-agent-brain#1092), partly for this reason. It was first captured as a defect-note on 2026-10-17.The Problem
A reactive config whose
beforeSethook rejects by throwing keeps the rejected value. Probe on Neo 13.1.0 in Node:class Probe extends Neo.core.Base { static config = {className: 'Probe.ThrowingBeforeSet', foo_: null} beforeSetFoo(value) { if (value === 'bad') throw new TypeError('rejected'); return value } } Neo.setupClass(Probe); const p = Neo.create(Probe); p.foo = 'good'; try { p.foo = 'bad' } catch {} p.foo // 'bad'Any validation-by-throw on a reactive config is unsafe today, so consumers route around reactive configs. That is the opposite of what the class system is for.
The Architectural Reality
src/Neo.mjs(autoGenerateGetSet, deve0704c93bb) works in three steps:Config#setRaw.undefinedcancel path.tryhas only afinally, which resumes the EffectManager. A throw frombeforeSet<Key>therefore skips both reverts, and the getter (me[_key]→config.get()) returns the candidate.src/core/Base.mjsconfig-hook JSDoc: "beforeSetMyConfig(newValue, oldValue): Executed before a new value is set. Can be used for validation or transformation. Returningundefinedfrom this hook will cancel the update." The setter's own comments call the step-2 write a temporary state.The Fix
In the generated setter, when
beforeSet<Key>throws, restore the backing property tooldValueand rethrow the same error. NoafterSetruns and no subscriber is notified, matching the cancel path except that the caller sees the error.Acceptance Criteria
beforeSetthat throws leaves the previous value readable, rethrows the same error, and runs noafterSet.undefined) and the transform path are unchanged, and the existing core class-system suites stay green.test/playwright/unit/core/ClassSystem.spec.mjsis red on dev and green with the fix.Out of Scope
set({a, b}), where configs applied before a later throw stay applied. That is a separate question.Related
neomjs/neo-agent-brain#1086 · neomjs/neo-agent-brain#1092
Live latest-open sweep: checked the latest 20 open neo issues at 2026-10-18T01:37:47Z; no equivalent ("beforeSet throw", "beforeSet validation", "setter restore throw": no hits). A2A in-flight sweep: the last 12 messages, all statuses; no overlapping claim. Memory Core rationale sweep: no prior decision. Own assignments: none on this surface.
Origin Session ID: 71ff10c1-2fda-4f34-ad65-7d53bf3d2ef8 Retrieval Hint: "reactive config beforeSet throws rejected value installed setRaw restore"