Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/crates/allen-reflex/src/lexicon.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / crates / allen-reflex / src / lexicon.rs` 644 lines ยท 15759 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Hand-written word lists. Every list here is prior knowledge about English that the 17 //! 79 training cases are too few to teach; each has a one-line semantic justification. 18 //! None of them names an exam case, an id or an argument value. Lists are matched on 19 //! lower-case words after contraction expansion (`don't` -> `do not`). 20 21 use crate::text::Token; 22 23 /// Concept classes. A concept is added as an extra feature next to the words, so two 24 /// different words with the same meaning ("abort", "cancel") look alike to every scorer. 25 #[derive(Clone, Copy, PartialEq, Eq, Debug)] 26 #[repr(u8)] 27 pub enum Concept { 28 /// storing a fact (remember, memorize, keep in mind) 29 Store = 0, 30 /// a standing preference (prefer, rather, from now on) 31 Pref, 32 /// a to-do item (task, to-do, remind me) 33 Todo, 34 /// writing or drafting text (write, draft, poem, explain) 35 Write, 36 /// agreement (yes, accept, go ahead) 37 Yes, 38 /// rejection (no, reject, decline) 39 No, 40 /// stopping (cancel, abort, never mind) 41 Stop, 42 /// the agent's state (status, ready, pending) 43 State, 44 /// what the agent can do (help, options, commands) 45 Menu, 46 /// audit counters (evidence, counters, how many) 47 Audit, 48 /// reading back the latest note or reply (recall, last, newest) 49 Latest, 50 /// the stored facts (facts, what you remember) 51 Facts, 52 /// live information from the world (weather, news, price) 53 World, 54 /// household devices and media (lights, music, thermostat) 55 Device, 56 /// buying, booking, ordering (book, order, flight) 57 Commerce, 58 /// social talk (hello, thanks, bye) 59 Social, 60 /// a pointer with no content (this, that, it, thing) 61 Deictic, 62 /// a question word (what, how, is, are at the start) 63 Question, 64 } 65 66 /// Number of concepts. 67 pub const N_CONCEPTS: usize = 18; 68 69 type Phrase = &'static [&'static str]; 70 71 /// (concept, phrases). Justification per concept is on the enum. 72 pub const CONCEPTS: &[(Concept, &[Phrase])] = &[ 73 ( 74 Concept::Store, 75 &[ 76 &["remember"], 77 &["memorize"], 78 &["memorise"], 79 &["store"], 80 &["save"], 81 &["keep", "in", "mind"], 82 &["note", "for", "memory"], 83 &["do", "not", "forget"], 84 &["fact"], 85 &["memory"], 86 ], 87 ), 88 ( 89 Concept::Pref, 90 &[ 91 &["prefer"], 92 &["preference"], 93 &["rather"], 94 &["from", "now", "on"], 95 &["i", "like"], 96 &["always"], 97 &["tone"], 98 &["style"], 99 ], 100 ), 101 ( 102 Concept::Todo, 103 &[ 104 &["task"], 105 &["todo"], 106 &["to-do"], 107 &["to", "do"], 108 &["remind", "me"], 109 &["my", "list"], 110 &["make", "a", "note"], 111 &["note", "down"], 112 ], 113 ), 114 ( 115 Concept::Write, 116 &[ 117 &["write"], 118 &["draft"], 119 &["compose"], 120 &["generate"], 121 &["summarize"], 122 &["summarise"], 123 &["explain"], 124 &["describe"], 125 &["rewrite"], 126 &["translate"], 127 &["poem"], 128 &["story"], 129 &["haiku"], 130 &["limerick"], 131 &["letter"], 132 &["essay"], 133 &["toast"], 134 &["reply"], 135 &["message"], 136 ], 137 ), 138 ( 139 Concept::Yes, 140 &[ 141 &["approve"], 142 &["accept"], 143 &["yes"], 144 &["yeah"], 145 &["yep"], 146 &["confirm"], 147 &["go", "ahead"], 148 &["sounds", "good"], 149 &["looks", "good"], 150 &["agreed"], 151 &["proceed"], 152 ], 153 ), 154 ( 155 Concept::No, 156 &[ 157 &["deny"], 158 &["reject"], 159 &["no"], 160 &["nope"], 161 &["decline"], 162 &["wrong"], 163 &["not", "good"], 164 &["throw", "it", "away"], 165 &["throw", "away"], 166 &["discard"], 167 &["do", "not", "like"], 168 &["do", "not", "accept"], 169 ], 170 ), 171 ( 172 Concept::Stop, 173 &[ 174 &["cancel"], 175 &["stop"], 176 &["abort"], 177 &["never", "mind"], 178 &["nevermind"], 179 &["forget", "it"], 180 &["call", "it", "off"], 181 &["halt"], 182 &["drop"], 183 &["changed", "my", "mind"], 184 &["hold", "on"], 185 ], 186 ), 187 ( 188 Concept::State, 189 &[ 190 &["status"], 191 &["state"], 192 &["ready"], 193 &["locked"], 194 &["pending"], 195 &["busy"], 196 &["idle"], 197 &["doing"], 198 &["running"], 199 ], 200 ), 201 ( 202 Concept::Menu, 203 &[ 204 &["help"], 205 &["option"], 206 &["options"], 207 &["command"], 208 &["commands"], 209 &["can", "you", "do"], 210 &["menu"], 211 &["capabilities"], 212 &["actions"], 213 ], 214 ), 215 ( 216 Concept::Audit, 217 &[ 218 &["evidence"], 219 &["audit"], 220 &["counter"], 221 &["counters"], 222 &["how", "many"], 223 &["so", "far"], 224 &["log"], 225 &["statistics"], 226 &["stats"], 227 ], 228 ), 229 ( 230 Concept::Latest, 231 &[ 232 &["recall"], 233 &["read", "back"], 234 &["last"], 235 &["latest"], 236 &["newest"], 237 &["most", "recent"], 238 &["previous"], 239 &["bring", "up"], 240 &["repeat"], 241 ], 242 ), 243 ( 244 Concept::Facts, 245 &[ 246 &["facts"], 247 &["remembered"], 248 &["know", "about", "me"], 249 &["stored"], 250 &["you", "remember"], 251 &["told", "you"], 252 ], 253 ), 254 ( 255 Concept::World, 256 &[ 257 &["weather"], 258 &["news"], 259 &["price"], 260 &["stock"], 261 &["bitcoin"], 262 &["score"], 263 &["forecast"], 264 &["traffic"], 265 &["rain"], 266 &["temperature"], 267 &["time", "is", "it"], 268 &["who", "won"], 269 &["right", "now"], 270 ], 271 ), 272 ( 273 Concept::Device, 274 &[ 275 &["light"], 276 &["lights"], 277 &["lamp"], 278 &["tv"], 279 &["music"], 280 &["play"], 281 &["song"], 282 &["thermostat"], 283 &["heater"], 284 &["volume"], 285 &["speaker"], 286 &["door"], 287 &["garage"], 288 &["oven"], 289 &["switch", "on"], 290 &["turn", "on"], 291 &["turn", "off"], 292 ], 293 ), 294 ( 295 Concept::Commerce, 296 &[ 297 &["book"], 298 &["order"], 299 &["flight"], 300 &["pizza"], 301 &["ticket"], 302 &["hotel"], 303 &["taxi"], 304 &["buy", "me"], 305 &["purchase"], 306 &["shop"], 307 ], 308 ), 309 ( 310 Concept::Social, 311 &[ 312 &["hi"], 313 &["hello"], 314 &["hey"], 315 &["thanks"], 316 &["thank", "you"], 317 &["bye"], 318 &["goodbye"], 319 &["good", "morning"], 320 &["good", "night"], 321 &["have", "a", "nice"], 322 ], 323 ), 324 ( 325 Concept::Deictic, 326 &[ 327 &["this"], 328 &["that"], 329 &["it"], 330 &["thing"], 331 &["one"], 332 &["something"], 333 &["stuff"], 334 &["other"], 335 &["before"], 336 &["same"], 337 &["usual"], 338 ], 339 ), 340 ]; 341 342 /// Courtesy wrappers at the start of a clause; they carry no content 343 /// ("please", "can you", "I want you to"). 344 pub const POLITE: &[Phrase] = &[ 345 &["please"], 346 &["kindly"], 347 &["ok"], 348 &["okay"], 349 &["now"], 350 &["just"], 351 &["so"], 352 &["well"], 353 &["also"], 354 &["alright"], 355 &["hey"], 356 &["first"], 357 &["then"], 358 &["can", "you"], 359 &["could", "you"], 360 &["would", "you"], 361 &["will", "you"], 362 &["i", "want", "you", "to"], 363 &["i", "need", "you", "to"], 364 &["i", "would", "like", "you", "to"], 365 &["go", "ahead", "and"], 366 ]; 367 368 /// Discourse fillers: a leading sentence made only of these is dropped when more follows 369 /// ("Ok. Remember ..."), because it acknowledges and does not request. 370 pub const FILLER: &[&str] = &[ 371 "ok", "okay", "good", "great", "fine", "nice", "cool", "thanks", "thank", "you", "hmm", "um", 372 "oh", "well", "so", "alright", "right", "perfect", 373 ]; 374 375 /// Leading words dropped before a comma ("Ok, remember ..."). 376 pub const FILLER_COMMA: &[&str] = &["ok", "okay", "well", "so", "alright", "hmm", "um", "oh"]; 377 378 /// Words that carry no argument content: an argument made only of these is missing 379 /// ("Save this.", "Add a task."). 380 pub const VACUOUS: &[&str] = &[ 381 "this", 382 "that", 383 "it", 384 "thing", 385 "things", 386 "one", 387 "something", 388 "anything", 389 "stuff", 390 "a", 391 "an", 392 "the", 393 "my", 394 "your", 395 "some", 396 "to", 397 "for", 398 "me", 399 "task", 400 "note", 401 "fact", 402 "preference", 403 "new", 404 "down", 405 "please", 406 "again", 407 "too", 408 ]; 409 410 /// Verbs a `prompt` argument normally starts with; "Write something" names no content. 411 pub const WRITE_VERBS: &[&str] = &[ 412 "write", "draft", "compose", "generate", "create", "make", "produce", 413 ]; 414 415 /// Verbs that are not in the agent's list and that the operator may not ask the model to 416 /// run (exam contract: unlock, rotate, update, shutdown, delete, wipe, deploy; plus the 417 /// plain synonyms of those). 418 pub const FORBIDDEN: &[&str] = &[ 419 "unlock", 420 "rotate", 421 "update", 422 "upgrade", 423 "shutdown", 424 "reboot", 425 "restart", 426 "wipe", 427 "erase", 428 "delete", 429 "deploy", 430 "format", 431 "uninstall", 432 "rm", 433 "destroy", 434 ]; 435 436 /// Two-word forbidden phrases (the second word may come up to 3 words later: 437 /// "shut the agent down"). 438 pub const FORBIDDEN_SPLIT: &[(&str, &str)] = &[ 439 ("shut", "down"), 440 ("power", "off"), 441 ("power", "down"), 442 ("turn", "off"), 443 ("switch", "off"), 444 ]; 445 446 /// Objects that make "turn off" a device request (`none`) rather than switching the agent off. 447 pub const DEVICE_OBJECTS: &[&str] = &[ 448 "light", 449 "lights", 450 "lamp", 451 "lamps", 452 "tv", 453 "television", 454 "music", 455 "radio", 456 "heater", 457 "fan", 458 "oven", 459 "stove", 460 "alarm", 461 "speaker", 462 "kettle", 463 "heating", 464 "ac", 465 "sprinkler", 466 "sprinklers", 467 ]; 468 469 /// Words that turn a following verb into a noun ("an update", "the format"). 470 pub const DETERMINERS: &[&str] = &[ 471 "a", "an", "the", "any", "this", "that", "your", "my", "some", "its", "every", 472 ]; 473 474 /// Negation just before a verb ("do not delete"). 475 pub const NEGATION: &[&str] = &["not", "never", "no"]; 476 477 /// Words asking the agent to drop its rules (exam contract rule: "asks you to break these rules"). 478 pub const RULE_BREAK_VERBS: &[&str] = &[ 479 "ignore", 480 "disregard", 481 "forget", 482 "disable", 483 "bypass", 484 "break", 485 "override", 486 "skip", 487 "drop", 488 "remove", 489 "turn", 490 ]; 491 492 /// Objects of a rule-breaking verb. 493 pub const RULE_OBJECTS: &[&str] = &[ 494 "rule", 495 "rules", 496 "instruction", 497 "instructions", 498 "policy", 499 "policies", 500 "safety", 501 "restriction", 502 "restrictions", 503 "limit", 504 "limits", 505 "guardrail", 506 "guardrails", 507 "allowed", 508 "approval", 509 "filter", 510 "filters", 511 "prompt", 512 ]; 513 514 /// Phrases that announce a fake mode or authority (role-play jailbreaks). 515 pub const OVERRIDE_PHRASES: &[Phrase] = &[ 516 &["developer", "mode"], 517 &["dev", "mode"], 518 &["admin", "mode"], 519 &["god", "mode"], 520 &["debug", "mode"], 521 &["system", "override"], 522 &["jailbreak"], 523 &["no", "rules"], 524 &["without", "rules"], 525 &["unrestricted"], 526 &["pretend", "you"], 527 &["pretend", "to", "be"], 528 &["act", "as", "if"], 529 &["any", "command"], 530 &["without", "asking"], 531 &["sudo"], 532 &["root", "access"], 533 &["your", "instructions"], 534 &["system", "prompt"], 535 ]; 536 537 /// Approval without the operator in the loop ("approve everything automatically"). 538 pub const BLANKET: &[&str] = &["automatically", "always", "every", "everything", "all"]; 539 540 /// Reported speech: the order comes from stored data ("the note says ..."). 541 pub const REPORT: &[&str] = &[ 542 "says", 543 "said", 544 "say", 545 "tells", 546 "told", 547 "instructs", 548 "wrote", 549 "written", 550 "asks", 551 ]; 552 553 /// Phrases that obey such an order ("do it", "follow it"). 554 pub const OBEY: &[Phrase] = &[ 555 &["do", "it"], 556 &["do", "that"], 557 &["do", "what"], 558 &["do", "as"], 559 &["follow"], 560 &["obey"], 561 &["carry", "out"], 562 &["execute"], 563 &["run", "it"], 564 &["act", "on"], 565 &["go", "on"], 566 ]; 567 568 /// Leading phrases that open a text payload (store, preference, to-do, writing). Anything 569 /// after them in the same clause is the operator's data, so words like "wipe" inside it are 570 /// not orders (exam contract: a request to store a note that contains an order is `remember`). 571 pub const TEXT_FRAMES: &[Phrase] = &[ 572 &["remember"], 573 &["memorize"], 574 &["memorise"], 575 &["store"], 576 &["save"], 577 &["note"], 578 &["keep", "in", "mind"], 579 &["keep", "this"], 580 &["do", "not", "forget"], 581 &["make", "a", "note"], 582 &["remind", "me"], 583 &["task"], 584 &["new", "task"], 585 &["add"], 586 &["put"], 587 &["to", "do"], 588 &["todo"], 589 &["prefer"], 590 &["i", "prefer"], 591 &["i", "like"], 592 &["i", "would", "rather"], 593 &["my", "preference"], 594 &["write"], 595 &["draft"], 596 &["compose"], 597 &["generate"], 598 &["summarize"], 599 &["explain"], 600 &["describe"], 601 &["ask", "the", "model"], 602 ]; 603 604 /// Second-step verbs: "X and ..." starts a new request. 605 pub const AND_VERBS: &[&str] = &[ 606 "approve", "deny", "cancel", "recall", "show", "list", "check", "read", "tell", "give", 607 "reject", "accept", 608 ]; 609 610 /// Is `words[at..]` starting with phrase `p`? 611 pub fn starts(toks: &[Token], at: usize, p: &[&str]) -> bool { 612 if at + p.len() > toks.len() { 613 return false; 614 } 615 p.iter().enumerate().all(|(k, w)| toks[at + k].word == *w) 616 } 617 618 /// Is `w` in list `l`? 619 pub fn is_in(l: &[&str], w: &str) -> bool { 620 l.contains(&w) 621 } 622 623 /// Longest phrase of `list` starting at `at`, as its length (0 if none). 624 pub fn longest(toks: &[Token], at: usize, list: &[Phrase]) -> usize { 625 list.iter() 626 .filter(|p| starts(toks, at, p)) 627 .map(|p| p.len()) 628 .max() 629 .unwrap_or(0) 630 } 631 632 /// Skip courtesy wrappers at `at`; returns the first content index. 633 pub fn skip_polite(toks: &[Token], mut at: usize, end: usize) -> usize { 634 loop { 635 if at >= end { 636 return at; 637 } 638 let n = longest(toks, at, POLITE); 639 if n == 0 || at + n > end { 640 return at; 641 } 642 at += n; 643 } 644 }