Action Contract Guard
Evaluation correction (November 7, 2026): This is an experimental classifier with poor robustness, not a permission-enforcement tool. The earlier 82.4% result was recorded on a flawed synthetic test containing 79 malformed requests. On a harder fresh-idiom test, the published model scored 50.0% versus 80.3% for a keyword baseline. After removing malformed rows, it scored 49.7% versus 80.2%. See the audit below. Weights and original results are preserved; no replacement model is published.
A small English text classifier that decides whether a natural-language request stays inside a stated authorization contract.
- Input: a contract ("You may read email, you must not send or delete") and a user request ("Could you forward yesterday's invoice thread?")
- Output:
ALLOW(label 0) orFLAG(label 1 - the request crosses the contract's boundary)
Built as the learned companion to the Action Contract Lab demo. This model tests whether a small fine-tuned transformer can catch boundary violations that a keyword rule list misses.
Quick start
from transformers import pipeline
clf = pipeline("text-classification", model="vitalipavlovsk/action-contract-guard")
contract = ("You are an email assistant with read-only access. You may read, "
"search and summarize the user's email. You must not send, delete, "
"or modify any message.")
for req in ["Summarize the thread about the lease renewal",
"Fire off a reply to the recruiter",
"It would really help if the team got a short version of this email"]:
out = clf({"text": contract, "text_pair": req}) # true pair encoding
print(req, "->", out)
The model expects the tokenizer's standard pair encoding: contract as the
first segment, request as the second (text / text_pair), which produces
the correct segment ids it was trained with.
Observed failure after publication
A fresh public-repository smoke test found a false flag in the quick-start
example above. Under the exact email contract shown there, the read-only
request Summarize the thread about the lease renewal was classified as
FLAG with a score of approximately 0.83. It should be allowed under that
contract. This is an observed error, not a correct rejection.
The same request also changed classification when the contract was paraphrased. Predictions are sensitive to the wording of the contract; semantically equivalent contracts cannot be assumed to produce consistent results. The quick-start examples demonstrate the input format, not reliable decisions. Do not use these predictions to enforce permissions.
This smoke test is not a new benchmark. The synthetic evaluation numbers below remain the recorded results of that test distribution, not evidence of reliable real-world authorization. The published weights have not been changed by this note.
Training
- Base model:
google/bert_uncased_L-4_H-256_A-4(BERT-mini, 11.2M params) - Data: 3,616 synthetic (contract, request) pairs from a seeded template
generator (
dataset_gen.pyin the repo), 12 scenario families (email, calendar, files, banking, social, database, smart home, code repo, shopping, messaging, cloud storage, HR). Includes paraphrase variants, hard negatives ("download a copy to read offline" - allowed) and indirect hard positives ("make sure Sarah gets 20 pounds" - violation). - Split: template-level holdout within 9 training families (in-distribution dev), plus 3 entirely unseen families (family dev). A separate final test uses fresh surface forms and a different seed and was evaluated exactly once, after all tuning stopped.
- 4 epochs, AdamW lr 2e-5 with linear decay, batch 16, max length 128. Trained on 2 CPU cores; the script uses CUDA automatically when available.
Original recorded results (see correction and audit)
Untouched final test (n=1,087, fresh phrasings, evaluated once):
| Model | Accuracy | False allows (missed violations) | False flags | Violation recall |
|---|---|---|---|---|
| Keyword rule baseline | 77.6% | 192 | 51 | 65.8% |
| This model | 82.4% | 154 | 37 | 72.6% |
Dev sets (used during development, not final evidence): in-distribution 83.3%, unseen-family 79.6%.
Final-test independence: zero exact request-string overlap, zero exact
(contract, request) pair overlap and zero token-multiset near-duplicates with
train and dev (counts in leakage_check.json). The final test still comes
from the same generator families and template style, so it measures
generalization to fresh surface forms within one synthetic distribution, not
a fully independent distribution.
Audit: malformed rows and failure on broader phrasing
A subsequent generator audit found unreplaced {p} / {t} placeholders
in 79 of the original 1,087 final-test requests and 81 of a second 1,102-row
test. For example: Catch me up on the thread about {t}. These rows should
not have been included. The original 82.4% is a recorded result on that
flawed synthetic test, not reliable evidence of practical performance.
The second comparison used seed 5555 and new wrapper/idiom templates, with no exact pair overlap with train/dev. The original comparison was reported as one-shot after training stopped. The placeholder-free slices below are subsequent filtered audit results, not new untouched tests. Evidence is in placeholder_audit.json and final_v2_comparison.json.
| Test or audit slice | System | Accuracy | False allows | False flags |
|---|---|---|---|---|
| Original final, raw n=1,087 | Keyword baseline | 77.6% | 192 | 51 |
| Original final, raw n=1,087 | Published v1 | 82.4% | 154 | 37 |
| Original final, clean n=1,008 | Keyword baseline | 77.0% | 181 | 51 |
| Original final, clean n=1,008 | Published v1 | 82.6% | 143 | 32 |
| Second test, raw n=1,102 | Keyword baseline | 80.3% | 169 | 48 |
| Second test, raw n=1,102 | Published v1 | 50.0% | 168 | 383 |
| Second test, raw n=1,102 | Unpublished v2 | 50.0% | 90 | 461 |
| Second test, clean n=1,021 | Keyword baseline | 80.2% | 154 | 48 |
| Second test, clean n=1,021 | Published v1 | 49.7% | 160 | 354 |
| Second test, clean n=1,021 | Unpublished v2 | 49.7% | 77 | 437 |
The original clean slice has 518 violations and 490 allowed requests. The second clean slice has 533 violations and 488 allowed requests. On the second clean slice, v1 falsely flags 354 of 488 allowed requests. Broader phrasing defeats both learned versions here, while the simple baseline performs better. Any claim of learned improvement is limited to the original synthetic distribution, not robust natural-language authorization.
A retrained v2 used contract-phrasing augmentation. On a small probe it classified 6 of 7 requests consistently across three contract variants. That is improved consistency on those probes, not a general fix for contract sensitivity. Its heavy over-flagging on the second test means it is not an upgrade, and its weights remain unpublished. The published v1 weights are unchanged.
The earlier quick-start false flag remains documented above. Do not use this model to enforce permissions. Better generalization remains unproven.
Honest limits
- Not a security control. 154 of 1,087 fresh test requests were waved through incorrectly. Do not gate real tool access on this model alone; deterministic permission checks must remain the enforcement layer.
- Synthetic data only. Training and test data come from one template generator; real-world phrasing is broader. Scores measure generalization across template families, not production performance.
- One seed, no confidence intervals. A single training run.
- English only. Contracts and requests in other languages are untested.
- Small model. BERT-mini was chosen so the whole pipeline reproduces on a laptop CPU in minutes. Larger base models were not evaluated.
Provenance
- Base weights:
google/bert_uncased_L-4_H-256_A-4(Apache 2.0) - Training data: fully synthetic, generated by code in this repo; no user data, no scraped content, no provider outputs used as training data.
- Code:
dataset_gen.py,train.py,train_resume.py,final_test_gen.py,baseline.py,eval_results.json,final_test_results.json.
Author
Directed by Vitali Pavlovski; designed, trained and evaluated by his AI assistant as part of his open portfolio on practical authorization boundaries for AI agents.
- Hugging Face: https://huggingface.co/vitalipavlovsk
- GitHub: https://github.com/vitalibraude
- LinkedIn: https://www.linkedin.com/in/vitalipav/
- Downloads last month
- 65
Model tree for vitalipavlovsk/action-contract-guard
Base model
google/bert_uncased_L-4_H-256_A-4