- 3001
- 3002
/// The live bug: every writing request tripped the agent's stop gate, - 3003
/// because `OutcomeSpec::requires_execution` returned true for any - 3004
/// `Act::Author` reading and `vak-agent`'s stop policy reads - 3005
/// `spec.stop == StopProfile::Effect || spec.requires_execution()`. - 3006
/// Authoring content — a poem, an email, a summary, a plan, prose of any - 3007
/// length — must not demand a bash or file-modification receipt, and its - 3008
/// stop profile must not be `Effect` or `Verification`. - 3009
#[test] - 3010
fn authoring_prose_does_not_require_an_execution_receipt() { - 3011
for prompt in [ - 3012
"write a short poem about the sea", - 3013
"draft an email to my landlord asking to fix the heater", - 3014
"write a summary of this article", - 3015
"Write a lot.", - 3016
] { - 3017
let intent = resolve_text(prompt); - 3018
let spec = OutcomeSpec::from_intent(prompt, &intent); - 3019
assert!( - 3020
!spec.requires_execution(), - 3021
"{prompt:?}: acts={:?} expects_saved_file={} should not require execution", - 3022
spec.acts, - 3023
spec.expects_saved_file() - 3024
); - 3025
assert_ne!( - 3026
spec.stop, - 3027
StopProfile::Effect, - 3028
"{prompt:?}: stop profile should not be Effect" - 3029
); - 3030
assert_ne!( - 3031
spec.stop, - 3032
StopProfile::Verification, - 3033
"{prompt:?}: stop profile should not be Verification" - 3034
); - 3035
} - 3036
} - 3037
- 3038
/// The one case authoring genuinely needs a receipt: the request names a - 3039
/// file deliverable outright. `Act` alone cannot see this — only - 3040
/// `OutcomeSpec`, which has the request text via `expects_saved_file`. - 3041
#[test] - 3042
fn authoring_with_a_named_file_target_requires_an_execution_receipt() { - 3043
let prompt = "write a Python script that parses logs and save it as parse.py"; - 3044
let intent = resolve_text(prompt); - 3045
let spec = OutcomeSpec::from_intent(prompt, &intent); - 3046
assert!(spec.expects_saved_file(), "acts={:?}", spec.acts); - 3047
assert!(spec.requires_execution()); - 3048
} - 3049
- 3050
/// Genuinely effectful work and verification are unaffected by the - 3051
/// authoring fix: they must keep demanding an execution receipt. - 3052
#[test] - 3053
fn effectful_and_verification_requests_still_require_execution() { - 3054
for prompt in [ - 3055
"fix the failing test", - 3056
"deploy the billing service to production", - 3057
"rename the config key in settings.toml", - 3058
] { - 3059
let intent = resolve_text(prompt); - 3060
let spec = OutcomeSpec::from_intent(prompt, &intent); - 3061
assert!( - 3062
spec.requires_execution(), - 3063
"{prompt:?}: acts={:?} should still require execution", - 3064
spec.acts - 3065
); - 3066
} - 3067
} - 3068
- 3069
/// `Orchestrate` mirrors `Author`: dispatching a worker is proven by a tool - 3070
/// call, not a shell command or a file write, so it must not demand an - 3071
/// execution receipt — but unlike a plain answer it still must demand *some* - 3072
/// tool call, or a claimed delegation with nothing dispatched would pass. - 3073
#[test] - 3074
fn orchestrate_requires_a_tool_but_not_an_execution_receipt() { - 3075
let reading = Reading { - 3076
act: Act::Orchestrate, - 3077
..Reading::general() - 3078
}; - 3079
let spec = OutcomeSpec::from_reading("delegate this across three workers", &reading, 1); - 3080
assert!(!spec.requires_execution()); - 3081
assert!(spec.requires_tool()); - 3082
} - 3083
- 3084
// ================================================================ - 3085
// Part 16: Resolution determinism and reproducibility - 3086
// ================================================================ - 3087
- 3088
#[test] - 3089
fn resolution_is_deterministic_across_runs() { - 3090
let cases = &[ - 3091
"hello", - 3092
"deploy to production", - 3093
"fix the bug and send me a report", - 3094
"what is the meaning of life the universe and everything", - 3095
"analyze the logs and find the error", - 3096
]; - 3097
for text in cases { - 3098
let a = resolve_text(text); - 3099
let b = resolve_text(text); - 3100
assert_eq!(a, b, "resolution not deterministic for `{}`", text); - 3101
} - 3102
} - 3103
- 3104
#[test] - 3105
fn resolution_tier_reproducibility() { - 3106
let declared = Declared { - 3107
act: Some(Act::Modify), - 3108
..Declared::default() - 3109
}; - 3110
let intent = resolve_declared("hello", &declared); - 3111
// Partial declaration (only act) → coverage < 1.0 → Signals tier. - 3112
// Full declaration of all four axes is required for Declared tier. - 3113
assert_eq!(intent.provenance.tier, Tier::Signals); - 3114
assert!(intent.provenance.reproducible); - 3115
- 3116
let intent = resolve_text("zorble frobnicate xyzzy"); - 3117
assert_eq!(intent.provenance.tier, Tier::General); - 3118
assert!(intent.provenance.reproducible); - 3119
- 3120
let intent = resolve_text("deploy to production"); - 3121
if intent.provenance.tier == Tier::Signals { - 3122
assert!(intent.provenance.reproducible); - 3123
} - 3124
} - 3125
- 3126
#[test] - 3127
fn resolution_note_reaches_model() { - 3128
let intent = resolve_text("deploy to production"); - 3129
assert!( - 3130
intent.model_visible().is_some() || intent.engagement.posture.note.is_none(), - 3131
"irreversible work should produce a model-visible note" - 3132
); - 3133
} - 3134
- 3135
// ================================================================ - 3136
// Part 17: Domain and capability slicing - 3137
// ================================================================ - 3138
- 3139
#[test] - 3140
fn slicing_keeps_orientation_floor() { - 3141
let r = reading_simple( - 3142
Act::Converse, - 3143
Horizon::Immediate, - 3144
Stakes::Inert, - 3145
Evidence::None, - 3146
); - 3147
let engagement = derive(&r, &Authority::default(), true); - 3148
for domain in vak_intent::FLOOR_DOMAINS.iter() { - 3149
assert!( - 3150
engagement.limits.required_domains.contains(domain), - 3151
"floor domain `{}` must survive slicing", - 3152
domain - 3153
); - 3154
} - 3155
} - 3156
- 3157
#[test] - 3158
fn slicing_withheld_gives_the_orientation_floor() { - 3159
let r = reading_simple( - 3160
Act::Converse, - 3161
Horizon::Immediate, - 3162
Stakes::Inert, - 3163
Evidence::None, - 3164
); - 3165
let engagement = derive(&r, &Authority::default(), false); - 3166
assert_eq!( - 3167
engagement.limits.required_domains, - 3168
Engagement::orienting().limits.required_domains - 3169
); - 3170
} - 3171
- 3172
#[test] - 3173
fn below_floor_confidence_gives_the_orientation_floor() { - 3174
let resolution = resolve( - 3175
&req("zorble frobnicate"), - 3176
&Declared::default(), - 3177
&Authority::default(), - 3178
&ResolverConfig::default(), - 3179
); - 3180
let intent = resolution.intent(); - 3181
assert_eq!(intent.provenance.tier, Tier::General); - 3182
assert_eq!( - 3183
intent.engagement.limits.required_domains, - 3184
Engagement::orienting().limits.required_domains - 3185
); - 3186
} - 3187
- 3188
/// `DomainSet::All` has exactly one meaning — everything — and only a - 3189
/// disabled kernel produces it. - 3190
#[test] - 3191
fn only_a_disabled_kernel_is_unconstrained() { - 3192
let config = ResolverConfig { - 3193
enabled: false, - 3194
..ResolverConfig::default() - 3195
}; - 3196
let intent = resolve( - 3197
&req("zorble frobnicate"), - 3198
&Declared::default(), - 3199
&Authority::default(), - 3200
&config, - 3201
) - 3202
.intent(); - 3203
assert!(intent.engagement.limits.required_domains.is_unconstrained()); - 3204
} - 3205
- 3206
// ================================================================ - 3207
// Part 18: Capacity is never capped by a reading - 3208
// ================================================================ - 3209
- 3210
/// A reading decides which tools are loaded, never what is possible. The - 3211
/// route ladder, the turn count and the worker budget are not part of the - 3212
/// lattice at all, so no reading — right or wrong — can take them away; the - 3213
/// only limits a reading carries are authority-bearing ones. - 3214
#[test] - 3215
fn a_reading_carries_no_capacity_limit() { - 3216
for &act in &Act::ALL { - 3217
for &horizon in &Horizon::ALL { - 3218
let r = reading_simple(act, horizon, Stakes::Inert, Evidence::None); - 3219
let limits = derive(&r, &Authority::default(), true).limits; - 3220
assert_eq!( - 3221
limits.spend_ceiling_usd, None, - 3222
"{act:?}/{horizon:?}: no spend cap without a grant" - 3223
); - 3224
assert_eq!( - 3225
limits.permission_ceiling, - 3226
PermissionCeiling::FullAccess, - 3227
"{act:?}/{horizon:?}: no permission cap without a grant" - 3228
); - 3229
} - 3230
} - 3231
} - 3232
- 3233
// ================================================================ - 3234
// Part 19: Act is_effectful classification - 3235
// ================================================================ - 3236
- 3237
#[test] - 3238
fn act_is_effectful_classification() { - 3239
assert!(!Act::Converse.is_effectful()); - 3240
assert!(!Act::Answer.is_effectful()); - 3241
assert!(!Act::Locate.is_effectful()); - 3242
assert!(!Act::Analyze.is_effectful()); - 3243
assert!(!Act::Author.is_effectful()); - 3244
assert!(Act::Modify.is_effectful()); - 3245
assert!(Act::Operate.is_effectful()); - 3246
assert!(Act::Govern.is_effectful()); - 3247
// Verify and Orchestrate are not effectful — only Modify|Operate|Govern - 3248
// produce side-effects that matter for the stop profile. - 3249
assert!(!Act::Verify.is_effectful()); - 3250
assert!(!Act::Orchestrate.is_effectful()); - 3251
assert!(!Act::Author.is_effectful()); - 3252
} - 3253
- 3254
/// `requires_execution` is the bash-or-file-receipt gate the stop policy - 3255
/// reads (`spec.requires_execution()` in `vak-agent/src/stop_policy.rs`). - 3256
/// `Author` producing prose is proven by the response itself, so it is - 3257
/// absent; `Orchestrate` dispatching a worker is proven by a tool call - 3258
/// rather than a shell command or a file write, so it is absent too and - 3259
/// lives under `requires_tool` instead. `Verify` has no other way to be - 3260
/// proven than running the check, so it stays alongside the effectful acts. - 3261
#[test] - 3262
fn act_requires_execution_and_requires_tool_classification() { - 3263
for act in [Act::Modify, Act::Operate, Act::Govern, Act::Verify] { - 3264
assert!(act.requires_execution(), "{act:?} should require execution"); - 3265
assert!(act.requires_tool(), "{act:?} should require a tool"); - 3266
} - 3267
for act in [ - 3268
Act::Converse, - 3269
Act::Answer, - 3270
Act::Locate, - 3271
Act::Analyze, - 3272
Act::Author, - 3273
Act::Orchestrate, - 3274
] { - 3275
assert!( - 3276
!act.requires_execution(), - 3277
"{act:?} should not require an execution/file receipt" - 3278
); - 3279
} - 3280
// Orchestrate still needs proof that a worker or flow actually ran — - 3281
// just not specifically a shell command or a file write. - 3282
assert!(Act::Orchestrate.requires_tool()); - 3283
for act in [Act::Converse, Act::Answer, Act::Analyze, Act::Author] { - 3284
assert!(!act.requires_tool(), "{act:?} should not require a tool"); - 3285
} - 3286
assert!(Act::Locate.requires_tool()); - 3287
} - 3288
- 3289
#[test] - 3290
fn implied_stakes_visible_through_resolve() { - 3291
assert_eq!( - 3292
resolve_text("deploy the service").reading.stakes, - 3293
Stakes::Irreversible - 3294
); - 3295
// Governing the agent's own configuration is reversible; the permission - 3296
// engine and the privileged-config rules guard it. - 3297
assert_eq!( - 3298
resolve_text("configure the gateway").reading.stakes, - 3299
Stakes::Reversible - 3300
); - 3301
assert_eq!( - 3302
resolve_text("refactor the parser").reading.stakes, - 3303
Stakes::Reversible - 3304
); - 3305
assert_eq!(resolve_text("what is life").reading.stakes, Stakes::Inert); - 3306
assert_eq!( - 3307
resolve_text("find the config").reading.stakes, - 3308
Stakes::Inert - 3309
); - 3310
assert_eq!( - 3311
resolve_text("analyze the logs").reading.stakes, - 3312
Stakes::Inert - 3313
); - 3314
assert_eq!( - 3315
resolve_text("write a report").reading.stakes, - 3316
Stakes::Reversible - 3317
); - 3318
assert_eq!( - 3319
resolve_text("fix the bug").reading.stakes, - 3320
Stakes::Reversible - 3321
); - 3322
assert_eq!( - 3323
resolve_text("test the parser").reading.stakes, - 3324
Stakes::Reversible - 3325
); - 3326
} - 3327
- 3328
// ================================================================ - 3329
// Part 20: Prompt note and surface propagation - 3330
// ================================================================ - 3331
- 3332
#[test] - 3333
fn prompt_note_for_ambiguous_high_stakes() { - 3334
let mut r = reading_simple( - 3335
Act::Operate, - 3336
Horizon::Turn, - 3337
Stakes::Irreversible, - 3338
Evidence::None, - 3339
); - 3340
r.clarity = Clarity::Ambiguous; - 3341
let engagement = derive(&r, &Authority::default(), true); - 3342
let note = engagement.posture.note.as_deref().unwrap_or(""); - 3343
assert!( - 3344
note.contains("ask") || note.contains("question") || note.contains("ambiguous"), - 3345
"ambiguous high-stakes should mention asking: `{note}`" - 3346
); - 3347
} - 3348
- 3349
#[test] - 3350
fn prompt_note_for_state_assumption() { - 3351
let mut r = reading_simple(Act::Answer, Horizon::Turn, Stakes::Inert, Evidence::None); - 3352
r.clarity = Clarity::Ambiguous; - 3353
let engagement = derive(&r, &Authority::default(), true); - 3354
let note = engagement.posture.note.as_deref().unwrap_or(""); - 3355
assert!( - 3356
note.contains("under-specified") || note.contains("assumption"), - 3357
"under-specified should mention assumption: `{note}`" - 3358
); - 3359
} - 3360
- 3361
#[test] - 3362
fn prompt_note_for_deferred_work() { - 3363
let r = reading_simple( - 3364
Act::Operate, - 3365
Horizon::Durable, - 3366
Stakes::Costly, - 3367
Evidence::None, - 3368
); - 3369
let auth = authority_of(Autonomy::Delegated, Attendance::Unattended); - 3370
let engagement = derive(&r, &auth, true); - 3371
let note = engagement.posture.note.as_deref().unwrap_or(""); - 3372
assert!( - 3373
note.contains("Nobody") || note.contains("queued"), - 3374
"deferred work should mention nobody available: `{note}`" - 3375
); - 3376
} - 3377
- 3378
// ================================================================ - 3379
// Part 21: Modality requirements - 3380
// ================================================================ - 3381
- 3382
#[test] - 3383
fn required_modalities_only_non_text() { - 3384
let mut r = Reading::general(); - 3385
r.input_modalities.insert(Modality::Text); - 3386
r.input_modalities.insert(Modality::Data); - 3387
assert!(r.required_modalities().is_empty()); - 3388
- 3389
let mut r = Reading::general(); - 3390
r.input_modalities.insert(Modality::Image); - 3391
r.input_modalities.insert(Modality::Text); - 3392
assert_eq!(r.required_modalities(), BTreeSet::from([Modality::Image])); - 3393
- 3394
let mut r = Reading::general(); - 3395
r.input_modalities.insert(Modality::Image); - 3396
r.input_modalities.insert(Modality::Audio); - 3397
r.input_modalities.insert(Modality::Text); - 3398
assert_eq!( - 3399
r.required_modalities(), - 3400
BTreeSet::from([Modality::Audio, Modality::Image]) - 3401
); - 3402
} - 3403
- 3404
#[test] - 3405
fn modality_text_data_need_no_declared_support() { - 3406
assert!(!Modality::Text.needs_declared_support()); - 3407
assert!(!Modality::Data.needs_declared_support()); - 3408
assert!(Modality::Image.needs_declared_support()); - 3409
assert!(Modality::Audio.needs_declared_support()); - 3410
assert!(Modality::Video.needs_declared_support()); - 3411
assert!(Modality::Screen.needs_declared_support()); - 3412
assert!(Modality::Stream.needs_declared_support()); - 3413
} - 3414
- 3415
// ================================================================ - 3416
// Part 22: Thousands of generated combinations - 3417
// ================================================================ - 3418
- 3419
#[test] - 3420
fn thousands_of_act_horizon_stakes_combinations() { - 3421
let act_verbs: &[(&[&str], Act)] = &[ - 3422
(&["hi", "hello", "hey", "bye", "thanks"], Act::Converse), - 3423
( - 3424
&[ - 3425
"what", - 3426
"how", - 3427
"why", - 3428
"explain", - 3429
"describe", - 3430
"summarize", - 3431
"tell", - 3432
], - 3433
Act::Answer, - 3434
), - 3435
( - 3436
&["find", "search", "grep", "locate", "where", "list"], - 3437
Act::Locate, - 3438
), - 3439
( - 3440
&[ - 3441
"analyze", - 3442
"compare", - 3443
"research", - 3444
"investigate", - 3445
"evaluate", - 3446
"assess", - 3447
], - 3448
Act::Analyze, - 3449
), - 3450
( - 3451
&[ - 3452
"write", "draft", "create", "generate", "design", "compose", "plan", - 3453
], - 3454
Act::Author, - 3455
), - 3456
( - 3457
&[ - 3458
"fix", - 3459
"refactor", - 3460
"update", - 3461
"change", - 3462
"edit", - 3463
"remove", - 3464
"delete", - 3465
"implement", - 3466
], - 3467
Act::Modify, - 3468
), - 3469
( - 3470
&[ - 3471
"deploy", "restart", "send", "install", "schedule", "monitor", "pay", - 3472
], - 3473
Act::Operate, - 3474
), - 3475
( - 3476
&["test", "verify", "check", "validate", "audit"], - 3477
Act::Verify, - 3478
), - 3479
( - 3480
&["orchestrate", "coordinate", "delegate", "parallel"], - 3481
Act::Orchestrate, - 3482
), - 3483
( - 3484
&["configure", "remember", "forget", "permission"], - 3485
Act::Govern, - 3486
), - 3487
]; - 3488
- 3489
let modifiers: &[&str] = &["", "please", "now", "quickly", "the", "a", "this"]; - 3490
let objects: &[&str] = &[ - 3491
"the bug", - 3492
"the code", - 3493
"the file", - 3494
"the system", - 3495
"the service", - 3496
"it", - 3497
]; - 3498
- 3499
let mut count = 0u64; - 3500
for (verbs, _expected_act) in act_verbs { - 3501
for verb in *verbs { - 3502
for modifier in modifiers { - 3503
for object in objects { - 3504
let text = format!("{} {} {}", modifier, verb, object) - 3505
.trim() - 3506
.to_string(); - 3507
if text.is_empty() { - 3508
continue; - 3509
} - 3510
let extraction = extract(&req(&text)); - 3511
let _ = extraction.act.winner(); - 3512
let intent = resolve_text(&text); - 3513
assert!(intent.engagement.limits.is_at_most(&Limits::unrestricted())); - 3514
count += 1; - 3515
} - 3516
} - 3517
} - 3518
} - 3519
assert!( - 3520
count >= 2_000, - 3521
"should have generated at least 2000 scenarios, got {}", - 3522
count - 3523
); - 3524
} - 3525
- 3526
#[test] - 3527
fn thousands_of_horizon_combinations() { - 3528
let recurrence_words: &[&str] = &[ - 3529
"every day", - 3530
"every night", - 3531
"every week", - 3532
"every month", - 3533
"every hour", - 3534
"nightly", - 3535
"monthly", - 3536
"daily", - 3537
"weekly", - 3538
"hourly", - 3539
"continuously", - 3540
"whenever", - 3541
"from now on", - 3542
"ongoing", - 3543
]; - 3544
let verbs: &[&str] = &[ - 3545
"check", "monitor", "watch", "sync", "alert", "scan", "verify", "inspect", - 3546
]; - 3547
let subjects: &[&str] = &[ - 3548
"the logs", - 3549
"the system", - 3550
"the service", - 3551
"the queue", - 3552
"the metrics", - 3553
"the database", - 3554
"the cache", - 3555
"the files", - 3556
"the data", - 3557
]; - 3558
- 3559
let mut count = 0u64; - 3560
for word in recurrence_words { - 3561
for verb in verbs { - 3562
for subject in subjects { - 3563
let text = format!("{} {} {}", verb, subject, word); - 3564
let extraction = extract(&req(&text)); - 3565
let horizon = extraction.horizon.winner().map(|w| w.0); - 3566
assert_eq!( - 3567
Some(Horizon::Durable), - 3568
horizon, - 3569
"`{}` should be Durable", - 3570
text - 3571
); - 3572
count += 1; - 3573
} - 3574
} - 3575
} - 3576
assert!( - 3577
count >= 900, - 3578
"should have tested {} durable combinations", - 3579
count - 3580
); - 3581
} - 3582
- 3583
#[test] - 3584
fn thousands_of_stakes_combinations() { - 3585
let stakes_words: &[(&str, Stakes)] = &[ - 3586
("production", Stakes::Irreversible), - 3587
("prod", Stakes::Irreversible), - 3588
("live", Stakes::Irreversible), - 3589
("customer", Stakes::Irreversible), - 3590
("everyone", Stakes::Irreversible), - 3591
("permanently", Stakes::Irreversible), - 3592
("expensive", Stakes::Costly), - 3593
("budget", Stakes::Costly), - 3594
("quota", Stakes::Costly), - 3595
]; - 3596
let verbs: &[&str] = &[ - 3597
"deploy", - 3598
"delete", - 3599
"send", - 3600
"modify", - 3601
"refactor", - 3602
"write", - 3603
"fix", - 3604
"create", - 3605
"configure", - 3606
"run", - 3607
"start", - 3608
"stop", - 3609
]; - 3610
let objects: &[&str] = &[ - 3611
"the service", - 3612
"the database", - 3613
"the file", - 3614
"the config", - 3615
"the system", - 3616
"the account", - 3617
"the record", - 3618
"the setting", - 3619
]; - 3620
- 3621
let mut count = 0u64; - 3622
for (word, expected_stakes) in stakes_words { - 3623
for verb in verbs { - 3624
for object in objects { - 3625
let text = format!("{} {} to {}", verb, object, word); - 3626
let extraction = extract(&req(&text)); - 3627
let stakes = extraction.stakes_from_words.winner(); - 3628
if let Some((winner, _)) = stakes { - 3629
assert!( - 3630
winner.rank() >= expected_stakes.rank(), - 3631
"`{}`: expected >= {:?}, got {:?}", - 3632
text, - 3633
expected_stakes, - 3634
winner - 3635
); - 3636
} - 3637
count += 1; - 3638
} - 3639
} - 3640
} - 3641
assert!( - 3642
count >= 800, - 3643
"should have tested {} stakes combinations", - 3644
count - 3645
); - 3646
} - 3647
- 3648
#[test] - 3649
fn thousands_of_evidence_combinations() { - 3650
let evidence_words: &[(&str, Evidence)] = &[ - 3651
("cite", Evidence::Cited), - 3652
("sources", Evidence::Cited), - 3653
("proof", Evidence::Verified), - 3654
("ensure", Evidence::Verified), - 3655
("audited", Evidence::Audited), - 3656
("acceptance", Evidence::Audited), - 3657
]; - 3658
let verbs: &[&str] = &[ - 3659
"deploy", "fix", "write", "analyze", "research", "verify", "test", - 3660
]; - 3661
let objects: &[&str] = &[ - 3662
"the report", - 3663
"the bug", - 3664
"the system", - 3665
"the code", - 3666
"the data", - 3667
]; - 3668
- 3669
let mut count = 0u64; - 3670
for (word, expected_ev) in evidence_words { - 3671
for verb in verbs { - 3672
for object in objects { - 3673
let text = format!("{} {} with {}", verb, object, word); - 3674
let extraction = extract(&req(&text)); - 3675
let evidence = extraction.evidence.winner(); - 3676
if let Some((winner, _)) = evidence { - 3677
assert_eq!( - 3678
winner, *expected_ev, - 3679
"`{}`: expected {:?}, got {:?}", - 3680
text, expected_ev, winner - 3681
); - 3682
} - 3683
count += 1; - 3684
} - 3685
} - 3686
} - 3687
assert!( - 3688
count >= 200, - 3689
"should have tested {} evidence combinations", - 3690
count - 3691
); - 3692
} - 3693
- 3694
#[test] - 3695
fn thousands_of_resolution_does_not_crash() { - 3696
let templates: &[&str] = &[ - 3697
"deploy the service", - 3698
"fix the failing test", - 3699
"write a comprehensive report on", - 3700
"analyze the data and compare it with", - 3701
"find all instances of", - 3702
"refactor the parser to handle", - 3703
"configure the gateway with the new settings", - 3704
"verify the fix works on", - 3705
"schedule a backup of", - 3706
"monitor the system for", - 3707
"what is the status of", - 3708
"explain how the parser works with", - 3709
"create a new file called", - 3710
"remove the old", - 3711
"update the configuration for", - 3712
"search for all", - 3713
"test the integration with", - 3714
"audit the code for", - 3715
"govern the settings for", - 3716
"orchestrate the migration of", - 3717
]; - 3718
let suffixes: &[&str] = &[ - 3719
"", - 3720
"please", - 3721
"now", - 3722
"urgently", - 3723
"in production", - 3724
"with citations", - 3725
"every day", - 3726
"with the team", - 3727
"before deploying", - 3728
"and send me a report", - 3729
"and verify the result", - 3730
"and then deploy it", - 3731
"to production", - 3732
"and make sure it works", - 3733
"with sources", - 3734
"for the audit", - 3735
]; - 3736
- 3737
let mut count = 0u64; - 3738
for template in templates { - 3739
for suffix in suffixes { - 3740
let text = format!("{} {}", template, suffix).trim().to_string(); - 3741
if text.is_empty() || text.len() > 500 { - 3742
continue; - 3743
} - 3744
let intent = resolve_text(&text); - 3745
assert!( - 3746
intent.engagement.limits.is_at_most(&Limits::unrestricted()), - 3747
"narrowing invariant violated for `{}`", - 3748
text - 3749
); - 3750
count += 1; - 3751
} - 3752
} - 3753
assert!( - 3754
count >= 300, - 3755
"should have tested {} resolution combinations", - 3756
count - 3757
); - 3758
} - 3759
- 3760
#[test] - 3761
fn thousands_of_engagement_matrix_combinations() { - 3762
let mut count = 0u64; - 3763
for &act in &Act::ALL { - 3764
for &stakes in &Stakes::ALL { - 3765
for &evidence in &Evidence::ALL { - 3766
for &autonomy in &Autonomy::ALL { - 3767
for &attendance in &Attendance::ALL { - 3768
let r = reading_simple(act, Horizon::Session, stakes, evidence); - 3769
let auth = authority_of(autonomy, attendance); - 3770
let engagement = derive(&r, &auth, true); - 3771
assert!(engagement.limits.is_at_most(&Limits::unrestricted())); - 3772
count += 1; - 3773
} - 3774
} - 3775
} - 3776
} - 3777
} - 3778
assert_eq!(count, 10 * 4 * 4 * 4 * 3); - 3779
} - 3780
- 3781
#[test] - 3782
fn thousands_of_lattice_meet_pairs() { - 3783
let mut engagements = Vec::new(); - 3784
for &act in &Act::ALL { - 3785
for &horizon in &Horizon::ALL { - 3786
for &stakes in &Stakes::ALL { - 3787
for &evidence in &Evidence::ALL { - 3788
for slice in [true, false] { - 3789
let r = reading_simple(act, horizon, stakes, evidence); - 3790
engagements.push(derive(&r, &Authority::default(), slice)); - 3791
} - 3792
} - 3793
} - 3794
} - 3795
} - 3796
- 3797
let baseline = Limits::unrestricted(); - 3798
let mut tested = 0u64; - 3799
for i in 0..engagements.len() { - 3800
for j in (i + 1)..engagements.len() { - 3801
if (i + j) % 17 != 0 { - 3802
continue; - 3803
} - 3804
let met = engagements[i].limits.meet(&engagements[j].limits); - 3805
assert!(met.is_at_most(&engagements[i].limits)); - 3806
assert!(met.is_at_most(&engagements[j].limits)); - 3807
assert!(met.is_at_most(&baseline)); - 3808
tested += 1; - 3809
} - 3810
} - 3811
assert!( - 3812
tested >= 10_000, - 3813
"should have tested ~10k pairs, got {}", - 3814
tested - 3815
); - 3816
} - 3817
- 3818
#[test] - 3819
fn thousands_of_capability_slice_intersections() { - 3820
let domains_list: &[&[&str]] = &[ - 3821
&["filesystem", "memory"], - 3822
&["filesystem", "memory", "live-data", "web"], - 3823
&["filesystem", "memory", "code-exec", "vcs"], - 3824
&["filesystem", "memory", "documents", "web", "live-data"], - 3825
&["filesystem", "memory", "messaging", "orchestration"], - 3826
&["filesystem", "memory", "orchestration", "documents"], - 3827
&["filesystem", "memory", "code-exec", "vcs", "live-data"], - 3828
&["filesystem", "memory", "observability", "code-exec"], - 3829
]; - 3830
let baseline = Limits::unrestricted(); - 3831
let mut tested = 0u64; - 3832
for i in 0..domains_list.len() { - 3833
for j in 0..domains_list.len() { - 3834
let mut a = Limits::unrestricted(); - 3835
a.required_domains = DomainSet::only(domains_list[i].iter().copied()); - 3836
let mut b = Limits::unrestricted(); - 3837
b.required_domains = DomainSet::only(domains_list[j].iter().copied()); - 3838
let met = a.meet(&b); - 3839
assert!(met.is_at_most(&a), "meet not below lhs: {} & {}", i, j); - 3840
assert!(met.is_at_most(&b), "meet not below rhs: {} & {}", i, j); - 3841
assert!( - 3842
met.is_at_most(&baseline), - 3843
"meet not below baseline: {} & {}", - 3844
i, - 3845
j - 3846
); - 3847
tested += 1; - 3848
} - 3849
} - 3850
assert!( - 3851
tested >= 64, - 3852
"should have tested {} domain combinations", - 3853
tested - 3854
); - 3855
} - 3856
- 3857
// ================================================================ - 3858
// Part 23: Confidence and threshold edge cases - 3859
// ================================================================ - 3860
- 3861
#[test] - 3862
fn confidence_is_always_in_unit_interval() { - 3863
let cases: &[&str] = &[ - 3864
"hi", - 3865
"deploy to production", - 3866
"fix the bug", - 3867
"what is 2+2", - 3868
"write a report and send it to the team and verify the result", - 3869
"analyze the data and compare it with historical trends then report findings with citations", - 3870
"", - 3871
"a", - 3872
"ab", - 3873
"a b c d e f g h i j k l m n o p q r s t u v w x y z", - 3874
"deploy deploy deploy", - 3875
"fix fix fix", - 3876
"test test test", - 3877
"I need to deploy the service to production and I must verify the tests pass green with citations from the audited sources", - 3878
]; - 3879
for text in cases { - 3880
let intent = resolve_text(text); - 3881
let c = intent.reading.confidence; - 3882
assert!( - 3883
(0.0..=1.0).contains(&c), - 3884
"confidence {} out of [0,1] for `{}`", - 3885
c, - 3886
text - 3887
); - 3888
} - 3889
} - 3890
- 3891
#[test] - 3892
fn confidence_reflects_margin_on_categorical_axes() { - 3893
let extraction = extract(&req("review the code")); - 3894
let (winner, conf) = extraction.act.winner().unwrap(); - 3895
assert_eq!(winner, Act::Analyze); - 3896
assert!( - 3897
conf > 0.5, - 3898
"single strong act should have decent confidence" - 3899
); - 3900
- 3901
let extraction = extract(&req("fix and verify")); - 3902
if extraction.act.winner().is_some() { - 3903
let (_, conf) = extraction.act.winner().unwrap(); - 3904
let ranked = extraction.act.ranked(); - 3905
if ranked.len() >= 2 { - 3906
assert!(conf <= 0.95, "ambiguous act should not be 100% confident"); - 3907
} - 3908
} - 3909
} - 3910
- 3911
#[test] - 3912
fn evidence_absence_is_confident() { - 3913
// In extraction, absence of evidence words → no votes → winner() is None. - 3914
let extraction = extract(&req("fix the bug")); - 3915
assert!(extraction.evidence.winner().is_none()); - 3916
// But in the full resolve, silence reads as a confident Evidence::None - 3917
// (confidence 0.85, above the 0.75 accept floor so the reading resolves). - 3918
let intent = resolve_text("fix the bug"); - 3919
assert_eq!(intent.reading.evidence, Evidence::None); - 3920
} - 3921
- 3922
#[test] - 3923
fn resolution_does_not_panic_on_random_noise() { - 3924
let cases: &[&str] = &[ - 3925
"asdf", - 3926
"qwerty", - 3927
"asdfasdfasdf", - 3928
"zxcvbnm", - 3929
"1234567890", - 3930
"!!!", - 3931
"???", - 3932
"---", - 3933
"+++", - 3934
"...", - 3935
"a b c d e f g h i j k l m n o p q r s t u v w x y z", - 3936
"the the the the", - 3937
"a a a a a a a a", - 3938
"to be or not to be that is the question", - 3939
"lorem ipsum dolor sit amet consectetur adipiscing elit", - 3940
"the quick brown fox jumps over the lazy dog", - 3941
]; - 3942
for text in cases { - 3943
let intent = resolve_text(text); - 3944
assert!(intent.engagement.limits.is_at_most(&Limits::unrestricted())); - 3945
assert!((0.0..=1.0).contains(&intent.reading.confidence)); - 3946
} - 3947
} - 3948
- 3949
// ================================================================ - 3950
// Part 24: Provenance and signal traceability - 3951
// ================================================================ - 3952
- 3953
#[test] - 3954
fn provenance_records_signals_for_signal_tier() { - 3955
let intent = resolve_text("deploy to production"); - 3956
if intent.provenance.tier == Tier::Signals { - 3957
assert!(!intent.provenance.signals.is_empty()); - 3958
} - 3959
} - 3960
- 3961
#[test] - 3962
fn provenance_escalation_note_present_when_below_threshold() { - 3963
let resolution = resolve( - 3964
&req("zorble frobnicate"), - 3965
&Declared::default(), - 3966
&Authority::default(), - 3967
&ResolverConfig::default(), - 3968
); - 3969
let intent = resolution.intent(); - 3970
assert!(intent.provenance.escalation_note.is_some()); - 3971
} - 3972
- 3973
#[test] - 3974
fn signal_names_are_stable_identifiers() { - 3975
let extraction = extract(&req("deploy the service to production")); - 3976
for signal in &extraction.signals { - 3977
assert!(!signal.name.is_empty(), "signal name must not be empty"); - 3978
} - 3979
} - 3980
- 3981
#[test] - 3982
fn signal_weights_are_non_negative() { - 3983
let extraction = extract(&req("deploy to production and verify with tests")); - 3984
for signal in &extraction.signals { - 3985
assert!( - 3986
signal.weight >= 0.0, - 3987
"signal weight must be non-negative: {:?}", - 3988
signal - 3989
); - 3990
} - 3991
} - 3992
- 3993
// ================================================================ - 3994
// Part 25: Full pipeline — natural language to engagement - 3995
// ================================================================ - 3996
- 3997
#[test] - 3998
fn pipeline_greeting_read_only() { - 3999
let intent = resolve_text("hello there"); - 4000
assert_eq!(intent.reading.act, Act::Converse);
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.