Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

FP14d: a note or mark teaches the fingerprint that judged the piece. teach, approve and pair already label the one `which` picks for the file; read, readings and learn-notes now keep a project's notes in the one that judges the project ([PROJECT] on readings and learn-notes), and learning again remakes only those notes' rows. `raea fingerprint move [--fp CHILD] [--to PARENT] --axis/--source/--project` takes a child's own matching rows up into a fingerprint it extends and retrains both; rows on an axis the parent lacks or the child overrides stay

shinyobjectze4b607e7f8f6
diff --git a/apps/fingerprint/src/lib.rs b/apps/fingerprint/src/lib.rs
index 5c419ae2..50f8edbc 100644
--- a/apps/fingerprint/src/lib.rs
+++ b/apps/fingerprint/src/lib.rs
@@ -6,6 +6,7 @@
mod approve;
mod bootstrap;
+mod moving;
mod notes;
mod pairing;
mod pick;
@@ -18,14 +19,16 @@ use std::path::Path;
pub use serve::serve;
-pub const USAGE: &str = "raea fingerprint new NAME [--who W] [--about TEXT] [--extends FP] [--kinds K,K] [--tags T,T] | raea fingerprint bootstrap FILE... [--from LIST] [--per N] | raea fingerprint teach FILE --axis A --at T [--bad|--good] [--span S] [--box x0,y0,x1,y1] [--words W] [--project P] | raea fingerprint approve FILE... [--project P] | raea fingerprint pair WORSE BETTER --axis A [--at T] [--then T2] | raea fingerprint versions V1 V2... | raea fingerprint profile REFS... --as NAME [--against LIST] | raea fingerprint score FILE [--json] [--sheet out.png] [--timeline] [--profile NAME] | raea fingerprint report [--json] | raea fingerprint which [PATH] [--json] | raea fingerprint use NAME [--in project|workspace] [PATH] | raea fingerprint diff A B [--json] | raea fingerprint share NAME [--in project|workspace] [PATH] | raea fingerprint reembed PLACE... | raea fingerprint read PROJECT [--by kimi|claude] | raea fingerprint readings [--ask N] [--tally] | raea fingerprint learn-notes | raea fingerprint stop [--fp NAME] (a person's sense of good work as axes with small heads over on-device encoders, docs/fingerprint.md: new makes ~/.raea/fingerprints/NAME with raea's base taxonomy in fingerprint.ts (or FP's axes with --extends), what it's for, the kinds of piece and project tags it judges, and every axis scoring from its words; bootstrap puts known defects into windows of real work and trains the mechanical axes, held out by source; teach adds a label at a moment; approve makes approved work clean on every axis, away from its notes; pair says one moment is better than another on an axis (a pick, a hand edit); versions makes weak pairs of noted moments the next version changed; score prints the moments it expects a note on first, then every axis per window with --json, a sheet PNG with --sheet, or the piece second by second in words with --timeline; profile takes the ranges of work you admire (loudness, tilt, cut rate, motion, brightness, contrast, saturation, sharpness), checked leave-one-out, and score --profile says what falls outside them, where and which way; report says each head's held-out score, labels, cheats, gate and what it can't judge; which says the one that judges a piece (its project's, its workspace's, then yours) and why, use pins one there, diff lists the axes two fingerprints rank the same evidence most differently on, and share copies one's taxonomy and evidence (no heads, no media) into a project or workspace for its team; reembed moves a fingerprint's evidence to this machine's encoders, re-embedding the rows whose media it finds; read has a fresh kimi or claude session read a project's pinned notes into kinds and axes, readings puts them to you to check and tallies your answers, and learn-notes makes the defects and praise evidence once you've agreed with 45 kinds and 40 axes in 50)";
+pub const USAGE: &str = "raea fingerprint new NAME [--who W] [--about TEXT] [--extends FP] [--kinds K,K] [--tags T,T] | raea fingerprint bootstrap FILE... [--from LIST] [--per N] | raea fingerprint teach FILE --axis A --at T [--bad|--good] [--span S] [--box x0,y0,x1,y1] [--words W] [--project P] | raea fingerprint approve FILE... [--project P] | raea fingerprint pair WORSE BETTER --axis A [--at T] [--then T2] | raea fingerprint versions V1 V2... | raea fingerprint profile REFS... --as NAME [--against LIST] | raea fingerprint score FILE [--json] [--sheet out.png] [--timeline] [--profile NAME] | raea fingerprint report [--json] | raea fingerprint which [PATH] [--json] | raea fingerprint use NAME [--in project|workspace] [PATH] | raea fingerprint diff A B [--json] | raea fingerprint share NAME [--in project|workspace] [PATH] | raea fingerprint reembed PLACE... | raea fingerprint read PROJECT [--by kimi|claude] | raea fingerprint readings [PROJECT] [--ask N] [--tally] | raea fingerprint learn-notes [PROJECT] | raea fingerprint move [--fp CHILD] [--to PARENT] [--axis A] [--source S] [--project P] | raea fingerprint stop [--fp NAME] (a person's sense of good work as axes with small heads over on-device encoders, docs/fingerprint.md: new makes ~/.raea/fingerprints/NAME with raea's base taxonomy in fingerprint.ts (or FP's axes with --extends), what it's for, the kinds of piece and project tags it judges, and every axis scoring from its words; bootstrap puts known defects into windows of real work and trains the mechanical axes, held out by source; teach adds a label at a moment; approve makes approved work clean on every axis, away from its notes; pair says one moment is better than another on an axis (a pick, a hand edit); versions makes weak pairs of noted moments the next version changed; score prints the moments it expects a note on first, then every axis per window with --json, a sheet PNG with --sheet, or the piece second by second in words with --timeline; profile takes the ranges of work you admire (loudness, tilt, cut rate, motion, brightness, contrast, saturation, sharpness), checked leave-one-out, and score --profile says what falls outside them, where and which way; report says each head's held-out score, labels, cheats, gate and what it can't judge; which says the one that judges a piece (its project's, its workspace's, then yours) and why, use pins one there, diff lists the axes two fingerprints rank the same evidence most differently on, and share copies one's taxonomy and evidence (no heads, no media) into a project or workspace for its team; reembed moves a fingerprint's evidence to this machine's encoders, re-embedding the rows whose media it finds; read has a fresh kimi or claude session read a project's pinned notes into kinds and axes, readings puts them to you to check and tallies your answers, and learn-notes makes the defects and praise evidence once you've agreed with 45 kinds and 40 axes in 50, each project's in the fingerprint that judges it; move takes a child's own labels (by axis, source or project) up into a fingerprint it extends, which never reads them otherwise)";
/// Evaluates a .ts file's default export to its JSON (the CLI's spec host)
pub type Eval = fn(&Path) -> Result<String, String>;
/// The flags each verb takes, and whether each takes a value
-pub(crate) const FLAGS: [(&str, bool); 28] = [
+pub(crate) const FLAGS: [(&str, bool); 30] = [
("--fp", true),
+ ("--to", true),
+ ("--source", true),
("--kinds", true),
("--tags", true),
("--who", true),
@@ -125,10 +128,10 @@ pub fn cli(args: &[String], eval: Eval) -> i32 {
"which" => pick::which_here(&args[1..], &std::env::current_dir().unwrap_or_default()),
"diff" => pick::diff_here(&args[1..]),
"read" => notes::read_here(&args[1..], &std::env::current_dir().unwrap_or_default()),
- "readings" => notes::readings_here(&args[1..]),
+ "readings" => notes::readings_here(&args[1..], &std::env::current_dir().unwrap_or_default()),
"share" => pick::share_here(&args[1..], &std::env::current_dir().unwrap_or_default()),
"use" => pick::use_here(&args[1..], &std::env::current_dir().unwrap_or_default()),
- "new" | "bootstrap" | "teach" | "approve" | "pair" | "versions" | "learn-notes" | "reembed" | "profile" | "score" | "stop" => {
+ "new" | "bootstrap" | "teach" | "approve" | "pair" | "versions" | "learn-notes" | "move" | "reembed" | "profile" | "score" | "stop" => {
let cwd = std::env::current_dir().unwrap_or_default();
let here = has(args, "--here") || std::env::var_os("RAEA_FINGERPRINT_HERE").is_some();
let (out, code) = if here { serve::here(args, &cwd, eval) } else { serve::call(args, &cwd) };
diff --git a/apps/fingerprint/src/moving.rs b/apps/fingerprint/src/moving.rs
new file mode 100644
index 00000000..a25cbd09
--- /dev/null
+++ b/apps/fingerprint/src/moving.rs
@@ -0,0 +1,86 @@
+//! `raea fingerprint move [--fp CHILD] [--to PARENT] [--axis A] [--source S] [--project P]` (docs/fingerprint.feature
+//! FP14d). A note or mark teaches the fingerprint that judged the piece, and a parent never reads a child's evidence
+//! (inherit.rs), so one client's taste doesn't move the person's own. Moving labels up is the person's call: the
+//! child's own rows that match leave its ledger for a fingerprint it extends (its nearest unless --to names one). A
+//! row on an axis the parent hasn't, or on one the child says otherwise, stays: in the parent it would mean something
+//! else.
+
+use crate::{Eval, flag};
+use anyhow::{Result, anyhow, bail};
+use raea_sys_fingerprint::evidence::{Ledger, Row};
+use raea_sys_fingerprint::folder::Folder;
+use raea_sys_fingerprint::inherit;
+use raea_sys_fingerprint::taxonomy::Fingerprint;
+use std::collections::BTreeSet;
+
+/// The rows `pick` takes from `child` into `parent`; returns how many moved
+pub fn rows(child: &mut Ledger, parent: &mut Ledger, pick: &dyn Fn(&Row) -> bool) -> usize {
+ let mut n = 0;
+ for i in 0..child.rows.len() {
+ if pick(&child.rows[i]) {
+ parent.push(child.rows[i].clone(), child.features(i));
+ n += 1;
+ }
+ }
+ child.retain(|r| !pick(r));
+ n
+}
+
+/// The axes a row may carry into `parent`: the parent's own and inherited ones, less those the child overrides
+pub fn carried(parent: &Fingerprint, eval: Eval, over: &BTreeSet<String>) -> BTreeSet<String> {
+ let full = inherit::axes(parent, &inherit::parents(parent, Some(eval)));
+ full.axes.iter().map(|a| a.name.clone()).filter(|a| !over.contains(a)).chain(["*".to_string()]).collect()
+}
+
+/// Moves the child's matching rows up and writes both ledgers; returns the parent's name and what it did
+pub(crate) fn up(dir: &Folder, child: &Fingerprint, args: &[String], eval: Eval) -> Result<(String, String)> {
+ let (axis, source, project) = (flag(args, "--axis"), flag(args, "--source"), flag(args, "--project"));
+ if axis.is_none() && source.is_none() && project.is_none() {
+ bail!("say which labels: --axis A, --source S (note, teach, approval, pair, damage) or --project P");
+ }
+ let parents = inherit::parents(child, Some(eval));
+ let (pdir, parent) = match flag(args, "--to") {
+ Some(n) => parents.iter().find(|(_, p)| p.name == n).ok_or_else(|| anyhow!("{} doesn't extend {n}: labels only move up", child.name))?,
+ None => parents.first().ok_or_else(|| anyhow!("{} extends nothing, so its labels have nowhere to move up to", child.name))?,
+ };
+ let keep = carried(parent, eval, &inherit::overrides(child, &parents));
+ let wanted = |r: &Row| axis.is_none_or(|a| r.axis == a) && source.is_none_or(|s| r.source == s) && project.is_none_or(|p| r.project == p);
+ let (mut lc, mut lp) = (dir.ledger()?, pdir.ledger()?);
+ let stay = lc.rows.iter().filter(|r| wanted(r) && !keep.contains(&r.axis)).count();
+ let n = rows(&mut lc, &mut lp, &|r| wanted(r) && keep.contains(&r.axis));
+ if n == 0 && stay == 0 {
+ bail!("none of {}'s own labels match", child.name);
+ }
+ pdir.write_ledger(&lp)?;
+ dir.write_ledger(&lc)?;
+ let mut out = format!("{n} labels moved from {} up to {}\n", child.name, parent.name);
+ if stay > 0 {
+ out += &format!("{stay} stay: their axes are {}'s own, and would mean something else in {}\n", child.name, parent.name);
+ }
+ Ok((parent.name.clone(), out))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn row(axis: &str, source: &str) -> Row {
+ Row { media: "m".into(), a: 0.0, b: 2.0, axis: axis.into(), bad: true, weight: 1.0, who: "me".into(), source: source.into(), project: "p".into(), kind: None, region: None, words: None, at: 0, pin: None }
+ }
+
+ #[test]
+ fn only_picked_rows_move_and_keep_their_features() {
+ let w = raea_sys_fingerprint::evidence::width();
+ let (mut c, mut p) = (Ledger::default(), Ledger::default());
+ c.push(row("blur", "note"), &vec![1.0; w]);
+ c.push(row("glow", "note"), &vec![2.0; w]);
+ c.push(row("blur", "damage"), &vec![3.0; w]);
+ p.push(row("hiss", "teach"), &vec![4.0; w]);
+ let n = rows(&mut c, &mut p, &|r| r.source == "note" && r.axis == "blur");
+ assert_eq!(n, 1);
+ assert_eq!(c.rows.iter().map(|r| r.axis.as_str()).collect::<Vec<_>>(), ["glow", "blur"]);
+ assert_eq!((c.features(0)[0], c.features(1)[0]), (2.0, 3.0), "the child's rows keep their own features");
+ assert_eq!(p.rows.len(), 2);
+ assert_eq!(p.features(1)[0], 1.0, "a moved row carries its features");
+ }
+}
diff --git a/apps/fingerprint/src/notes.rs b/apps/fingerprint/src/notes.rs
index 80930e59..73a7cceb 100644
--- a/apps/fingerprint/src/notes.rs
+++ b/apps/fingerprint/src/notes.rs
@@ -139,7 +139,7 @@ pub(crate) fn read_here(args: &[String], cwd: &Path) -> i32 {
let w = words(args)?;
let project = w.first().map_or(cwd.to_path_buf(), |p| cwd.join(p));
let by = flag(args, "--by").unwrap_or("kimi");
- let dir = crate::pick::chosen(args, Some(&project.join("x.mp4"))).0;
+ let dir = crate::pick::chosen(args, Some(&crate::pick::piece_in(args, cwd))).0;
let fp = dir.read(None).map_err(|e| e.to_string())?;
let mut notes = pinned(&project);
let mut kept = readings_of(&dir);
@@ -185,9 +185,9 @@ pub fn earned(r: &[Reading]) -> bool {
/// The choices a reading is checked with, and what each says about kind and axis
pub const CHOICES: [(&str, bool, bool); 4] = [("Right", true, true), ("Right kind, wrong axis", true, false), ("Wrong kind", false, false), ("Right axis, wrong kind", false, true)];
-/// `raea fingerprint readings [--ask N] [--tally]`
-pub(crate) fn readings_here(args: &[String]) -> i32 {
- let dir = crate::pick::chosen(args, None).0;
+/// `raea fingerprint readings [PROJECT] [--ask N] [--tally]`: the readings kept in the fingerprint that judges PROJECT
+pub(crate) fn readings_here(args: &[String], cwd: &Path) -> i32 {
+ let dir = crate::pick::chosen(args, Some(&crate::pick::piece_in(args, cwd))).0;
let mut r = readings_of(&dir);
if let Some(n) = flag(args, "--ask").and_then(|n| n.parse::<usize>().ok()) {
let todo: Vec<usize> = r.iter().enumerate().filter(|(_, x)| x.kind_ok.is_none()).map(|(i, _)| i).take(n).collect();
@@ -249,7 +249,9 @@ pub(crate) fn learn(enc: &mut raea_sys_columns::Encoders, dir: &Folder, l: &mut
let (k, a, n) = agreement(&r);
anyhow::bail!("notes don't train yet: {n} readings checked, kind right {:?}, axis right {:?} (FP5b needs 50 checked, 90% and 80%: raea fingerprint readings --ask 50)", k, a);
}
- l.retain(|x| x.source != "note");
+ // only these readings' rows are remade: notes another fingerprint's person moved up here (FP14d) stay
+ let ids: std::collections::BTreeSet<&str> = r.iter().map(|x| x.note.as_str()).collect();
+ l.retain(|x| x.source != "note" || !x.kind.as_deref().is_some_and(|k| ids.contains(k)));
let mut made = 0;
for x in r.iter().filter(|x| x.kind_ok != Some(false) && x.axis_ok != Some(false)) {
let bad = match x.kind.as_str() {
diff --git a/apps/fingerprint/src/pick.rs b/apps/fingerprint/src/pick.rs
index 5fa7c6a4..7e77f564 100644
--- a/apps/fingerprint/src/pick.rs
+++ b/apps/fingerprint/src/pick.rs
@@ -19,6 +19,12 @@ pub(crate) fn chosen(args: &[String], file: Option<&Path>) -> (Folder, Option<Ch
(Folder::named(&n), None)
}
+/// A piece in the project a verb names (its first word, else the current folder), so `read`, `readings` and
+/// `learn-notes` keep a project's notes in the fingerprint that judges it (FP14d)
+pub(crate) fn piece_in(args: &[String], cwd: &Path) -> PathBuf {
+ here(cwd, args, 0).join("piece.mp4")
+}
+
fn here(cwd: &Path, args: &[String], at: usize) -> PathBuf {
let w = words(args).unwrap_or_default();
w.get(at).map_or_else(|| cwd.to_path_buf(), |p| cwd.join(p))
diff --git a/apps/fingerprint/src/verbs.rs b/apps/fingerprint/src/verbs.rs
index e7a20ccc..83e33fc7 100644
--- a/apps/fingerprint/src/verbs.rs
+++ b/apps/fingerprint/src/verbs.rs
@@ -27,7 +27,8 @@ pub(crate) fn run(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval, s
"approve" => approved(enc, rest, cwd, eval),
"reembed" => reembedded(enc, rest, cwd, eval),
"pair" | "versions" => paired(enc, args[0].as_str(), rest, cwd, eval),
- "learn-notes" => learned(enc, rest, eval),
+ "learn-notes" => learned(enc, rest, cwd, eval),
+ "move" => moved(enc, rest, eval),
"profile" => {
let dir = crate::pick::chosen(rest, None).0;
crate::profiles::make(enc, &dir, rest, cwd).map(|o| (o, 0))
@@ -191,9 +192,10 @@ fn paired(enc: &mut Encoders, verb: &str, args: &[String], cwd: &Path, eval: Eva
Ok((out, 0))
}
-/// `learn-notes` (notes.rs, FP5a): checked readings as evidence, then the heads retrained
-fn learned(enc: &mut Encoders, args: &[String], eval: Eval) -> Result<(String, i32)> {
- let (dir, fp, w) = open(enc, args, eval, None)?;
+/// `learn-notes [PROJECT]` (notes.rs, FP5a): checked readings as evidence in the fingerprint that judges the project
+/// (FP14d), then its heads retrained
+fn learned(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result<(String, i32)> {
+ let (dir, fp, w) = open(enc, args, eval, Some(&crate::pick::piece_in(args, cwd)))?;
let mut l = dir.ledger()?;
let out = crate::notes::learn(enc, &dir, &mut l)?;
dir.write_ledger(&l)?;
@@ -201,6 +203,16 @@ fn learned(enc: &mut Encoders, args: &[String], eval: Eval) -> Result<(String, i
Ok((out, 0))
}
+/// `move` (moving.rs, FP14d): a child's own labels up into a fingerprint it extends, then both retrained
+fn moved(enc: &mut Encoders, args: &[String], eval: Eval) -> Result<(String, i32)> {
+ let (dir, fp, w) = open(enc, args, eval, None)?;
+ let (to, out) = crate::moving::up(&dir, &dir.read(Some(eval))?, args, eval)?;
+ retrain(&dir, &fp, &w, &dir.ledger()?, None)?;
+ let (pd, pfp, pw) = open(enc, &["--fp".into(), to], eval, None)?;
+ retrain(&pd, &pfp, &pw, &pd.ledger()?, None)?;
+ Ok((out, 0))
+}
+
fn teach(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result<(String, i32)> {
let file = at(cwd, words(args).map_err(|e| anyhow!(e))?.first().ok_or_else(|| anyhow!("which file?"))?);
let (dir, fp, w) = open(enc, args, eval, Some(&file))?;
diff --git a/docs/fingerprint.feature b/docs/fingerprint.feature
index b50f7e0a..fd19d3f5 100644
--- a/docs/fingerprint.feature
+++ b/docs/fingerprint.feature
@@ -484,6 +484,10 @@ Feature: Fingerprint: a person's or a team's sense of good work, learned on thei
Scenario: FP14d. A note teaches the one that judged
Then a note or mark on a piece is evidence in the fingerprint that judged that piece, so labels land where the
taste they express applies, and a parent sees them only if the person moves them up (`raea fingerprint move`)
+ And so far (11-12): teach, approve and pair label the fingerprint `which` picks for the file; read, readings and
+ learn-notes keep a project's notes in the one that judges the project, and learning again remakes only those
+ notes' rows. `move [--fp CHILD] [--to PARENT] --axis/--source/--project` takes the child's own matching rows up
+ into a fingerprint it extends and retrains both; rows on an axis the parent lacks or the child overrides stay
@needs:FP14c
Scenario: FP14e. Managing them in the app
diff --git a/docs/manual/guides/fingerprint.md b/docs/manual/guides/fingerprint.md
index d32c9a3f..10d7b16c 100644
--- a/docs/manual/guides/fingerprint.md
+++ b/docs/manual/guides/fingerprint.md
@@ -69,6 +69,13 @@ raea fingerprint use client-ads --in project projects/brand
Which one judges a piece is decided by where it lives: the project's fingerprints first, then the workspace's, then
your own. At each level, the one whose `applies` matches the piece's kind wins, else that level's default.
+Your notes and marks on a piece teach the fingerprint that judged it, so a client's notes stay with the client's
+fingerprint. When one of its lessons is really yours, move it up:
+
+```sh
+raea fingerprint move --fp client-ads --axis glow # its glow labels become yours (me)
+```
+
## Profiles of work you admire
```sh