mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 21:03:47 -10:00
The rules are raea/goal's (sdk/goal), run by `raea goal check` at four moments: the hook after a save, every render's end, raea cloud's publish, and the Stop hook. Rust's cut and goal gates and the box's word, sound, frame and place checks are packs (MK30-MK39); runtime/cut-plan, runtime/goal-plan, raea make status and the box's check code are gone with no alias (MK41). brief.ts is the one registered root (MK43): raea runs it, and every file that imports raea must be reached from it (the registered check, an error at publish and done). Its tasks are its `plan` (MK44), read from its run and written back where each is written by `raea goal tasks`, the one path for the app, agents and the box. Its `goal` is one goal or a workflow of several (MK46), each with its step, after and rules, checked and reported alone. Taste lines and signed asks run inside the loop (MK47). `raea goal check|tasks|seen|judge|gates|next` is the loop; `raea make clothes|motion|solid|wear|splat|physics|bake| sao|tokensynth|sounds|component|blockout|...` the asset tools (MK45). Old names are refused with where they went. docs/make.feature is docs/goal.feature; tools/legacy-names.sh holds the old names out. raea's Node mode on JavaScriptCore now gives a CommonJS package's names as named exports (React's jsx), loads a file a tool imports by URL, keeps process.exit's code from a promise callback, and reads stdin as fd 0, so the goal runner runs on the shipped binary.
110 lines
6.2 KiB
TypeScript
110 lines
6.2 KiB
TypeScript
// raea cloud's pure parts, checked without a container: node test/units.ts
|
|
// (gpu.ts reads vulkaninfo's summary and picks the device; offload.ts plans which project a render sends and how its
|
|
// paths read on the worker)
|
|
|
|
import assert from "node:assert/strict"
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"
|
|
import os from "node:os"
|
|
import path from "node:path"
|
|
import { parseSummary, pick } from "../server/gpu.ts"
|
|
import { plan, projectRoot } from "../server/offload.ts"
|
|
import { shellEnv } from "../server/shell-os.ts"
|
|
import { landedQuery, linkIn, packCredential, unpackCredential } from "../server/google-token.ts"
|
|
|
|
const L4 = `Devices:
|
|
========
|
|
GPU0:
|
|
apiVersion = 1.3.289
|
|
driverVersion = 580.95.5.0
|
|
vendorID = 0x10de
|
|
deviceID = 0x27b8
|
|
deviceType = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
|
deviceName = NVIDIA L4
|
|
driverID = DRIVER_ID_NVIDIA_PROPRIETARY
|
|
driverName = NVIDIA
|
|
driverInfo = 580.95.05
|
|
GPU1:
|
|
apiVersion = 1.4.305
|
|
vendorID = 0x10005
|
|
deviceType = PHYSICAL_DEVICE_TYPE_CPU
|
|
deviceName = llvmpipe (LLVM 19.1.7, 256 bits)
|
|
driverName = llvmpipe
|
|
driverInfo = Mesa 25.0.7-2 (LLVM 19.1.7)
|
|
`
|
|
const gpus = parseSummary(L4)
|
|
assert.equal(gpus.length, 2)
|
|
assert.deepEqual(gpus[0], { name: "NVIDIA L4", type: "discrete", driver: "NVIDIA 580.95.05", vendor: "0x10de" })
|
|
assert.equal(gpus[1].type, "cpu")
|
|
assert.deepEqual(pick(gpus), { renders: "gpu", name: "NVIDIA L4" })
|
|
assert.deepEqual(pick([gpus[1]]), { renders: "cpu", name: "llvmpipe (LLVM 19.1.7, 256 bits)" })
|
|
assert.deepEqual(pick([]), { renders: "cpu", name: "llvmpipe" })
|
|
|
|
const root = mkdtempSync(path.join(os.tmpdir(), "raea-units-"))
|
|
try {
|
|
const proj = path.join(root, "work", "card")
|
|
mkdirSync(path.join(proj, "scenes"), { recursive: true })
|
|
writeFileSync(path.join(proj, "package.json"), "{}")
|
|
writeFileSync(path.join(proj, "scenes", "edit.tsx"), "")
|
|
writeFileSync(path.join(proj, "words.json"), "[]")
|
|
writeFileSync(path.join(root, "work", "elsewhere.json"), "[]")
|
|
const work = path.join(root, "work")
|
|
|
|
// the composition's project is the nearest folder above it with a project's files
|
|
assert.equal(projectRoot("card/scenes/edit.tsx", work, root), proj)
|
|
// from the workspace root: paths made relative to the project, the flags' values left alone
|
|
assert.deepEqual(plan(["render", "card/scenes/edit.tsx", "-o", "card/out/x.mp4", "--frames", "30"], work), {
|
|
root: proj,
|
|
args: ["render", "scenes/edit.tsx", "-o", "out/x.mp4", "--frames", "30"],
|
|
moves: [],
|
|
})
|
|
// an output outside the project is written at its top as .raea-cloud-out-N-NAME (no folder to make) and moved after
|
|
const p = plan(["render", "scenes/edit.tsx", "-o", "/tmp/x.mp4", "--words", "words.json"], proj)
|
|
assert.ok(typeof p !== "string")
|
|
assert.deepEqual(p.args, ["render", "scenes/edit.tsx", "-o", ".raea-cloud-out-0-x.mp4", "--words", "words.json"])
|
|
assert.deepEqual(p.moves, [{ from: ".raea-cloud-out-0-x.mp4", to: "/tmp/x.mp4" }])
|
|
// an input outside the project can't go
|
|
assert.match(plan(["render", "scenes/edit.tsx", "-o", "x.mp4", "--words", "../elsewhere.json"], proj) as string, /outside the project/)
|
|
// no composition: nothing to send
|
|
assert.match(plan(["render", "--help"], proj) as string, /names no composition/)
|
|
// RAEA_CLOUD_GPU_ROOT widens what's sent
|
|
assert.equal((plan(["render", "card/scenes/edit.tsx", "-o", "x.mp4", "--words", "elsewhere.json"], work, ".") as { root: string }).root, work)
|
|
} finally {
|
|
rmSync(root, { recursive: true, force: true })
|
|
}
|
|
|
|
// the box's shell on Windows: its own folder first on PATH, whatever case Windows gave the name; untouched elsewhere
|
|
assert.deepEqual(shellEnv({ Path: "C:\\w" }, true, "C:\\g\\usr\\bin\\sh.exe"), { Path: "C:\\g\\usr\\bin;C:\\w" })
|
|
assert.deepEqual(shellEnv({ PATH: "C:\\w" }, true, "bash"), { PATH: "C:\\w" })
|
|
assert.deepEqual(shellEnv({ PATH: "/usr/bin" }, false, "/bin/bash"), { PATH: "/usr/bin" })
|
|
console.log("units: ok")
|
|
|
|
// google-token.ts: Antigravity's Google sign-in link, the address the browser lands on, the credential's files
|
|
{
|
|
const out = `I1124 credential_manager.py:561] Launching browser login flow...\nhttps://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=x.apps.googleusercontent.com&redirect_uri=http%3A%2F%2F127.0.0.1%3A54616%2F&state=abc123&access_type=offline\n`
|
|
const l = linkIn(out)!
|
|
assert.equal(l.port, 54616)
|
|
assert.equal(l.state, "abc123")
|
|
assert.equal(linkIn("https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=https%3A%2F%2Fevil.example%2F&state=x"), undefined, "a link back anywhere but this box is refused")
|
|
assert.equal(landedQuery("http://127.0.0.1:54616/?state=abc123&code=4/0Ab&scope=email", l), "/?state=abc123&code=4/0Ab&scope=email")
|
|
assert.throws(() => landedQuery("http://127.0.0.1:54616/?state=other&code=4/0Ab", l), /another sign-in/)
|
|
assert.throws(() => landedQuery("http://127.0.0.1:9999/?state=abc123&code=4/0Ab", l), /isn't the page/)
|
|
assert.throws(() => landedQuery("http://127.0.0.1:54616/?state=abc123", l), /no code/)
|
|
assert.throws(() => landedQuery("http://127.0.0.1:54616/?error=access_denied&state=abc123", l), /access_denied/)
|
|
assert.throws(() => landedQuery("4/0Ab-just-a-code", l), /whole address/)
|
|
const home = mkdtempSync(path.join(os.tmpdir(), "units-gemini-"))
|
|
mkdirSync(path.join(home, "antigravity-acp"), { recursive: true })
|
|
writeFileSync(path.join(home, "antigravity-acp", "oauth.json"), '{"refresh_token":"1//x","email":"[email protected]"}')
|
|
writeFileSync(path.join(home, "antigravity-acp", "settings.json"), '{"theme":"dark"}')
|
|
const c = packCredential(home)!
|
|
assert.ok(c.startsWith("agy1:"))
|
|
assert.deepEqual(Object.keys(JSON.parse(Buffer.from(c.slice(5), "base64").toString())), ["antigravity-acp/oauth.json"], "only the token file goes")
|
|
const other = mkdtempSync(path.join(os.tmpdir(), "units-gemini-"))
|
|
unpackCredential(c, other)
|
|
assert.equal(packCredential(other), c)
|
|
assert.throws(() => unpackCredential(`agy1:${Buffer.from(JSON.stringify({ "../../etc/x": "y" })).toString("base64")}`, other), /outside its folder/)
|
|
rmSync(home, { recursive: true, force: true })
|
|
rmSync(other, { recursive: true, force: true })
|
|
console.log("ok google-token")
|
|
}
|
|
|