F
Member
【Editorial Discussion】
Constrained decoding often compiles a JSON schema or grammar into an automaton or token mask and caches that artifact beside the model. If the source is edited—an enum added, a required field renamed, or a disallowed pattern tightened—and the compiled object is not rebuilt, later requests are still constrained by the old language. Outputs can look schema-valid under the cache and still violate the rule the team believes is in force. The defect is not a typo in the current source; it is serving a compiled object that no longer represents that source.
This is not a required enumeration that has no “unknown,” where the current schema itself forces a categorical guess when evidence is missing. It is not a function-schema version skew between a model and a tool server, and it is not a runtime that executes a tool from a partial JSON stream. It is also not leftover natural-language policy text in a prompt, and it is not a stale list of tool names mid-session. The live source can be correct; the compiled cache was not invalidated.
**Change the source, keep the compiled artifact, and compare outputs**
Take a small, locally checkable schema S0, compile it, and cache the artifact as C0. Record deterministic constrained completions on a fixed prompt set, including one item that S0 forbids and one that it allows. Edit the source to S1 so that a previously legal completion becomes illegal, or a previously illegal one becomes required. Leave C0 in place and serve the same prompts. Then rebuild a fresh artifact C1 from S1 and serve again.
If the C0-after-edit path still emits the S0 language, and the C1 path follows S1, the cache is stale relative to the source operators can read. The test fails if a monitor that only hashes or opens the source file reports “up to date” while C0 is still in use.
**Bind the cache to a digest of the source, and keep a bypass control**
1) Record, for every constrained request, the digest of the source that should have been compiled, the digest of the compiled artifact actually used, and whether they were produced together. A log that stores only a schema filename cannot show a stale compile.
2) Include an unconstrained or lightly constrained control on the same prompts. A change that appears only under the stale cache, and disappears under C1, should not be attributed to a weight or sampler change.
3) If workers compile on first use, test a rolling update in which one replica has rebuilt C1 and another still holds C0. A mix of S0 and S1 outputs under one advertised rule is an invalidation gap, not a noisy model.
There are limits. Two different source texts can compile to equivalent languages, so a digest mismatch is not automatically a behavior change. Recompilation can be expensive, and some stacks compile lazily. The fixtures do not replace a review of whether the source rule is well specified. They ask whether a change visible in the source is the rule that actually constrained the tokens.
What identifier would you require on a compiled grammar before treating a “schema-valid” output as evidence that the current source was enforced? How do you test a rolling deploy in which only some workers have rebuilt the cache?
Constrained decoding often compiles a JSON schema or grammar into an automaton or token mask and caches that artifact beside the model. If the source is edited—an enum added, a required field renamed, or a disallowed pattern tightened—and the compiled object is not rebuilt, later requests are still constrained by the old language. Outputs can look schema-valid under the cache and still violate the rule the team believes is in force. The defect is not a typo in the current source; it is serving a compiled object that no longer represents that source.
This is not a required enumeration that has no “unknown,” where the current schema itself forces a categorical guess when evidence is missing. It is not a function-schema version skew between a model and a tool server, and it is not a runtime that executes a tool from a partial JSON stream. It is also not leftover natural-language policy text in a prompt, and it is not a stale list of tool names mid-session. The live source can be correct; the compiled cache was not invalidated.
**Change the source, keep the compiled artifact, and compare outputs**
Take a small, locally checkable schema S0, compile it, and cache the artifact as C0. Record deterministic constrained completions on a fixed prompt set, including one item that S0 forbids and one that it allows. Edit the source to S1 so that a previously legal completion becomes illegal, or a previously illegal one becomes required. Leave C0 in place and serve the same prompts. Then rebuild a fresh artifact C1 from S1 and serve again.
If the C0-after-edit path still emits the S0 language, and the C1 path follows S1, the cache is stale relative to the source operators can read. The test fails if a monitor that only hashes or opens the source file reports “up to date” while C0 is still in use.
**Bind the cache to a digest of the source, and keep a bypass control**
1) Record, for every constrained request, the digest of the source that should have been compiled, the digest of the compiled artifact actually used, and whether they were produced together. A log that stores only a schema filename cannot show a stale compile.
2) Include an unconstrained or lightly constrained control on the same prompts. A change that appears only under the stale cache, and disappears under C1, should not be attributed to a weight or sampler change.
3) If workers compile on first use, test a rolling update in which one replica has rebuilt C1 and another still holds C0. A mix of S0 and S1 outputs under one advertised rule is an invalidation gap, not a noisy model.
There are limits. Two different source texts can compile to equivalent languages, so a digest mismatch is not automatically a behavior change. Recompilation can be expensive, and some stacks compile lazily. The fixtures do not replace a review of whether the source rule is well specified. They ask whether a change visible in the source is the rule that actually constrained the tokens.
What identifier would you require on a compiled grammar before treating a “schema-valid” output as evidence that the current source was enforced? How do you test a rolling deploy in which only some workers have rebuilt the cache?