mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 08:46:06 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f68805b981 |
No files matched your search
@@ -8,7 +8,7 @@
|
||||
{
|
||||
"name": "raea",
|
||||
"source": { "source": "git-subdir", "url": "https://github.com/shinyobjectz/raea-skills.git", "path": "skills" },
|
||||
"description": "Make video, motion graphics, games and 3D scenes with raea, the Render Anything Engine: the raea skill, and hooks that show media in the raea app instead of the Mac's viewer and run raea check on the brief's goals as a turn ends (nothing is checked after a save: a render checks its own output)."
|
||||
"description": "Make video, motion graphics, games and 3D scenes with raea, the Render Anything Engine: the raea skill, and hooks that run raea's quick check on a composition after it's saved and show media in the raea app instead of the Mac's viewer."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# vendor/bevy_pbr's shaders keep LF on every checkout. raea replaces some of them with its own forks only after checking
|
||||
# Bevy's is still the one the fork was taken from, by its bytes' hash (raea_sys_frame::bevy_api::swap_embedded_shader),
|
||||
# and a Windows checkout turns LF into CRLF: 0.1.9-rc1's Windows build panicked on volumetric_fog.wesl at its first render
|
||||
vendor/bevy_pbr/**/*.wesl text eol=lf
|
||||
vendor/bevy_pbr/**/*.wgsl text eol=lf
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Bug report
|
||||
description: Something raea did wrong, with a way to see it happen.
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
For a security problem, use the Security tab, not a public issue. Leave out keys and anything private.
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: What `raea --version` prints, or the app's version from its About screen.
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: where
|
||||
attributes:
|
||||
label: Where
|
||||
options:
|
||||
- raea CLI (render, play, check, media, ...)
|
||||
- SDK (TypeScript, React)
|
||||
- raea app (desktop)
|
||||
- Install or update
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: machine
|
||||
attributes:
|
||||
label: Machine
|
||||
description: OS and version, CPU, and for a picture problem the GPU.
|
||||
placeholder: macOS 27.2, Apple Silicon
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: ran
|
||||
attributes:
|
||||
label: What you ran
|
||||
description: The command, and the smallest composition that shows it (paste the TSX).
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: happened
|
||||
attributes:
|
||||
label: What happened
|
||||
description: The output as printed. For a picture or sound problem, the frame or time and a screenshot.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: What you expected
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,8 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Security problem
|
||||
url: https://github.com/shinyobjectz/raea/security/advisories/new
|
||||
about: Report it privately, not in an issue.
|
||||
- name: Documentation
|
||||
url: https://raea.io/docs
|
||||
about: The CLI and SDK reference and the guides.
|
||||
@@ -1,23 +0,0 @@
|
||||
name: Feature request
|
||||
description: Something you want to make that raea can't do yet, or makes hard.
|
||||
body:
|
||||
- type: textarea
|
||||
id: making
|
||||
attributes:
|
||||
label: What you're trying to make
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: today
|
||||
attributes:
|
||||
label: What you do today
|
||||
description: The command, SDK part or app screen you use now, and where it falls short.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: want
|
||||
attributes:
|
||||
label: What you'd like
|
||||
description: An example of how you'd use it helps most.
|
||||
validations:
|
||||
required: true
|
||||
@@ -1,11 +0,0 @@
|
||||
## What changes
|
||||
|
||||
<!-- What triggered it, what raea did before, and what it does now. Link the issue. -->
|
||||
|
||||
## How it was checked
|
||||
|
||||
<!-- The commands you ran and what they printed. For a picture or sound change: the composition, the frame, your OS and GPU. -->
|
||||
|
||||
## What wasn't checked
|
||||
|
||||
<!-- Platforms or paths you couldn't try, and anything a reviewer should look at closely. -->
|
||||
+11
-44
@@ -1,8 +1,7 @@
|
||||
# raea's public CI (docs/public-first.feature PF5), on GitHub's hosted runners only: it runs code from pull requests,
|
||||
# so it never touches a self-hosted machine. What needs this Mac's GPU, VideoToolbox or audio (P26, UI parity, the
|
||||
# sound gates) stays the maintainers' L1/L2 (docs/agents.md); this is the part anyone can read and rerun.
|
||||
# every pull request and push to main guard (names and secrets), L0's repo-wide gates, sdk/cloud's local tests,
|
||||
# cargo check of the engine, the tests of every crate that needs no GPU
|
||||
# every pull request and push to main guard (names and secrets), L0's repo-wide gates, cargo check of the engine
|
||||
name: ci
|
||||
|
||||
on:
|
||||
@@ -69,9 +68,6 @@ jobs:
|
||||
run: bash tools/layers.sh
|
||||
- name: names
|
||||
run: bash tools/names.sh
|
||||
- name: legacy names
|
||||
# nothing names what raea's one loop replaced (docs/goal.feature MK41)
|
||||
run: bash tools/legacy-names.sh
|
||||
- name: size
|
||||
run: bash tools/size.sh
|
||||
- name: one-version
|
||||
@@ -94,24 +90,6 @@ jobs:
|
||||
- name: taxonomy
|
||||
run: bash tools/taxonomy.sh --check
|
||||
|
||||
cloud:
|
||||
# sdk/cloud's tests that need no container or farm (its npm test): the box server's pure parts and memory guard,
|
||||
# what a render sends the farm, and the farm's planner (its encode on ffmpeg), media and volume gate
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: false
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- name: ffmpeg
|
||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
||||
- name: sdk/cloud tests
|
||||
working-directory: sdk/cloud
|
||||
run: npm ci --no-fund --no-audit --loglevel=error && npm test
|
||||
|
||||
engine:
|
||||
# a fresh clone builds as the README says (public #14): the toolchain from rust-toolchain.toml, --locked
|
||||
strategy:
|
||||
@@ -126,41 +104,30 @@ jobs:
|
||||
lfs: false
|
||||
- name: Linux libraries
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libasound2-dev libfontconfig1-dev libvulkan-dev libudev-dev nasm ffmpeg
|
||||
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libasound2-dev libfontconfig1-dev libvulkan-dev libudev-dev nasm
|
||||
- name: macOS tools
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install cmake ninja nasm ffmpeg
|
||||
run: brew install cmake ninja nasm
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.4.2
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: cargo check
|
||||
run: cargo check --locked -p raea-cli --tests
|
||||
- name: unit tests (every crate with no GPU)
|
||||
- name: unit tests (the crates with no GPU or media device)
|
||||
# debug info off: with it the test binaries of the app crates filled 27 GB of a runner's disk (#90)
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
# The crates come from the lock file, so a new crate's tests run without anyone naming it: every workspace crate
|
||||
# that links neither wgpu nor Rolldown, then the few that link wgpu and whose tests need no GPU. All of wgpu's
|
||||
# side can't join: its test binaries would fill the runner's disk (#90). Left out, with the reason:
|
||||
# raea-sys-mlx its tests run on MLX's GPU device, and a hosted macOS runner has no Metal device
|
||||
# raea-bundle in a call of its own: Rolldown's crates turn on serde_json's arbitrary_precision, features unify
|
||||
# across one cargo call, and with it on an untagged enum can't read a number (raea-core-brief's make dials failed
|
||||
# here from 11-23 while passing alone). raea itself never links Rolldown: it loads it as a library at run time.
|
||||
# --no-fail-fast: one run names every crate whose tests fail, not only the first
|
||||
run: |
|
||||
ws=$(cargo metadata --locked --no-deps --format-version 1 | jq -r '.packages[].name' | sort)
|
||||
linked=$(for k in wgpu rolldown; do cargo tree --locked --workspace -i "$k" -e normal,build,dev --prefix none --format '{p}'; done | grep -F "($PWD/" | sed 's/ v[0-9].*//' | sort -u)
|
||||
light=$(comm -23 <(echo "$ws") <(echo "$linked") | grep -vx raea-sys-mlx | sed 's/^/-p /')
|
||||
cargo test --locked --no-fail-fast $light -p raea-runtime-plugins -p raea-runtime-live -p raea-app-check -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
cargo test --locked -p raea-bundle
|
||||
run: cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
- name: Windows' and Linux's own (#169)
|
||||
# what a Windows or Linux user meets that needs a feature the step above doesn't turn on: openh264 at --quality
|
||||
# master (raea-io-soft's tests/quality.rs, its h264 feature) and raea's Node core under the agent shell
|
||||
# (raea-native's tests/node.rs, its modules feature: Node's names for the system, Windows' paths). QuickJS's
|
||||
# Intl (raea-runtime-jsengine, on Linux) and git found or fetched (raea-io-assets) run in the step above
|
||||
# what a Windows or Linux user meets that no other step ran: QuickJS's Intl (raea-runtime-jsengine's
|
||||
# quickjs_formats_as_javascriptcore_does, on Linux), openh264 at --quality master (raea-io-soft), git found or
|
||||
# fetched (raea-io-assets), and raea's Node core under the agent shell (raea-native's tests/node.rs: Node's names
|
||||
# for the system, Windows' paths); tests/node.rs needs raea-native's modules feature and tests/quality.rs
|
||||
# raea-io-soft's h264
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
run: |
|
||||
cargo test --locked -p raea-native --features modules --test node
|
||||
cargo test --locked -p raea-io-soft --features h264
|
||||
cargo test --locked -p raea-runtime-jsengine -p raea-io-assets
|
||||
@@ -2,7 +2,6 @@
|
||||
# Apple Silicon, Linux on x86_64 and Windows on x86_64 are built from the tag on GitHub's runners, packed by
|
||||
# tools/release.sh, checked by tools/release-check.sh, attested (anyone can check a download with
|
||||
# `gh attestation verify raea-VERSION-macos-arm64.tar.gz -R shinyobjectz/raea`) and attached to the tag's release.
|
||||
# Linux also packages and checks an AppImage from the same verified archive (tools/release-appimage.sh).
|
||||
# The skills gate reads the feed app, which is private, so it runs in a maintainer's checkout first
|
||||
# (tools/skills.sh check), and the tag names the commit it passed on; tools/release.sh checks the gate's inputs haven't
|
||||
# changed since (tools/release/skills-passed.sh):
|
||||
@@ -182,11 +181,6 @@ jobs:
|
||||
v=${TAG#v}
|
||||
if [ "$RUNNER_OS" = Linux ]; then xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release.sh "$v" ship HEAD
|
||||
else bash tools/release.sh "$v" ship HEAD; fi
|
||||
- name: Package and check the Linux AppImage
|
||||
if: runner.os == 'Linux'
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/appimage-check
|
||||
run: xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release-appimage.sh "${TAG#v}" "dist/raea-${TAG#v}-linux-x86_64.tar.gz"
|
||||
# a failed check's own files (the app check's frames, every step's log), not the unpacked release
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
@@ -195,8 +189,6 @@ jobs:
|
||||
path: |
|
||||
${{ runner.temp }}/release-check/app
|
||||
${{ runner.temp }}/release-check/**/*.log
|
||||
${{ runner.temp }}/appimage-check/app
|
||||
${{ runner.temp }}/appimage-check/**/*.log
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
# the stripped binaries' symbols (#88), for symbolicating a crash report from this release; never published
|
||||
@@ -210,10 +202,6 @@ jobs:
|
||||
if: ${{ !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.tar.gz
|
||||
- uses: actions/attest-build-provenance@v2
|
||||
if: ${{ runner.os == 'Linux' && !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.AppImage
|
||||
- name: Attach to the release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
@@ -221,16 +209,11 @@ jobs:
|
||||
run: |
|
||||
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" ${{ contains(env.TAG, '-') && '--prerelease' || '' }} --title "raea ${TAG#v}" --notes "Built by .github/workflows/release.yml; notes follow."
|
||||
gh release upload "$TAG" dist/raea-*.tar.gz dist/raea-*.tar.gz.sha256 --clobber
|
||||
if [ "$RUNNER_OS" = Linux ]; then
|
||||
gh release upload "$TAG" dist/raea-*.AppImage dist/raea-*.AppImage.sha256 --clobber
|
||||
fi
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ inputs.dry_run }}
|
||||
with:
|
||||
name: dry-run-${{ runner.os }}
|
||||
path: |
|
||||
dist/raea-*.tar.gz*
|
||||
dist/raea-*.AppImage*
|
||||
path: dist/raea-*.tar.gz*
|
||||
retention-days: 3
|
||||
compression-level: 0
|
||||
|
||||
@@ -240,9 +223,6 @@ jobs:
|
||||
# (tools/release/win-bundle.sh), as Microsoft documents for app-local deployment.
|
||||
windows:
|
||||
runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }}
|
||||
# the signing identity's federated credential trusts this repository's environment "signing" and nothing else
|
||||
# (Azure app raea-release-signing); with no identity set there is no environment, and the zip is unsigned
|
||||
environment: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && 'signing' || '' }}
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the compile cache, as build's
|
||||
@@ -372,24 +352,9 @@ jobs:
|
||||
run: bash tools/release/lavapipe.sh
|
||||
- name: Where the skills gate passed
|
||||
run: bash tools/release/skills-passed.sh "$TAG" "${{ inputs.skills_passed }}"
|
||||
# raea's own Windows programs signed (#221), once the repository has the signing identity: the variables
|
||||
# AZURE_SIGN_CLIENT_ID, AZURE_SIGN_TENANT_ID and AZURE_SIGN_SUBSCRIPTION_ID name an Azure app whose federated
|
||||
# credential trusts this workflow and which holds the Artifact Signing Certificate Profile Signer role on the
|
||||
# account (no secret is stored: the job's own token is exchanged). Without them the zip is unsigned, as before
|
||||
- name: Sign in to Azure for signing
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ vars.AZURE_SIGN_CLIENT_ID }}
|
||||
tenant-id: ${{ vars.AZURE_SIGN_TENANT_ID }}
|
||||
subscription-id: ${{ vars.AZURE_SIGN_SUBSCRIPTION_ID }}
|
||||
- name: jsign (signs raea's programs)
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
run: choco install jsign -y --no-progress
|
||||
- name: Pack and check (tools/release.sh)
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/release-check
|
||||
RAEA_WIN_SIGN: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && '1' || '' }}
|
||||
run: bash tools/release.sh "${TAG#v}" target/dist HEAD
|
||||
# live play on Windows (PT20 left it unproven): bevy-ts's play cases, `play --offscreen` with an input script and
|
||||
# a snapshot's pixels probed, run by the raea just built; check.sh reads the pixels with ImageMagick, which the
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
# raea built natively for Windows on ARM (#82: a Snapdragon X runs the x64 build under emulation, and asked for its
|
||||
# own). GitHub's windows-11-arm runner builds what release.yml's windows job builds, for aarch64-pc-windows-msvc, runs
|
||||
# `raea --version`, packs and checks raea-VERSION-windows-arm64.zip with tools/release.sh (RAEA_WIN_ARCH=arm64)
|
||||
# without drawing (RAEA_CHECK_NO_GPU=1: WARP segfaults in Bevy's compute shaders here as on x64, and Mesa's lavapipe has
|
||||
# no ARM64 build; a Snapdragon PC is what draws, #82), and on a v* tag attaches it to that
|
||||
# release. It runs beside release.yml, not in it, so a release never waits on or fails with the ARM64 build; a
|
||||
# promoted release (release-go.sh) builds it again from the tag. install.ps1 takes it on an ARM64 PC when it's there.
|
||||
name: windows-arm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: "commit, branch or tag to build"
|
||||
required: false
|
||||
version:
|
||||
description: "the version the zip is named for (raea-VERSION-windows-arm64.zip)"
|
||||
required: false
|
||||
push:
|
||||
branches: [windows-arm64]
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-11-arm
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the release builds' compile cache (tools/release/compile-cache.sh), under this OS and architecture's own prefix
|
||||
RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
submodules: true
|
||||
lfs: false
|
||||
- name: Toolchain (rust-toolchain.toml's pin)
|
||||
run: |
|
||||
if ! command -v rustup >/dev/null; then
|
||||
curl -fsSL --retry 3 -o "$RUNNER_TEMP/rustup-init.exe" https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe
|
||||
"$RUNNER_TEMP/rustup-init.exe" -y --default-toolchain none --profile minimal
|
||||
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$USERPROFILE/.cargo/bin:$PATH"
|
||||
fi
|
||||
rustup show active-toolchain || rustup toolchain install
|
||||
rustc -vV
|
||||
# ring builds its aarch64 assembly with clang (and only clang) on Windows
|
||||
- name: clang (ring's assembly)
|
||||
run: |
|
||||
if ! command -v clang >/dev/null; then
|
||||
for d in "/c/Program Files/LLVM/bin" "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/Llvm/ARM64/bin; do
|
||||
[ -x "$d/clang.exe" ] && { echo "$d" >> "$GITHUB_PATH"; export PATH="$d:$PATH"; break; }
|
||||
done
|
||||
fi
|
||||
command -v clang >/dev/null || { winget install -e --id LLVM.LLVM --accept-source-agreements --accept-package-agreements --silent; echo "/c/Program Files/LLVM/bin" >> "$GITHUB_PATH"; export PATH="/c/Program Files/LLVM/bin:$PATH"; }
|
||||
clang --version
|
||||
- name: jq that writes LF
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/jq"
|
||||
printf '#!/bin/bash\nexec "%s" -b "$@"\n' "$(command -v jq)" > "$RUNNER_TEMP/jq/jq"
|
||||
chmod +x "$RUNNER_TEMP/jq/jq"
|
||||
echo "$RUNNER_TEMP/jq" >> "$GITHUB_PATH"
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.4.2
|
||||
- name: The runtime's packages
|
||||
run: for d in sdk/react/js sdk/react/tw; do (cd "$d" && bun install --frozen-lockfile); done
|
||||
# (an sccache the action can't fetch for ARM64 Windows leaves the build uncached, as compile-cache.sh does)
|
||||
- name: Compile cache (sccache, as release.yml's)
|
||||
if: env.AWS_ACCESS_KEY_ID != ''
|
||||
continue-on-error: true
|
||||
uses: mozilla-actions/[email protected]
|
||||
- name: Use the compile cache
|
||||
if: env.AWS_ACCESS_KEY_ID != ''
|
||||
run: bash tools/release/compile-cache.sh
|
||||
- name: Build
|
||||
run: |
|
||||
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
|
||||
t() { s=$SECONDS; "$@"; echo "::notice::Windows ARM64 $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
|
||||
t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
t cargo build --profile dist --locked -p raea-rune-host
|
||||
t cargo build --profile dist --locked -p raea-page-host --features window
|
||||
t cargo build --profile dist --locked -p raea-perceive
|
||||
- name: What raea.exe is and imports
|
||||
run: |
|
||||
file target/dist/raea.exe || true
|
||||
dumpbin=$(ls "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/MSVC/*/bin/Hostarm64/arm64/dumpbin.exe 2>/dev/null | head -1)
|
||||
[ -n "$dumpbin" ] && "$dumpbin" -nologo -headers -dependents target/dist/raea.exe | grep -iE 'machine|\.dll$' | sed 's/^ *//' | tee -a "$GITHUB_STEP_SUMMARY" || true
|
||||
target/dist/raea.exe --version | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
- name: Models (pinned by URL and sha256 in tools/release/models.tsv)
|
||||
run: |
|
||||
while IFS=$'\t' read -r path url sha; do
|
||||
case $path in ''|'#'*) continue ;; esac
|
||||
mkdir -p "$HOME/.local/share/raea-models/$(dirname "$path")"
|
||||
curl -fsSL "$url" -o "$HOME/.local/share/raea-models/$path"
|
||||
echo "$sha $HOME/.local/share/raea-models/$path" | sha256sum -c -
|
||||
done < <(tr -d '\r' < tools/release/models.tsv)
|
||||
# bin\ as release.yml's windows job fills it, with the ARM64 runtime, uv and DXC (RAEA_WIN_ARCH=arm64), then the
|
||||
# zip packed and checked by tools/release.sh as raea-VERSION-windows-arm64.zip. The skills gate is this commit's
|
||||
# (public raea has no feed app; cli.md is still checked against this build's help); nothing is drawn
|
||||
- name: Pack and check (tools/release.sh)
|
||||
env:
|
||||
RAEA_WIN_ARCH: arm64
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/release-check
|
||||
RAEA_CHECK_NO_GPU: "1"
|
||||
run: |
|
||||
bash tools/release/onnxruntime.sh target/dist
|
||||
bash tools/release/win-bundle.sh target/dist
|
||||
v="${{ inputs.version }}"
|
||||
case $GITHUB_REF in
|
||||
refs/tags/v*)
|
||||
v=${v:-${GITHUB_REF_NAME#v}}
|
||||
# where the skills gate passed, as release.yml reads it (the tag's skills-passed line)
|
||||
eval "$(GITHUB_ENV= bash tools/release/skills-passed.sh "$GITHUB_REF_NAME" | grep '^RAEA_SKILLS_PASSED=')" ;;
|
||||
*) RAEA_SKILLS_PASSED=$(git rev-parse HEAD) ;;
|
||||
esac
|
||||
export RAEA_SKILLS_PASSED
|
||||
bash tools/release.sh "${v:-0.0.0-arm64}" target/dist HEAD
|
||||
# on a v* tag, beside release.yml's archives (the release made here if release.yml hasn't yet)
|
||||
- name: Attach to the release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
pre=; case $GITHUB_REF_NAME in *-*) pre=--prerelease ;; esac
|
||||
gh release view "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 ||
|
||||
gh release create "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" $pre --title "raea ${GITHUB_REF_NAME#v}" --notes "Built by .github/workflows/release.yml; notes follow." ||
|
||||
gh release view "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" >/dev/null
|
||||
gh release upload "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" dist/raea-*-windows-arm64.zip dist/raea-*-windows-arm64.zip.sha256 --clobber
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: windows-arm64-zip
|
||||
path: dist/raea-*-windows-arm64.zip*
|
||||
retention-days: 7
|
||||
compression-level: 0
|
||||
if-no-files-found: ignore
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: windows-arm64-bins
|
||||
path: |
|
||||
target/dist/raea.exe
|
||||
target/dist/raea_bundle.dll
|
||||
target/dist/raea-rune-host.exe
|
||||
target/dist/raea-page-host.exe
|
||||
target/dist/raea-perceive.exe
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
# vendor/metis-sys's header change reaches release.yml's x64 build too (windows-latest's Visual Studio): metis-sys
|
||||
# alone, in a scratch crate, compiled there
|
||||
metis-x64:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
sparse-checkout: vendor/metis-sys
|
||||
- name: metis-sys on x64 MSVC
|
||||
run: |
|
||||
c="$RUNNER_TEMP/metis-x64"; mkdir -p "$c/src" && : > "$c/src/lib.rs"
|
||||
printf '[package]\nname = "metis-x64"\nversion = "0.0.0"\nedition = "2021"\n[dependencies]\nmetis-sys = { path = "%s" }\n[workspace]\n' "$(cygpath -m "$GITHUB_WORKSPACE/vendor/metis-sys")" > "$c/Cargo.toml"
|
||||
cl 2>&1 | head -1 || true
|
||||
cd "$c" && cargo build
|
||||
@@ -107,7 +107,5 @@ sdk/raea/.scratch-*/
|
||||
# examples/materials/wear: its house is made by make-house.ts (media/) and baked at render time (assets/wear/)
|
||||
/examples/materials/wear/media/
|
||||
/examples/materials/wear/assets/
|
||||
# a playable example's generated sounds, made beside it the first time it's rendered or exported (raea's asset store)
|
||||
/examples/playables/assets/
|
||||
# tools/bevy-parity links each example folder's assets/ to Bevy's checkout at run time (an absolute, per-machine path)
|
||||
/sdk/raea/bench/bevy-parity/**/assets
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
# gitleaks: the default rules, minus raea's asset ledgers, whose "key" field is a content hash of the made file
|
||||
# (prompt, seed and model), not a credential; and Bevy's batching code, whose `prev_key = item.sort_key.0` is a
|
||||
# render-phase sort key and whose `Opaque3dBinKey` and `Wireframe3dBinKey` (vendor/bevy_pbr) are bin keys' type names.
|
||||
# render-phase sort key.
|
||||
[extend]
|
||||
useDefault = true
|
||||
|
||||
[allowlist]
|
||||
description = "asset ledgers and Bevy sort and bin keys"
|
||||
description = "asset ledgers and Bevy sort keys"
|
||||
paths = ['''(^|/)assets/made\.jsonl$''']
|
||||
regexTarget = "line"
|
||||
regexes = ['''prev_key = item\.sort_key''', '''(bin_key|BinKey) = [A-Za-z0-9]+BinKey\b''']
|
||||
regexes = ['''prev_key = item\.sort_key''']
|
||||
@@ -1,55 +0,0 @@
|
||||
# Code of conduct
|
||||
|
||||
raea's issues, pull requests, reviews and other project-managed community spaces
|
||||
should let people discuss and improve the work without harassment. This applies
|
||||
to maintainers, contributors and people using automated or AI-assisted tools.
|
||||
Participants remain responsible for the material they submit through those tools.
|
||||
|
||||
## Expected behavior
|
||||
|
||||
- Discuss the code, evidence and ideas respectfully. Technical disagreement is
|
||||
welcome; personal attacks and assumptions about another person's motives are not.
|
||||
- Give actionable feedback, accept corrections and respect requests to stop a
|
||||
conversation or move it out of a thread.
|
||||
- Make room for different experience levels, backgrounds and communication styles.
|
||||
- Respect privacy. Share only logs, screenshots and other information you have
|
||||
permission to publish, with credentials and personal information removed.
|
||||
|
||||
Harassment, discriminatory insults, threats, sexual harassment, unwanted repeated
|
||||
contact, disclosure of private information, deliberate disruption and retaliation
|
||||
against someone raising a concern are unacceptable.
|
||||
|
||||
## Reporting a concern
|
||||
|
||||
For content on GitHub, use the content menu's **Report content** action where it
|
||||
is available. Choose **Report to repository admins** if GitHub offers it.
|
||||
Maintainer reporting depends on repository settings and the reporter's access.
|
||||
For abuse covered by GitHub's rules, use **Report abuse to GitHub Support** or
|
||||
[GitHub's abuse-reporting route](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam).
|
||||
GitHub handles those reports under its own policies; it is not the project's
|
||||
appeal body for every technical or moderation disagreement.
|
||||
|
||||
A separate private maintainer inbox for conduct reports has not been designated
|
||||
in this repository. If GitHub's maintainer-reporting option is unavailable, ask
|
||||
for a private contact without posting the incident, personal information or
|
||||
accusations in a public issue. Maintainers can document an additional contact
|
||||
after confirming who will handle it. Use [the security policy](SECURITY.md) for vulnerabilities,
|
||||
not as a general conduct-report channel.
|
||||
|
||||
Include links, the relevant context and your preferred way to be contacted when
|
||||
reporting privately. Do not retaliate, publicly investigate the reporter or
|
||||
pressure someone to disclose an incident.
|
||||
|
||||
## Moderation
|
||||
|
||||
Repository maintainers may clarify expectations, ask participants to change
|
||||
behavior, close or remove disruptive content, restrict interactions, or block
|
||||
continued participation as appropriate to severity and repetition. A technical
|
||||
disagreement or a rejected contribution alone is not misconduct.
|
||||
|
||||
Maintainers should consider context and available evidence, protect sensitive
|
||||
information, explain decisions when doing so does not compromise privacy, and
|
||||
allow a participant to provide relevant additional context privately through the
|
||||
same reporting route. A maintainer involved in a concern should seek an uninvolved
|
||||
reviewer where one is available. This policy does not promise a response deadline
|
||||
or confidentiality beyond what the chosen reporting service and process provide.
|
||||
Generated
+54
-560
File diff suppressed because it is too large.
Load diff
+2
-50
@@ -4,15 +4,11 @@
|
||||
resolver = "2"
|
||||
members = [
|
||||
"core/animate",
|
||||
"core/ask",
|
||||
"core/brief",
|
||||
"core/zfight",
|
||||
"core/modelbox",
|
||||
"core/facts",
|
||||
"core/ease",
|
||||
"core/fonts",
|
||||
"core/program",
|
||||
"core/tables",
|
||||
"core/scene",
|
||||
"core/shape",
|
||||
"core/meshcheck",
|
||||
@@ -31,7 +27,6 @@ members = [
|
||||
"systems/phase",
|
||||
"systems/shader/wgsl",
|
||||
"systems/sampler",
|
||||
"systems/memtally",
|
||||
"systems/parity",
|
||||
"systems/shader",
|
||||
"systems/three-shader",
|
||||
@@ -43,15 +38,12 @@ members = [
|
||||
"engine/bevy-world",
|
||||
"engine/bundle",
|
||||
"engine/cli",
|
||||
"engine/cli/goal",
|
||||
"engine/cli/refused",
|
||||
"engine/neural",
|
||||
"engine/light",
|
||||
"engine/modules",
|
||||
"engine/native",
|
||||
"io/npm",
|
||||
"engine/page",
|
||||
"engine/page/ax",
|
||||
"engine/page/host",
|
||||
"engine/rune",
|
||||
"engine/rune/page",
|
||||
@@ -69,7 +61,6 @@ members = [
|
||||
"io/codec",
|
||||
"io/media",
|
||||
"io/assets",
|
||||
"io/clef",
|
||||
"io/gen",
|
||||
"io/gen-comfy",
|
||||
"io/gen-core",
|
||||
@@ -90,7 +81,6 @@ members = [
|
||||
"systems/tone",
|
||||
"systems/mix",
|
||||
"systems/mix/level",
|
||||
"systems/mix/device",
|
||||
"systems/ml",
|
||||
"systems/mlx",
|
||||
"systems/kimodo",
|
||||
@@ -99,7 +89,6 @@ members = [
|
||||
"systems/vision",
|
||||
"systems/columns",
|
||||
"systems/index",
|
||||
"systems/fixes",
|
||||
"systems/fingerprint",
|
||||
"systems/fingerprint-use",
|
||||
"systems/fingerprint-things",
|
||||
@@ -109,8 +98,6 @@ members = [
|
||||
"systems/a11y",
|
||||
"systems/bake",
|
||||
"systems/contact",
|
||||
"systems/notice",
|
||||
"systems/motionfaults",
|
||||
"systems/light-meter",
|
||||
"systems/measure",
|
||||
"systems/canvas",
|
||||
@@ -127,8 +114,6 @@ members = [
|
||||
"systems/page-net",
|
||||
"systems/page-ops",
|
||||
"systems/frame",
|
||||
"systems/facetrack",
|
||||
"systems/engine-shaders",
|
||||
"systems/shots",
|
||||
"systems/hold",
|
||||
"systems/body",
|
||||
@@ -136,18 +121,16 @@ members = [
|
||||
"systems/layers",
|
||||
"systems/splat",
|
||||
"systems/sprite",
|
||||
"systems/stage",
|
||||
"systems/rt",
|
||||
"systems/gi",
|
||||
"systems/text3d",
|
||||
"runtime/gpuframe",
|
||||
"runtime/scene3d",
|
||||
"systems/copies",
|
||||
"systems/share",
|
||||
"systems/screen",
|
||||
"systems/matchmove",
|
||||
"systems/grid",
|
||||
"systems/lod",
|
||||
"systems/foliage",
|
||||
"systems/viewbox",
|
||||
"systems/rendermap",
|
||||
"systems/meshseq",
|
||||
@@ -155,7 +138,6 @@ members = [
|
||||
"systems/look",
|
||||
"systems/compose",
|
||||
"systems/material",
|
||||
"systems/toon",
|
||||
"systems/mesh",
|
||||
"systems/post",
|
||||
"systems/fog",
|
||||
@@ -177,19 +159,14 @@ members = [
|
||||
"tools/perceive",
|
||||
"engine/render",
|
||||
"engine/render/raytrace",
|
||||
"engine/render/plugins",
|
||||
"engine/render/denoise/bench",
|
||||
"engine/seedling",
|
||||
"engine/web",
|
||||
"runtime/react",
|
||||
"runtime/track",
|
||||
"runtime/pagestore",
|
||||
"runtime/review",
|
||||
"runtime/cssurls",
|
||||
"runtime/pid",
|
||||
"bench/bridge",
|
||||
"bench/bevy-parity",
|
||||
"bench/lightbench",
|
||||
"bench/bridge/swatch",
|
||||
"bench/rerender/ios",
|
||||
"core/alloc",
|
||||
@@ -198,32 +175,22 @@ members = [
|
||||
"runtime/bundle/lib",
|
||||
"engine/shape-web",
|
||||
"runtime/calls",
|
||||
"runtime/ecs",
|
||||
"runtime/shots",
|
||||
"runtime/wear",
|
||||
"runtime/canvas",
|
||||
"runtime/export",
|
||||
"runtime/endchecks",
|
||||
"runtime/lod-plan",
|
||||
"runtime/live",
|
||||
"runtime/page",
|
||||
"runtime/appscreen",
|
||||
"runtime/sound",
|
||||
"runtime/look",
|
||||
"runtime/scene",
|
||||
"runtime/kinds",
|
||||
"runtime/scene2d",
|
||||
"runtime/shared",
|
||||
"apps/ask",
|
||||
"apps/lightbake",
|
||||
"systems/lightbake",
|
||||
"systems/atlas",
|
||||
"apps/double",
|
||||
"apps/check",
|
||||
"apps/check/cause",
|
||||
"apps/check/flash",
|
||||
"apps/check/inbox",
|
||||
"apps/check/make",
|
||||
"apps/check/read",
|
||||
"apps/check/text",
|
||||
"apps/direction",
|
||||
@@ -237,17 +204,14 @@ members = [
|
||||
"apps/motion",
|
||||
"apps/engines",
|
||||
"apps/interchange",
|
||||
"apps/make",
|
||||
"apps/judge",
|
||||
"apps/solid",
|
||||
"apps/scene",
|
||||
"apps/voice",
|
||||
"apps/media",
|
||||
"apps/targets",
|
||||
"apps/game",
|
||||
"apps/capcut",
|
||||
"apps/layers",
|
||||
"apps/play",
|
||||
"apps/playable",
|
||||
"tools/sdk-props",
|
||||
"tools/hands-audit",
|
||||
]
|
||||
@@ -356,16 +320,10 @@ split-debuginfo = "packed"
|
||||
[patch.crates-io]
|
||||
# the MP4 muxer, vendored
|
||||
muxide = { path = "vendor/muxide" }
|
||||
# metis-sys 0.3.2 (bevy_pbr's meshlets) with GKlib's own stdint.h and inttypes.h stand-ins used only before Visual
|
||||
# Studio 2013: Visual Studio 18's stdint.h types int_fast16_t differently, and every C file failed (raea#82; the change
|
||||
# is marked "raea:" in vendor/GKlib/gk_arch.h). Its test graphs, manual and programs are left out
|
||||
metis-sys = { path = "vendor/metis-sys" }
|
||||
# usvg 0.48.1 spacing a chunk's last letter as Chrome does (changes marked "raea:", docs/layout-reads.feature LR10)
|
||||
usvg = { path = "vendor/usvg" }
|
||||
# bevy_seedling 0.8.0 without its cpal 0.18 paths, ported to Bevy 0.20 (changes marked "raea:")
|
||||
bevy_seedling = { path = "vendor/bevy_seedling" }
|
||||
# bevy_rich_text3d 0.8.0 whose glyph that grows the atlas is drawn whole (changes marked "raea:", docs/stage-guards.feature SG3)
|
||||
bevy_rich_text3d = { path = "vendor/bevy_rich_text3d" }
|
||||
# bevy_text 0.20.0 on parley 0.12, so one parley builds (changes marked "raea:", docs/bevy-upgrade.md)
|
||||
bevy_text = { path = "vendor/bevy_text" }
|
||||
# bevy_ui 0.20.0 on Taffy 0.15, Blitz's, so one Taffy builds (changes marked "raea:", docs/bevy-upgrade.md)
|
||||
@@ -374,8 +332,6 @@ bevy_ui = { path = "vendor/bevy_ui" }
|
||||
# uv_transform, and a panorama's sun sampled as a light rather than found by reflection rays alone (changes marked
|
||||
# "raea:", docs/raytracing.feature RT6). Back to upstream once Solari has these.
|
||||
bevy_solari = { path = "vendor/bevy_solari" }
|
||||
# the sun's far shadow map (raea-sys-rt far.rs) bound in Bevy's mesh view group (docs/bevy-upgrade.md, docs/realism.feature LT21)
|
||||
bevy_pbr = { path = "vendor/bevy_pbr" }
|
||||
# bevy_ui_widgets 0.20.0 on parley 0.12, Blitz's (docs/blitz-bevy.feature B0a)
|
||||
bevy_ui_widgets = { path = "vendor/bevy_ui_widgets" }
|
||||
# blitz-paint 0.3.0-beta.4 with angled gradients in tiles laid out around the tile, many-tile gradient layers drawn
|
||||
@@ -416,10 +372,6 @@ vello_encoding = { path = "vendor/vello_encoding" }
|
||||
# (changes marked "raea:"): raea-page blends a bevy_ui page as Bevy does (bevy_ui on Blitz). No upstream
|
||||
# equivalent yet (linebender/vello blends the encoded values).
|
||||
vello_shaders = { path = "vendor/vello_shaders" }
|
||||
# taffy 0.15.0 (Blitz's, Bevy UI's, rune-taffy's) with a flex line whose items overflow its container by less than
|
||||
# Chrome's layout unit, 1/64 px, kept on one line: f32 rounding wrapped items that add up to the container's width
|
||||
# (changes marked "raea:", raea #252). Back to upstream once Taffy breaks flex lines with a tolerance.
|
||||
taffy = { path = "vendor/taffy" }
|
||||
# Firewheel 0.12 on Bevy 0.20: bevy_reflect 0.20 and a glam-33 feature (BillyDM/Firewheel#144; changes marked "raea:")
|
||||
firewheel = { path = "vendor/firewheel" }
|
||||
firewheel-core = { path = "vendor/firewheel-core" }
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2020 Dario Nieuwenhuis
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,3 +1,10 @@
|
||||
SPDX-License-Identifier: ISC AND (Apache-2.0 OR ISC)
|
||||
|
||||
|
||||
Apache 2.0 license
|
||||
-------------------------------------
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
@@ -174,3 +181,22 @@
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
ISC license
|
||||
-------------------------------------
|
||||
|
||||
|
||||
Copyright Amazon.com, Inc. or its affiliates.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -0,0 +1,316 @@
|
||||
AWS Libcrypto (AWS-LC)
|
||||
|
||||
AWS-LC is a fork of BoringSSL, which is itself a fork of OpenSSL.
|
||||
Content from these and other sources retains their original licensing,
|
||||
as described below. New files from AWS-LC are made available under the Apache-2.0 license OR the ISC
|
||||
license. These licenses are reproduced at the bottom of this file.
|
||||
|
||||
```
|
||||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
SPDX-License-Identifier: Apache-2.0 OR ISC
|
||||
```
|
||||
|
||||
|
||||
================================================================================
|
||||
BoringSSL
|
||||
================================================================================
|
||||
|
||||
BoringSSL is a Google-maintained fork of OpenSSL. Historically, code
|
||||
authored by Google for BoringSSL was licensed under the ISC License.
|
||||
BoringSSL has since relicensed upstream to Apache License 2.0. Existing
|
||||
AWS-LC code originating from BoringSSL retains its ISC license, while
|
||||
newer code taken from BoringSSL is licensed under Apache License 2.0.
|
||||
|
||||
```
|
||||
Copyright (c) 2014-2024 Google Inc.
|
||||
SPDX-License-Identifier: ISC
|
||||
```
|
||||
|
||||
Additional individual contributions to BoringSSL-derived code are
|
||||
covered under the ISC license:
|
||||
|
||||
- Brian Smith (Copyright 2016)
|
||||
- Robert Nagy (Copyright 2022)
|
||||
- Arm Ltd (Copyright 2020)
|
||||
|
||||
```
|
||||
Copyright (c) 2025-2026 Google Inc.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
```
|
||||
|
||||
================================================================================
|
||||
OpenSSL
|
||||
================================================================================
|
||||
|
||||
Code derived from the OpenSSL project is licensed under the
|
||||
Apache License, Version 2.0.
|
||||
|
||||
```
|
||||
Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
```
|
||||
|
||||
Some OpenSSL-derived files also carry the original SSLeay copyright:
|
||||
|
||||
```
|
||||
Copyright (c) 1995-1998 Eric Young ([email protected]). All rights reserved.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
```
|
||||
|
||||
Portions of OpenSSL-derived code include contributions from:
|
||||
|
||||
- Sun Microsystems, Inc. (Copyright 2002)
|
||||
- Nokia (Copyright 2005)
|
||||
- Intel Corporation (Copyright 2012-2021)
|
||||
|
||||
These contributions are covered under the Apache-2.0 license.
|
||||
|
||||
================================================================================
|
||||
mlkem-native
|
||||
================================================================================
|
||||
|
||||
Code from the mlkem-native project is licensed under Apache License 2.0 or MIT or ISC.
|
||||
|
||||
```
|
||||
Copyright (c) The mlkem-native project authors.
|
||||
SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
||||
```
|
||||
|
||||
================================================================================
|
||||
mldsa-native
|
||||
================================================================================
|
||||
|
||||
Code from the mldsa-native project is licensed under Apache License 2.0 or MIT or ISC
|
||||
|
||||
```
|
||||
Copyright (c) The mldsa-native project authors.
|
||||
SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
|
||||
```
|
||||
|
||||
================================================================================
|
||||
Third-Party Libraries (compiled into libcrypto/libssl)
|
||||
================================================================================
|
||||
|
||||
Fiat Cryptography
|
||||
-----------------
|
||||
Synthesizing Correct-by-Construction Code for Cryptographic Primitives.
|
||||
See third_party/fiat/LICENSE.
|
||||
|
||||
```
|
||||
Copyright (c) 2015-2020 the fiat-crypto authors.
|
||||
SPDX-License-Identifier: MIT
|
||||
```
|
||||
|
||||
s2n-bignum
|
||||
----------
|
||||
Integer arithmetic routines for cryptography.
|
||||
See third_party/s2n-bignum/s2n-bignum-imported/LICENSE.
|
||||
|
||||
```
|
||||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT-0
|
||||
```
|
||||
|
||||
Note: ML-KEM/SHA3 code within s2n-bignum is licensed as
|
||||
Apache-2.0 OR ISC OR MIT (with attribution), sourced from the
|
||||
mlkem-native project.
|
||||
|
||||
Jitter Entropy RNG
|
||||
-------------------
|
||||
CPU Jitter Random Number Generator Library.
|
||||
See third_party/jitterentropy/jitterentropy-library/LICENSE.
|
||||
|
||||
The Jitter Entropy library is dual-licensed under a BSD-style license
|
||||
and the GNU General Public License Version 2. Amazon expressly elects
|
||||
to distribute the package under the 3-Clause BSD License and NOT under
|
||||
GNU General Public License Version 2.
|
||||
|
||||
```
|
||||
Copyright (C) 2017 - 2025, Stephan Mueller <[email protected]>.
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
```
|
||||
|
||||
Keccak / AES Reference Implementations
|
||||
---------------------------------------
|
||||
Public domain (CC0) contributions.
|
||||
https://creativecommons.org/public-domain/cc0
|
||||
|
||||
Code from sources and by authors listed in comments on top of the respective files.
|
||||
|
||||
|
||||
================================================================================
|
||||
Third-Party Libraries (NOT compiled into libcrypto/libssl)
|
||||
================================================================================
|
||||
|
||||
The following are used for testing and build tooling only. Distributing
|
||||
code linked against AWS-LC (libcrypto/libssl) does NOT trigger these
|
||||
license obligations.
|
||||
|
||||
Google Test
|
||||
-----------
|
||||
See third_party/googletest/LICENSE.
|
||||
|
||||
```
|
||||
Copyright 2008 Google Inc.
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
```
|
||||
|
||||
Go Standard Library
|
||||
-------------------
|
||||
Code in ssl/test/runner/ is derived from the Go standard library.
|
||||
|
||||
```
|
||||
Copyright (c) The Go Authors. All rights reserved.
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
```
|
||||
|
||||
Wycheproof Test Vectors
|
||||
------------------------
|
||||
Project Wycheproof is a community managed repository of test vectors that can be used by cryptography library
|
||||
developers to test against known attacks, specification inconsistencies, and other various implementation bugs.
|
||||
|
||||
See third_party/wycheproof_testvectors/LICENSE.
|
||||
|
||||
```
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
```
|
||||
|
||||
|
||||
================================================================================
|
||||
Full License Texts
|
||||
================================================================================
|
||||
|
||||
Apache License 2.0
|
||||
------------------
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
ISC License
|
||||
-----------
|
||||
Permission to use, copy, modify, and/or distribute this software for
|
||||
any purpose with or without fee is hereby granted, provided that the
|
||||
above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
BSD 3-Clause License
|
||||
--------------------
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
MIT No Attribution (MIT-0)
|
||||
--------------------------
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2020-2025 The RustCrypto Project Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,176 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2023 Thomas Pendock
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,5 +1,7 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Denis Kurilenko
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2018 Jorge Aparicio
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2017 Jorge Aparicio
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Dzmitry Malyshau
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2019 Anthony James Munns
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,12 @@
|
||||
Copyrights in the Rand project are retained by their contributors. No
|
||||
copyright assignment is required to contribute to the Rand project.
|
||||
|
||||
For full authorship information, see the version control history.
|
||||
|
||||
Except as otherwise noted (below and/or in individual files), Rand is
|
||||
licensed under the Apache License, Version 2.0 <LICENSE-APACHE> or
|
||||
<http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
<LICENSE-MIT> or <http://opensource.org/licenses/MIT>, at your option.
|
||||
|
||||
The Rand project includes code from the Rust project
|
||||
published under these same licenses.
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,26 @@
|
||||
Copyright 2018 Developers of the Rand project
|
||||
Copyright (c) 2014 The Rust Project Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,10 @@
|
||||
Rustls is distributed under the following three licenses:
|
||||
|
||||
- Apache License version 2.0.
|
||||
- MIT license.
|
||||
- ISC license.
|
||||
|
||||
These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC
|
||||
respectively. You may use this software under the terms of any
|
||||
of these licenses, at your option.
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,15 @@
|
||||
ISC License (ISC)
|
||||
Copyright (c) 2016, Joseph Birr-Pixton <[email protected]>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for
|
||||
any purpose with or without fee is hereby granted, provided that the
|
||||
above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2016 Joseph Birr-Pixton <[email protected]>
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
+2
-3
@@ -1,4 +1,3 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
@@ -187,7 +186,7 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2024 Mincong Lu
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -199,4 +198,4 @@
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
limitations under the License.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Mincong Lu
|
||||
Copyright (c) 2022 1Password
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -0,0 +1,20 @@
|
||||
rustls-platform-verifier-android 0.2.0 ships no licence file of its own. Its Cargo.toml declares MIT OR Apache-2.0, by its authors.
|
||||
|
||||
---- Apache-2.0: the text is LICENSES/texts/Apache-2.0.txt ----
|
||||
|
||||
---- MIT ----
|
||||
|
||||
Copyright (c) its authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,6 @@
|
||||
Copyright 2021 Travis Veazey
|
||||
|
||||
Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
||||
http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
||||
http://opensource.org/licenses/MIT>, at your option. This file may not be
|
||||
copied, modified, or distributed except according to those terms.
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2016 The Amethyst Project Developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Mathijs van de Nes
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,20 @@
|
||||
© 2016 Bertram Truong
|
||||
© 2021 Kornel Lesiński
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -27,9 +27,7 @@ paths for Windows in runtime/bundle). Its bin\ also carries, each with its licen
|
||||
and libvpx 1.17.0's decoders (BSD-3-Clause with the WebM project's patent grant: libvpx-LICENSE.txt,
|
||||
libvpx-PATENTS.txt) by tools/release/ffmpeg-win.sh, its H.264 encoder Windows' own (Media Foundation), its source
|
||||
published as the release tools-ffmpeg-9.0.2-lgpl;
|
||||
uv (uv.exe; Astral, MIT OR Apache-2.0);
|
||||
Microsoft's DirectX Shader Compiler v1.8.2502 (dxcompiler.dll, dxil.dll), DX12's shader compiler, redistributed under
|
||||
its licence terms (dxc-LICENSE-MS.txt; its LLVM parts under dxc-LICENSE-LLVM.txt and dxc-LICENSE-MIT.txt).
|
||||
uv (uv.exe; Astral, MIT OR Apache-2.0).
|
||||
The Windows app adds Git for Windows with Git LFS (dugite-native; GPLv2 and its parts' licences, in git\), which raea
|
||||
runs as a separate program; its complete corresponding source is published as the release tools-git-<tag>-sources.
|
||||
raea.exe, on a PC with no Git, fetches the same build once into its tools cache (io/assets git()).
|
||||
@@ -68,6 +66,7 @@ LICENSES/<crate>-<version>/.
|
||||
async-recursion 1.2.0: MIT OR Apache-2.0
|
||||
async-signal 0.2.14: Apache-2.0 OR MIT
|
||||
atomic-arena 0.1.2: MIT OR Apache-2.0
|
||||
atomic-polyfill 1.0.3: MIT OR Apache-2.0
|
||||
atspi-common 0.13.0: Apache-2.0 OR MIT
|
||||
atspi-proxies 0.13.0: Apache-2.0 OR MIT
|
||||
atspi 0.29.0: Apache-2.0 OR MIT
|
||||
@@ -75,6 +74,8 @@ LICENSES/<crate>-<version>/.
|
||||
avian_derive 0.2.3: MIT OR Apache-2.0
|
||||
avian2d 0.8.0: MIT OR Apache-2.0
|
||||
avian3d 0.8.0: MIT OR Apache-2.0
|
||||
aws-lc-rs 1.18.2: ISC AND (Apache-2.0 OR ISC)
|
||||
aws-lc-sys 0.46.0: ISC AND (Apache-2.0 OR ISC) AND Apache-2.0 AND MIT AND BSD-3-Clause AND (Apache-2.0 OR ISC OR MIT) AND (Apache-2.0 OR ISC OR MIT-0)
|
||||
az 1.3.0: MIT/Apache-2.0
|
||||
basis-universal-sys 0.3.1: MIT OR Apache-2.0
|
||||
basis-universal 0.3.1: MIT OR Apache-2.0
|
||||
@@ -171,6 +172,7 @@ LICENSES/<crate>-<version>/.
|
||||
deluxe-core 0.5.0: MIT
|
||||
deluxe-macros 0.5.0: MIT
|
||||
deluxe 0.5.0: MIT
|
||||
der_derive 0.8.0: Apache-2.0 OR MIT
|
||||
der-parser 10.0.0: MIT OR Apache-2.0
|
||||
deranged 0.5.9: MIT OR Apache-2.0
|
||||
derive-getters 0.5.0: MIT
|
||||
@@ -190,12 +192,15 @@ LICENSES/<crate>-<version>/.
|
||||
enumflags2 0.7.12: MIT OR Apache-2.0
|
||||
epaint_default_fonts 0.36.2: (MIT OR Apache-2.0) AND OFL-1.1 AND Ubuntu-font-1.0
|
||||
epaint 0.36.2: MIT OR Apache-2.0
|
||||
fastbloom 0.17.0: MIT OR Apache-2.0
|
||||
fastnoise-lite 1.1.1: MIT
|
||||
fid-rs 0.2.0: MIT OR Apache-2.0
|
||||
file-id 0.2.3: MIT OR Apache-2.0
|
||||
fixed 1.31.0: MIT/Apache-2.0
|
||||
flagset 0.4.7: Apache-2.0
|
||||
float_next_after 2.0.0: MIT
|
||||
float-ord 0.3.2: MIT / Apache-2.0
|
||||
fs_extra 1.3.0: MIT
|
||||
fsevent-sys 4.1.0: MIT
|
||||
futures-timer 3.0.4: MIT/Apache-2.0
|
||||
fuzzy-matcher 0.3.7: MIT
|
||||
@@ -208,6 +213,8 @@ LICENSES/<crate>-<version>/.
|
||||
glam 0.19.0: MIT OR Apache-2.0
|
||||
gloo-timers 0.3.0: MIT OR Apache-2.0
|
||||
governor 0.10.4: MIT
|
||||
hash32 0.2.1: MIT OR Apache-2.0
|
||||
heapless 0.7.17: MIT OR Apache-2.0
|
||||
heck 0.4.1: MIT OR Apache-2.0
|
||||
httlib-huffman 0.3.4: MIT
|
||||
i_float 1.16.0: MIT
|
||||
@@ -269,6 +276,7 @@ LICENSES/<crate>-<version>/.
|
||||
metis 0.2.2: MIT OR Apache-2.0
|
||||
metrics-util 0.20.4: MIT
|
||||
metrics 0.24.6: MIT
|
||||
mint 0.5.9: MIT
|
||||
mock_instant 0.6.1: 0BSD
|
||||
moonshine-save 0.8.0: MIT
|
||||
moonshine-util 0.6.0: MIT
|
||||
@@ -308,6 +316,7 @@ LICENSES/<crate>-<version>/.
|
||||
pollster 1.0.1: Apache-2.0/MIT
|
||||
poly1305 0.8.0: Apache-2.0 OR MIT
|
||||
polyanya 0.18.0: MIT OR Apache-2.0
|
||||
postcard-derive 0.2.2: MIT OR Apache-2.0
|
||||
powerfmt 0.2.1: MIT OR Apache-2.0
|
||||
proc-macro-crate 1.3.1: MIT OR Apache-2.0
|
||||
proc-macro-error-attr 1.0.4: MIT OR Apache-2.0
|
||||
@@ -319,6 +328,7 @@ LICENSES/<crate>-<version>/.
|
||||
quick-xml 0.31.0: MIT
|
||||
quick-xml 0.38.4: MIT
|
||||
radix_trie 0.2.1: MIT
|
||||
rand_chacha 0.3.1: MIT OR Apache-2.0
|
||||
rand_xorshift 0.3.0: MIT OR Apache-2.0
|
||||
rand_xoshiro 0.7.0: MIT OR Apache-2.0
|
||||
rapidhash 4.5.1: MIT OR Apache-2.0
|
||||
@@ -337,9 +347,13 @@ LICENSES/<crate>-<version>/.
|
||||
rune-staging 0.0.1: MIT
|
||||
rune 0.0.1: MIT
|
||||
rusticata-macros 4.1.0: MIT/Apache-2.0
|
||||
rustls-native-certs 0.8.5: Apache-2.0 OR ISC OR MIT
|
||||
rustls-pemfile 2.2.0: Apache-2.0 OR ISC OR MIT
|
||||
rustls-platform-verifier-android 0.2.0: MIT OR Apache-2.0
|
||||
rustls-platform-verifier 0.7.1: MIT OR Apache-2.0
|
||||
seahash 4.1.0: MIT
|
||||
selectors 0.38.0: MPL-2.0
|
||||
serde_arrays 0.2.0: MIT OR Apache-2.0
|
||||
serde_flexitos 0.2.2: Apache-2.0
|
||||
serde_regex 1.2.0: MIT OR Apache-2.0
|
||||
serde_repr 0.1.21: MIT OR Apache-2.0
|
||||
@@ -349,6 +363,7 @@ LICENSES/<crate>-<version>/.
|
||||
sif-itree 0.4.1: MIT OR Apache-2.0
|
||||
sketches-ddsketch 0.3.1: Apache-2.0
|
||||
smart-default 0.7.1: MIT
|
||||
spin 0.9.9: MIT
|
||||
spinning_top 0.3.0: MIT/Apache-2.0
|
||||
spki 0.8.1: Apache-2.0 OR MIT
|
||||
steamworks-sys 0.13.0: MIT / Apache-2.0
|
||||
@@ -379,6 +394,7 @@ LICENSES/<crate>-<version>/.
|
||||
unicode-general-category 1.1.0: Apache-2.0
|
||||
universal-hash 0.5.1: MIT OR Apache-2.0
|
||||
unsafe-libyaml 0.2.11: MIT
|
||||
urlencoding 2.1.3: MIT
|
||||
usvg 0.45.1: Apache-2.0 OR MIT
|
||||
vleue_navigator 0.17.0: MIT OR Apache-2.0
|
||||
voracious_radix_sort 1.2.0: MIT
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<p align="center">
|
||||
Tell your AI what to make. Videos, motion graphics, 3D and games, written as React and TypeScript<br>
|
||||
(the code your AI already writes) and rendered on your own GPU.
|
||||
(the code your AI already writes) and rendered on your own GPU, faster than they play.
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
---
|
||||
|
||||
> raea releases experimentally and often, so the newest release is always on
|
||||
> [Releases](https://github.com/shinyobjectz/raea/releases). The app is unstable for now, especially on Linux and
|
||||
> Windows: expect rough edges, and tell us what you hit in an [issue](https://github.com/shinyobjectz/raea/issues), or
|
||||
> from your agent with `raea bug`.
|
||||
> **0.1.6** (17 November 2026) is the latest release: the engine and the desktop app on macOS (Apple Silicon), Linux
|
||||
> (x86_64) and, newest and least tested, Windows 10 and 11 (x86_64). raea is young and moves fast, with a release most
|
||||
> days since 0.1.1 on 11 November: expect rough edges, and tell us what you hit in an
|
||||
> [issue](https://github.com/shinyobjectz/raea/issues), or from your agent with `raea bug`.
|
||||
|
||||
## The app
|
||||
|
||||
@@ -80,13 +80,6 @@ The installer puts the `raea` command under `~/.raea`, links it into `~/.local/b
|
||||
work. Run it again to update. The engine is free and needs no account. Tarballs and checksums are on the
|
||||
[releases page](https://github.com/shinyobjectz/raea/releases).
|
||||
|
||||
Linux release builds also package an x86_64 AppImage of the engine command and
|
||||
attach it and its SHA256 checksum beside the release archives.
|
||||
Make it executable with `chmod +x raea-*.AppImage`, then run
|
||||
`./raea-VERSION-linux-x86_64.AppImage --help` or pass the usual `raea` arguments.
|
||||
See [the AppImage release recipe](tools/release/README.md#linux-appimage) for build
|
||||
instructions, runtime requirements and running without FUSE.
|
||||
|
||||
On Windows 10 or 11, in PowerShell:
|
||||
|
||||
```powershell
|
||||
@@ -130,7 +123,7 @@ floor (`raea check hello.mp4`). `raea init` starts a project, and `raea --help`
|
||||
Gaussian splats, and Bevy plugins compiled into the engine. three.js work runs as it's written: a React Three Fiber
|
||||
scene inside `<R3F>`, or a three.js page's script inside `<Three program>`.
|
||||
- **Sound.** One mixer for live play and offline render, instruments and effects, and local models for foley and
|
||||
instrument notes (`raea make sao`, `raea make tokensynth`).
|
||||
instrument notes (`raea sao`, `raea tokensynth`).
|
||||
- **Built for agents.** Everything it draws stays queryable as data, so an agent can render a frame, look at it, and
|
||||
fix what's wrong without a person in the loop.
|
||||
|
||||
@@ -145,10 +138,9 @@ Apache-2.0, to read, render and take apart, and its models, textures and sound f
|
||||
- **Agent skills.** They live in [raea-skills](https://github.com/shinyobjectz/raea-skills), pinned here as
|
||||
[`skills/`](skills): `raea` teaches an agent to write, render and check raea compositions, 3D and games
|
||||
included. The installer adds it to `~/.claude/skills`, and `raea skills install --agent NAME` to other agents.
|
||||
- **Claude plugin.** The raea skill and its hooks: media an agent opens goes to the raea app, and `raea check` holds
|
||||
the brief's goals as a turn ends. Nothing is checked after a save, since a render checks its own output. In Claude
|
||||
Code: `/plugin install raea --marketplace shinyobjectz/raea-skills`. It's the `skills/` folder of raea-skills, and
|
||||
`/plugin marketplace add shinyobjectz/raea` installs the same one.
|
||||
- **Claude plugin.** The raea skill and two hooks (raea's quick check after a composition is saved, and media shown in
|
||||
the raea app). In Claude Code: `/plugin install raea --marketplace shinyobjectz/raea-skills`. It's the `skills/`
|
||||
folder of raea-skills, and `/plugin marketplace add shinyobjectz/raea` installs the same one.
|
||||
- **Craft guides.** `raea guide` prints the floor every edit is held to and the guides for pitches, explainers, stories,
|
||||
games, motion, music and layout. `raea context PROJECT` says what to read before working on a project.
|
||||
- **Bug reports.** When an agent finds a bug in raea itself, `raea bug TITLE --text TEXT` sends it to raea's server
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
[package]
|
||||
name = "raea-app-ask"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "Questions about a piece's picture and sound, prepared from what raea knows of it, asked of clef in parallel from the person's plan, and every answer kept"
|
||||
|
||||
[dependencies]
|
||||
# the question format and the standard sets; the one clef client, routed to the person's plan first (docs/ask.feature)
|
||||
raea-core-ask = { path = "../../core/ask" }
|
||||
raea-io-clef = { path = "../../io/clef" }
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# the fingerprint's AUC, quantile and gates, so a question is calibrated as an axis is (AK7)
|
||||
raea-sys-fingerprint = { path = "../../systems/fingerprint" }
|
||||
# today's date for a calibration
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
dunce = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
|
||||
[dev-dependencies]
|
||||
raea-io-assets = { path = "../../io/assets" }
|
||||
@@ -1,214 +0,0 @@
|
||||
//! Calibration (docs/ask.feature AK7): a question's answers held to the person's labels (labels.rs), per version of its
|
||||
//! words. Clef isn't trained on the labels, so its AUC on them is held out already; the one thing fitted is the
|
||||
//! threshold, the problem score that flags 10% of the clean labels. The gates are the fingerprint's (16 labels of each
|
||||
//! kind, from 3 projects, an AUC of 0.8). A question that passes is calibrated at its threshold: its answers are
|
||||
//! findings, and the person's calibration replaces raea's shipped one. One under 0.6 after 32 labels doesn't separate,
|
||||
//! and says which labels it missed, so its words can be fixed. `try_words` asks new words of the labelled clips and
|
||||
//! sets both AUCs side by side.
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashMap};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use raea_core_ask::{Calibration, Question};
|
||||
use raea_io_clef::Media;
|
||||
use raea_sys_fingerprint::head::{auc, quantile};
|
||||
use raea_sys_fingerprint::train::{GATE_AUC, GATE_LABELS, GATE_PROJECTS};
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::labels::{self, Label};
|
||||
use crate::prepare::Piece;
|
||||
use crate::record;
|
||||
use crate::runner::{self, Event, Group, Kept, Opts, Summary};
|
||||
|
||||
pub const FILE: &str = "calibration.json";
|
||||
/// An AUC under this after twice the gate's labels: the words don't separate the problem.
|
||||
const SEPARATES: f64 = 0.6;
|
||||
|
||||
/// The person's calibrations that passed the gates, by question version.
|
||||
pub fn local() -> BTreeMap<String, Calibration> {
|
||||
std::fs::read_to_string(record::dir().join(FILE)).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// A question with the person's calibration in place of raea's, when it has one.
|
||||
pub fn apply(q: &mut Question, local: &BTreeMap<String, Calibration>) {
|
||||
if let Some(c) = local.get(&q.version()) {
|
||||
q.calibration = Some(c.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/// A label the answers missed: a problem it scored low, or clean work it scored high.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct Miss {
|
||||
pub file: String,
|
||||
pub span: String,
|
||||
pub problem: f64,
|
||||
pub bad: bool,
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
/// One version's standing.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct Standing {
|
||||
pub id: String,
|
||||
pub version: String,
|
||||
pub ask: String,
|
||||
pub problems: usize,
|
||||
pub clean: usize,
|
||||
pub projects: usize,
|
||||
pub auc: Option<f64>,
|
||||
pub threshold: Option<f64>,
|
||||
/// calibrated, advice or "doesn't separate"
|
||||
pub state: String,
|
||||
pub why: String,
|
||||
pub misses: Vec<Miss>,
|
||||
/// other eyes' labels on its clips, kept and not counted
|
||||
pub others: usize,
|
||||
}
|
||||
|
||||
/// Each labelled clip's latest problem score for one version, beside its label.
|
||||
fn scored<'a>(version: &str, standing: &HashMap<(String, String), &'a Label>, calls: &HashMap<String, Value>) -> Vec<(f64, &'a Label)> {
|
||||
let mut latest: HashMap<String, (f64, &Label)> = HashMap::new();
|
||||
for a in record::rows("answers.jsonl").iter().filter(|a| a["version"] == version) {
|
||||
let (Some(p), Some(call)) = (a["problem"].as_f64(), calls.get(a["call"].as_str().unwrap_or_default())) else { continue };
|
||||
let key = (a["question"].as_str().unwrap_or_default().to_string(), labels::media_key(call));
|
||||
if let Some(l) = standing.get(&key) {
|
||||
latest.insert(key.1, (p, l));
|
||||
}
|
||||
}
|
||||
latest.into_values().collect()
|
||||
}
|
||||
|
||||
/// One version held to its labels.
|
||||
pub fn standing_of(q: &Question, all: &[Label], calls: &HashMap<String, Value>) -> Standing {
|
||||
let standing = labels::standing(all);
|
||||
let s = scored(&q.version(), &standing, calls);
|
||||
let score = |bad: bool| s.iter().filter(|(_, l)| l.bad == bad).map(|(p, _)| *p as f32).collect::<Vec<f32>>();
|
||||
let (pos, neg) = (score(true), score(false));
|
||||
let projects = s.iter().map(|(_, l)| l.project.as_str()).collect::<BTreeSet<_>>().len();
|
||||
let a = Some(auc(&pos, &neg)).filter(|a| a.is_finite());
|
||||
let threshold = Some(quantile(&neg, 0.9) as f64).filter(|t| t.is_finite());
|
||||
let mut why = Vec::new();
|
||||
if pos.len() < GATE_LABELS || neg.len() < GATE_LABELS {
|
||||
why.push(format!("{} problem and {} clean labels (needs {GATE_LABELS} of each)", pos.len(), neg.len()));
|
||||
}
|
||||
if projects < GATE_PROJECTS {
|
||||
why.push(format!("labels from {projects} projects (needs {GATE_PROJECTS})"));
|
||||
}
|
||||
match a {
|
||||
Some(v) if v < GATE_AUC => why.push(format!("AUC {v:.2} (needs {GATE_AUC})")),
|
||||
None => why.push("no AUC yet: it needs labels of both kinds".into()),
|
||||
_ => {}
|
||||
}
|
||||
let stuck = s.len() >= 2 * GATE_LABELS && a.is_some_and(|v| v < SEPARATES);
|
||||
let mut misses: Vec<Miss> = Vec::new();
|
||||
if stuck {
|
||||
let mut by: Vec<&(f64, &Label)> = s.iter().collect();
|
||||
by.sort_by(|x, y| x.0.total_cmp(&y.0));
|
||||
let low = by.iter().filter(|(_, l)| l.bad).take(5);
|
||||
let high = by.iter().rev().filter(|(_, l)| !l.bad).take(5);
|
||||
misses = low.chain(high).map(|(p, l)| Miss { file: l.file.clone(), span: labels::span(l.from, l.to), problem: *p, bad: l.bad, note: l.note.clone() }).collect();
|
||||
}
|
||||
let others = all.iter().filter(|l| !l.counted() && l.question == q.id).count();
|
||||
let state = match (why.is_empty(), stuck) {
|
||||
(true, _) => "calibrated",
|
||||
(false, true) => "doesn't separate",
|
||||
(false, false) => "advice",
|
||||
};
|
||||
let why = if why.is_empty() { format!("earned: {} labels from {projects} projects, flags past {:.2}", s.len(), threshold.unwrap_or(0.0)) } else { why.join("; ") };
|
||||
Standing { id: q.id.clone(), version: q.version(), ask: q.ask.clone(), problems: pos.len(), clean: neg.len(), projects, auc: a, threshold, state: state.into(), why, misses, others }
|
||||
}
|
||||
|
||||
/// Every labelled question's versions as the record kept them (or only `id`'s), newest wording last.
|
||||
fn versions(only: Option<&str>, all: &[Label]) -> Vec<Question> {
|
||||
let labelled: BTreeSet<&str> = all.iter().map(|l| l.question.as_str()).collect();
|
||||
let mut seen = BTreeSet::new();
|
||||
let mut out = Vec::new();
|
||||
for a in record::rows("answers.jsonl") {
|
||||
let id = a["question"].as_str().unwrap_or_default();
|
||||
if only.is_some_and(|o| o != id) || !labelled.contains(id) || !seen.insert(a["version"].as_str().unwrap_or_default().to_string()) {
|
||||
continue;
|
||||
}
|
||||
out.push(labels::question_of(&a));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `calibrate(ID)`: the feed's labels read again, then every labelled version held to them. The ones that
|
||||
/// pass are kept as the person's calibration; one that no longer passes loses it.
|
||||
pub fn calibrate(only: Option<&str>) -> Result<(Vec<Standing>, (usize, usize)), String> {
|
||||
let feed = labels::from_feed()?;
|
||||
let (all, calls) = (labels::all(), labels::calls());
|
||||
let out: Vec<Standing> = versions(only, &all).iter().map(|q| standing_of(q, &all, &calls)).collect();
|
||||
let mut keep = local();
|
||||
for s in &out {
|
||||
keep.remove(&s.version);
|
||||
if s.state == "calibrated" {
|
||||
let n = (s.problems + s.clean) as u32;
|
||||
let c = Calibration { auc: s.auc.unwrap_or(0.0), n, positives: s.problems as u32, threshold: s.threshold, date: today(), by: "you".into() };
|
||||
keep.insert(s.version.clone(), c);
|
||||
}
|
||||
}
|
||||
record::write_whole(FILE, &serde_json::to_string_pretty(&keep).map_err(|e| e.to_string())?)?;
|
||||
Ok((out, feed))
|
||||
}
|
||||
|
||||
/// YYYY-MM-DD, UTC.
|
||||
fn today() -> String {
|
||||
raea_io_trace::utc(std::time::SystemTime::now()).0.chars().take(10).collect()
|
||||
}
|
||||
|
||||
/// The groups `try_words` sends: the new question on each labelled clip set, with the state it was asked with.
|
||||
pub fn try_groups(like: &str, words: &str) -> Result<(Question, Question, Vec<Group>), String> {
|
||||
let all = labels::all();
|
||||
let standing = labels::standing(&all);
|
||||
let rows = record::rows("answers.jsonl");
|
||||
let old = rows.iter().rev().find(|a| a["question"] == like).map(labels::question_of).ok_or_else(|| format!("ask try: no answers to {like} in the record"))?;
|
||||
let new = Question { ask: words.to_string(), calibration: None, ..old.clone() };
|
||||
let calls = labels::calls();
|
||||
let mut groups: Vec<Group> = Vec::new();
|
||||
let mut sent = BTreeSet::new();
|
||||
for call in calls.values().filter(|c| standing.contains_key(&(like.to_string(), labels::media_key(c)))) {
|
||||
let names: Vec<&str> = call["media"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
|
||||
let Some(kept) = media(&names) else { continue };
|
||||
if !sent.insert(labels::media_key(call)) {
|
||||
continue;
|
||||
}
|
||||
let piece = Arc::new(Piece { file: PathBuf::from(call["file"].as_str().unwrap_or_default()), project: call["project"].as_str().map(PathBuf::from), ..Default::default() });
|
||||
let (from, to) = (call["from"].as_f64().unwrap_or(0.0), call["to"].as_f64());
|
||||
let seconds = to.map_or(60.0, |t| t - from);
|
||||
let kept = Kept { video_seconds: if kept.videos.is_empty() { 0.0 } else { seconds }, sound_seconds: if kept.sounds.is_empty() { 0.0 } else { seconds }, media: kept, state: call["state"].as_str().unwrap_or_default().into() };
|
||||
groups.push(Group { piece, from, to, sees: new.sees, hears: new.hears, with: vec![], questions: vec![new.clone()], kept: Some(Arc::new(kept)) });
|
||||
}
|
||||
if groups.is_empty() {
|
||||
return Err(format!("ask try: none of {like}'s labelled clips are still kept (calibrate() lists its labels)"));
|
||||
}
|
||||
Ok((old, new, groups))
|
||||
}
|
||||
|
||||
/// A call's clips from the kept media, in the kinds they were sent as; None when one has been pruned.
|
||||
fn media(names: &[&str]) -> Option<Media> {
|
||||
let mut m = Media::default();
|
||||
for n in names {
|
||||
let bytes = record::media(n)?;
|
||||
match n.rsplit('.').next() {
|
||||
Some("mp4") => m.videos.push(bytes),
|
||||
Some("mp3") => m.sounds.push(bytes),
|
||||
_ => m.stills.push(bytes),
|
||||
}
|
||||
}
|
||||
Some(m)
|
||||
}
|
||||
|
||||
/// `try_words(LIKE, WORDS)`: the new words asked of the old question's labelled clips, and both versions held to
|
||||
/// the same labels.
|
||||
pub fn try_words(like: &str, words: &str, o: &Opts, out: &mut dyn FnMut(Event)) -> Result<(Summary, Option<(Standing, Standing)>), String> {
|
||||
let (old, new, groups) = try_groups(like, words)?;
|
||||
let sum = runner::run_groups(groups, Vec::new(), o, out);
|
||||
if o.dry {
|
||||
return Ok((sum, None));
|
||||
}
|
||||
let (all, calls) = (labels::all(), labels::calls());
|
||||
Ok((sum, Some((standing_of(&old, &all, &calls), standing_of(&new, &all, &calls)))))
|
||||
}
|
||||
@@ -1,236 +0,0 @@
|
||||
//! Labels (docs/ask.feature AK6): whether a question's problem was really there in what one call sent, so the question
|
||||
//! can be calibrated on the person's own eye (calibrate.rs). A label belongs to a question and to the clips a call sent
|
||||
//! (by their hashes), never to one answer: the same question reworded, asked again of the same clips, has the same
|
||||
//! labels, which is what lets `try_words` measure new words.
|
||||
//!
|
||||
//! Where labels come from:
|
||||
//! - `verdict(ANSWER, WORD)`: the person answers the question themselves, in its own terms (yes or no, an option,
|
||||
//! a level). Theirs counts first.
|
||||
//! - The feed: a note of the person's on the render (its copy in the project's feed, known by `record::ident`), pinned
|
||||
//! inside the window or not pinned at all, holding one of the question's label words, is a yes; an approved post (done)
|
||||
//! with no such note is a no. Read again by every `calibrate()`.
|
||||
//! - Another eye (`verdict --eye agent`: an agent's own look) is kept as `eye:NAME` and never counted, as the
|
||||
//! fingerprint keeps another eye's readings (FP6d).
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_ask::{Kind, Question};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::record;
|
||||
|
||||
pub const FILE: &str = "labels.jsonl";
|
||||
|
||||
/// A note pinned at t covers 1.5 s before it to 0.5 s after (the fingerprint's span).
|
||||
const BEFORE: f64 = 1.5;
|
||||
const AFTER: f64 = 0.5;
|
||||
|
||||
/// Whether a question's problem is there in one call's clips, and who said so.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Label {
|
||||
pub question: String,
|
||||
/// the clips the call sent, by hash
|
||||
pub media: String,
|
||||
pub bad: bool,
|
||||
/// "verdict" (the person's), "note" or "approval" (read from the feed), or "eye:NAME" (kept, never counted)
|
||||
pub source: String,
|
||||
pub project: String,
|
||||
pub file: String,
|
||||
pub from: f64,
|
||||
pub to: Option<f64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub note: Option<String>,
|
||||
pub at: String,
|
||||
}
|
||||
|
||||
impl Label {
|
||||
/// The person's own: a verdict, a note or an approval.
|
||||
pub fn counted(&self) -> bool {
|
||||
self.rank() > 0
|
||||
}
|
||||
fn rank(&self) -> u8 {
|
||||
match self.source.as_str() {
|
||||
"verdict" => 3,
|
||||
"note" => 2,
|
||||
"approval" => 1,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The clips a call sent, as one key.
|
||||
pub fn media_key(call: &Value) -> String {
|
||||
let mut m: Vec<&str> = call["media"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
|
||||
m.sort_unstable();
|
||||
m.join("+")
|
||||
}
|
||||
|
||||
/// The feed a call's render was posted to: its project's, else the nearest one above its file.
|
||||
fn feed_of(call: &Value) -> Option<PathBuf> {
|
||||
let file = Path::new(call["file"].as_str().unwrap_or_default());
|
||||
call["project"].as_str().map(Path::new).into_iter().chain(file.ancestors()).map(|d| d.join(".raea/feed")).find(|d| d.is_dir())
|
||||
}
|
||||
|
||||
/// A call's project: the folder holding its brief, else the folder holding the feed it was posted to, else its file's.
|
||||
pub fn project_of(call: &Value) -> String {
|
||||
if let Some(p) = call["project"].as_str() {
|
||||
return p.to_string();
|
||||
}
|
||||
let home = feed_of(call).and_then(|f| f.parent()?.parent().map(Path::to_path_buf));
|
||||
let file = Path::new(call["file"].as_str().unwrap_or_default());
|
||||
home.as_deref().or(file.parent()).map(|p| p.display().to_string()).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn all() -> Vec<Label> {
|
||||
record::rows(FILE).into_iter().filter_map(|v| serde_json::from_value(v).ok()).collect()
|
||||
}
|
||||
|
||||
fn write(labels: &[Label]) -> Result<(), String> {
|
||||
record::write_whole(FILE, &labels.iter().filter_map(|l| serde_json::to_string(l).ok()).map(|l| l + "\n").collect::<String>())
|
||||
}
|
||||
|
||||
/// The label that stands for each question and clips: the person's verdict, else a note, else an approval.
|
||||
pub fn standing(labels: &[Label]) -> HashMap<(String, String), &Label> {
|
||||
let mut out: HashMap<(String, String), &Label> = HashMap::new();
|
||||
for l in labels.iter().filter(|l| l.counted()) {
|
||||
let key = (l.question.clone(), l.media.clone());
|
||||
if out.get(&key).is_none_or(|was| l.rank() >= was.rank()) {
|
||||
out.insert(key, l);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A question as its answer kept it (the whole question, else its words).
|
||||
pub fn question_of(answer: &Value) -> Question {
|
||||
serde_json::from_value(answer["q"].clone()).unwrap_or_else(|_| Question::plain(answer["question"].as_str().unwrap_or("q"), answer["ask"].as_str().unwrap_or_default()))
|
||||
}
|
||||
|
||||
/// Whether the answer the person gives means the problem is there: yes's flagged answer (yes, or no for a question
|
||||
/// flagged on no), a flagged option, or a grade or rate in its lower half.
|
||||
pub fn means_problem(q: &Question, said: &str) -> Result<bool, String> {
|
||||
let said = said.trim().to_lowercase();
|
||||
let levels = q.levels();
|
||||
if q.kind == Kind::Yes {
|
||||
return match said.as_str() {
|
||||
"yes" | "no" => Ok((said == "yes") != q.flags.first().is_some_and(|f| f == "no")),
|
||||
_ => Err(format!("{}: answer yes or no", q.id)),
|
||||
};
|
||||
}
|
||||
if q.kind == Kind::Choose && q.flags.is_empty() {
|
||||
return Err(format!("{} picks without a wrong answer, so it isn't calibrated", q.id));
|
||||
}
|
||||
let Some(i) = levels.iter().position(|l| l.to_lowercase() == said) else { return Err(format!("{}: answer one of {}", q.id, levels.join(", "))) };
|
||||
Ok(match q.kind {
|
||||
Kind::Choose => q.flags.iter().any(|f| f.to_lowercase() == said),
|
||||
_ => (i as f64) < (levels.len().max(2) - 1) as f64 / 2.0,
|
||||
})
|
||||
}
|
||||
|
||||
/// Every call in the record, by id.
|
||||
pub fn calls() -> HashMap<String, Value> {
|
||||
record::rows("calls.jsonl").into_iter().filter_map(|c| Some((c["id"].as_str()?.to_string(), c))).collect()
|
||||
}
|
||||
|
||||
fn label(q: &str, call: &Value, bad: bool, source: &str, note: Option<String>) -> Label {
|
||||
Label {
|
||||
question: q.to_string(),
|
||||
media: media_key(call),
|
||||
bad,
|
||||
source: source.into(),
|
||||
project: project_of(call),
|
||||
file: call["file"].as_str().unwrap_or_default().into(),
|
||||
from: call["from"].as_f64().unwrap_or(0.0),
|
||||
to: call["to"].as_f64(),
|
||||
note,
|
||||
at: record::now(),
|
||||
}
|
||||
}
|
||||
|
||||
/// `verdict(ANSWER, WORD, EYE)`: the person's answer to the question on that answer's clips (or another
|
||||
/// eye's, kept and never counted). A verdict given again replaces the last from the same source.
|
||||
pub fn verdict(answer: &str, said: &str, eye: Option<&str>) -> Result<String, String> {
|
||||
let row = record::rows("answers.jsonl").into_iter().find(|a| a["id"] == answer).ok_or_else(|| format!("ask verdict: no answer {answer} in {}", record::dir().display()))?;
|
||||
let call = calls().remove(row["call"].as_str().unwrap_or_default()).ok_or_else(|| format!("ask verdict: answer {answer}'s call isn't in the record"))?;
|
||||
let q = question_of(&row);
|
||||
let bad = means_problem(&q, said)?;
|
||||
let source = eye.map_or_else(|| "verdict".to_string(), |e| format!("eye:{e}"));
|
||||
let new = label(&q.id, &call, bad, &source, None);
|
||||
let mut labels = all();
|
||||
labels.retain(|l| !(l.question == new.question && l.media == new.media && l.source == new.source));
|
||||
let line = format!("{}: {} on {} ({}){}", q.id, if bad { "the problem is there" } else { "no problem" }, new.file, span(new.from, new.to), if eye.is_some() { format!(", kept as {source} and not counted") } else { String::new() });
|
||||
labels.push(new);
|
||||
write(&labels)?;
|
||||
Ok(line)
|
||||
}
|
||||
|
||||
pub fn span(from: f64, to: Option<f64>) -> String {
|
||||
match to {
|
||||
Some(t) => format!("{from:.1}-{t:.1} s"),
|
||||
None if from > 0.0 => format!("from {from:.1} s"),
|
||||
None => "the whole file".into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// One post of a feed: whether it's approved, its person's notes (pinned second or none, words), and its files.
|
||||
struct Post {
|
||||
done: bool,
|
||||
notes: Vec<(Option<f64>, String)>,
|
||||
files: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
fn posts(feed: &Path) -> Vec<Post> {
|
||||
let project = feed.parent().and_then(Path::parent).unwrap_or(feed);
|
||||
let lib = raea_io_home::user_home().unwrap_or_default().join(".raea/feed/media");
|
||||
let mut out = Vec::new();
|
||||
for e in std::fs::read_dir(feed).into_iter().flatten().flatten() {
|
||||
let Some(p) = std::fs::read_to_string(e.path()).ok().and_then(|t| serde_json::from_str::<Value>(&t).ok()) else { continue };
|
||||
let notes = p["notes"].as_array().into_iter().flatten().filter(|n| n["author"]["kind"] == "person").filter_map(|n| Some((n["pin"]["t"].as_f64(), n["text"].as_str()?.to_lowercase()))).collect();
|
||||
let files = p["media"].as_array().into_iter().flatten().filter_map(|m| m["path"].as_str()).filter_map(|m| [lib.join(m), project.join(m)].into_iter().find(|f| f.is_file())).collect();
|
||||
out.push(Post { done: p["status"] == "done", notes, files });
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Labels read again from the person's notes and approvals, for every recorded answer whose question has label words.
|
||||
/// The feed's labels replace the last ones read; verdicts and other eyes' stay. Says how many of each it found.
|
||||
pub fn from_feed() -> Result<(usize, usize), String> {
|
||||
let calls = calls();
|
||||
let mut feeds: HashMap<PathBuf, Vec<Post>> = HashMap::new();
|
||||
let mut idents: HashMap<PathBuf, Option<String>> = HashMap::new();
|
||||
let mut found: HashMap<(String, String), Label> = HashMap::new();
|
||||
for row in record::rows("answers.jsonl") {
|
||||
let q = question_of(&row);
|
||||
let Some(call) = calls.get(row["call"].as_str().unwrap_or_default()) else { continue };
|
||||
let (Some(ident), false) = (call["ident"].as_str(), q.label_words.is_empty()) else { continue };
|
||||
let Some(dir) = feed_of(call) else { continue };
|
||||
let len = record::ident_len(ident);
|
||||
let same = |f: &PathBuf, idents: &mut HashMap<PathBuf, Option<String>>| {
|
||||
std::fs::metadata(f).is_ok_and(|m| Some(m.len()) == len) && idents.entry(f.clone()).or_insert_with(|| record::ident(f)).as_deref() == Some(ident)
|
||||
};
|
||||
let (from, to) = (call["from"].as_f64().unwrap_or(0.0), call["to"].as_f64().unwrap_or(f64::INFINITY));
|
||||
let words: Vec<String> = q.label_words.iter().map(|w| w.to_lowercase()).collect();
|
||||
for post in feeds.entry(dir.clone()).or_insert_with(|| posts(&dir)).iter().filter(|p| p.files.iter().any(|f| same(f, &mut idents))) {
|
||||
let inside = |t: &Option<f64>| t.is_none_or(|t| t - BEFORE < to && t + AFTER > from);
|
||||
let seen = post.notes.iter().find(|(t, text)| inside(t) && words.iter().any(|w| text.contains(w.as_str())));
|
||||
let l = match (seen, post.done) {
|
||||
(Some((_, text)), _) => label(&q.id, call, true, "note", Some(text.clone())),
|
||||
(None, true) => label(&q.id, call, false, "approval", None),
|
||||
(None, false) => continue,
|
||||
};
|
||||
let key = (l.question.clone(), l.media.clone());
|
||||
if found.get(&key).is_none_or(|was| l.rank() > was.rank()) {
|
||||
found.insert(key, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut labels = all();
|
||||
labels.retain(|l| !matches!(l.source.as_str(), "note" | "approval"));
|
||||
let yes = found.values().filter(|l| l.bad).count();
|
||||
let no = found.len() - yes;
|
||||
labels.extend(found.into_values());
|
||||
write(&labels)?;
|
||||
Ok((yes, no))
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use raea_core_ask::{Kind, Question, Reading};
|
||||
use raea_io_clef::{Answered, Call, Fail};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::labels::{self, means_problem};
|
||||
use crate::prepare::Piece;
|
||||
use crate::runner::{self, Entry, Opts};
|
||||
use crate::{calibrate, record};
|
||||
|
||||
/// The labels and calibration files are rewritten whole: one test at a time.
|
||||
static LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
fn reading(p: f64) -> Reading {
|
||||
Reading { value: p, problem: Some(p), choice: None, says: format!("{p:.2}") }
|
||||
}
|
||||
|
||||
fn question(id: &str, words: &[&str]) -> Question {
|
||||
let mut q = Question::plain(id, &format!("Is there a problem the {id} test names?"));
|
||||
q.label_words = words.iter().map(|w| w.to_string()).collect();
|
||||
q
|
||||
}
|
||||
|
||||
/// A call and its answer kept, as the runner keeps them; the answer's id.
|
||||
fn asked(file: &Path, project: &str, clip: &str, q: &Question, p: f64) -> String {
|
||||
let call = record::call(&file.display().to_string(), Some(project), 0.0, Some(5.0), "a test", &[clip.to_string()], "a test", 0.0, false);
|
||||
record::answer(&call, &file.display().to_string(), q, &reading(p), p >= 0.5)
|
||||
}
|
||||
|
||||
fn write(p: &Path, bytes: &[u8]) {
|
||||
std::fs::create_dir_all(p.parent().unwrap()).unwrap();
|
||||
std::fs::write(p, bytes).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_persons_note_on_the_posted_render_labels_it_and_an_approval_labels_it_clean() {
|
||||
crate::tests::setup();
|
||||
let _one = LOCK.lock().unwrap();
|
||||
let proj = std::env::temp_dir().join(format!("raea-ask-notes-{}", std::process::id()));
|
||||
let (a, b, other) = (proj.join("out/a.mp4"), proj.join("out/b.mp4"), proj.join("old/a.mp4"));
|
||||
write(&a, b"render one");
|
||||
write(&b, b"render two");
|
||||
write(&other, b"another render, the same name");
|
||||
let post = |media: &str, status: &str, notes: serde_json::Value| json!({"media": [{"kind": "video", "path": media}], "status": status, "notes": notes});
|
||||
let person = |text: &str, t: Option<f64>| json!({"author": {"kind": "person", "name": "me"}, "text": text, "pin": t.map(|t| json!({"t": t}))});
|
||||
write(&proj.join(".raea/feed/1.json"), post("out/a.mp4", "seen", json!([person("The caption runs OVER HER FACE here", Some(2.0))])).to_string().as_bytes());
|
||||
let agent = json!({"author": {"kind": "agent"}, "text": "over her face"});
|
||||
write(&proj.join(".raea/feed/2.json"), post("out/b.mp4", "done", json!([agent, person("lovely", None)])).to_string().as_bytes());
|
||||
let q = question("notes.face", &["over her face"]);
|
||||
let project = proj.display().to_string();
|
||||
asked(&a, &project, "na.mp4", &q, 0.7);
|
||||
asked(&b, &project, "nb.mp4", &q, 0.2);
|
||||
asked(&other, &project, "nc.mp4", &q, 0.6);
|
||||
assert_eq!(labels::from_feed().unwrap(), (1, 1));
|
||||
let mine: Vec<_> = labels::all().into_iter().filter(|l| l.question == "notes.face").collect();
|
||||
let on = |clip: &str| mine.iter().find(|l| l.media == clip).unwrap_or_else(|| panic!("{clip}: {mine:?}"));
|
||||
assert!(on("na.mp4").bad && on("na.mp4").source == "note" && on("na.mp4").note.as_deref().is_some_and(|n| n.contains("over her face")));
|
||||
assert!(!on("nb.mp4").bad && on("nb.mp4").source == "approval", "an agent's note isn't the person's");
|
||||
assert!(!mine.iter().any(|l| l.media == "nc.mp4"), "another render with the same name isn't the one posted");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_verdict_reads_in_the_questions_terms_and_another_eyes_isnt_counted() {
|
||||
crate::tests::setup();
|
||||
let _one = LOCK.lock().unwrap();
|
||||
let mut q = question("verdict.logo", &[]);
|
||||
assert!(means_problem(&q, "Yes").unwrap() && !means_problem(&q, "no").unwrap());
|
||||
q.flags = vec!["no".into()];
|
||||
assert!(means_problem(&q, "no").unwrap(), "a question flagged on no: no is the problem");
|
||||
let mut g = q.clone();
|
||||
g.kind = Kind::Grade;
|
||||
assert!(means_problem(&g, "weak").unwrap() && !means_problem(&g, "acceptable").unwrap());
|
||||
g.kind = Kind::Choose;
|
||||
g.options = vec!["first".into(), "second".into()];
|
||||
g.flags = vec![];
|
||||
assert!(means_problem(&g, "first").is_err(), "a pick has no wrong answer");
|
||||
let file = std::env::temp_dir().join("raea-ask-verdict.mp4");
|
||||
let id = asked(&file, "p", "v1.mp4", &q, 0.3);
|
||||
labels::verdict(&id, "no", Some("agent")).unwrap();
|
||||
let said = labels::verdict(&id, "no", None).unwrap();
|
||||
assert!(said.contains("the problem is there"), "{said}");
|
||||
let all = labels::all();
|
||||
let standing = labels::standing(&all);
|
||||
let l = standing.get(&("verdict.logo".to_string(), "v1.mp4".to_string())).unwrap();
|
||||
assert!(l.bad && l.source == "verdict");
|
||||
assert!(all.iter().any(|l| l.source == "eye:agent" && !l.counted()));
|
||||
}
|
||||
|
||||
/// clef as a fake: yes to anything sent a clip whose bytes start "bad".
|
||||
fn sees_bad(call: &Call) -> Result<Answered, Fail> {
|
||||
let p = if call.media.videos.iter().any(|v| v.starts_with(b"bad")) { 0.9 } else { 0.1 };
|
||||
let answers = call.questions.iter().map(|q| (q.id.clone(), json!({"noul": p}))).collect();
|
||||
Ok(Answered { answers, cost: 0.001, cached: false, route: "a test".into(), pool_left: None })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn labels_from_three_projects_calibrate_a_question_and_new_words_are_measured_on_the_same_clips() {
|
||||
crate::tests::setup();
|
||||
let _one = LOCK.lock().unwrap();
|
||||
let (good, flat) = (question("cal.good", &[]), question("cal.flat", &[]));
|
||||
let file = PathBuf::from("/nowhere/cal.mp4");
|
||||
for i in 0..36 {
|
||||
let bad = i % 2 == 0;
|
||||
let clip = record::keep_media(format!("{}{i}", if bad { "bad" } else { "ok" }).as_bytes(), "mp4");
|
||||
let project = format!("p{}", i % 3);
|
||||
let call = record::call(&file.display().to_string(), Some(&project), 0.0, Some(3.0), "a test", &[clip], "a test", 0.0, false);
|
||||
let (p, word) = if bad { (0.6 + i as f64 / 1000.0, "yes") } else { (0.3 + i as f64 / 1000.0, "no") };
|
||||
for (q, p) in [(&good, p), (&flat, 0.5)] {
|
||||
let id = record::answer(&call, &file.display().to_string(), q, &reading(p), false);
|
||||
labels::verdict(&id, word, None).unwrap();
|
||||
}
|
||||
}
|
||||
let (all, _) = calibrate::calibrate(None).unwrap();
|
||||
let of = |id: &str| all.iter().find(|s| s.id == id).unwrap_or_else(|| panic!("{id}: {all:?}"));
|
||||
let g = of("cal.good");
|
||||
assert_eq!((g.state.as_str(), g.problems, g.clean, g.projects, g.auc), ("calibrated", 18, 18, 3, Some(1.0)), "{g:?}");
|
||||
let f = of("cal.flat");
|
||||
assert_eq!(f.state, "doesn't separate", "{f:?}");
|
||||
assert!(!f.misses.is_empty() && f.auc == Some(0.5));
|
||||
// the person's calibration goes out with the question from now on
|
||||
let piece = Arc::new(Piece { file: file.clone(), ..Default::default() });
|
||||
let (groups, _) = runner::plan(&[Entry { piece, window: None, questions: vec![good.clone()], dropped: vec![], with: vec![] }]);
|
||||
let sent = &groups[0].questions[0];
|
||||
assert!(sent.calibrated() && sent.calibration.as_ref().is_some_and(|c| c.by == "you"), "{sent:?}");
|
||||
// new words for the flat question, asked of its labelled clips
|
||||
let (sum, both) = calibrate::try_words("cal.flat", "Does anything look broken?", &Opts { jobs: 4, dry: false, ask: sees_bad }, &mut |_| {}).unwrap();
|
||||
let (old, new) = both.unwrap();
|
||||
assert_eq!(sum.calls, 36);
|
||||
assert_eq!((old.auc, new.auc, new.problems + new.clean), (Some(0.5), Some(1.0), 36), "{new:?}");
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//! Questions about a piece's picture and sound (docs/ask.feature AK2-AK3), asked for the fingerprint's double-check
|
||||
//! (`raea fingerprint score --ask`, apps/double). `prepare` reads what raea knows of the piece and keeps the questions
|
||||
//! that apply; `runner` plans the calls, cuts each clip once and asks in parallel; `record` keeps every call and answer;
|
||||
//! `labels` reads the person's notes and approvals into labels, and `calibrate` holds each question to them (AK6-AK7).
|
||||
|
||||
pub mod calibrate;
|
||||
pub mod labels;
|
||||
pub mod prepare;
|
||||
pub mod record;
|
||||
pub mod runner;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod labels_tests;
|
||||
@@ -1,164 +0,0 @@
|
||||
//! Ask understands a question before it spends (docs/ask.feature AK2): what the file holds (ffprobe), what the project's
|
||||
//! brief says it's for, whether anyone speaks in it, and from those which questions can be asked, which are swapped for
|
||||
//! their variant (sound for sound-silent) and which are dropped, each with why. The state paragraph tells clef what the
|
||||
//! piece is, as the app's critique writes it. When it isn't known whether anyone speaks, both variants are kept, the
|
||||
//! voice question goes in the same call (runner.rs), free, and the variant that doesn't apply is set aside.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_ask::{Facts, Question, library};
|
||||
use raea_io_clef::media::{self, Probe};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The question asked beside the rest when no one knows yet whether anyone speaks in the piece.
|
||||
pub const VOICE: &str = "voice-heard";
|
||||
|
||||
/// What raea knows of the piece.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Piece {
|
||||
pub file: PathBuf,
|
||||
pub probe: Probe,
|
||||
/// the brief's fields, as `raea spec brief.ts --as brief` reads them ({} without a brief)
|
||||
pub brief: Value,
|
||||
/// the project's folder (the one holding the brief), when there is one
|
||||
pub project: Option<PathBuf>,
|
||||
/// the words heard, when a words file was given
|
||||
pub words: Option<String>,
|
||||
/// someone speaks: from --voice, or from the words file (none heard is no)
|
||||
pub voice: Option<bool>,
|
||||
/// what the caller adds to the state (what raea measured, the platform)
|
||||
pub extra: Option<String>,
|
||||
}
|
||||
|
||||
/// The brief nearest the file: brief.ts in its folder or any folder above it.
|
||||
pub fn brief_near(file: &Path) -> Option<PathBuf> {
|
||||
let abs = dunce::canonicalize(file).ok()?;
|
||||
abs.ancestors().skip(1).map(|d| d.join("brief.ts")).find(|b| b.is_file())
|
||||
}
|
||||
|
||||
/// A brief's fields, through `raea spec FILE --as brief` (this raea), or {} when it can't be read.
|
||||
fn brief_of(path: &Path) -> Value {
|
||||
let Ok(exe) = std::env::current_exe() else { return json!({}) };
|
||||
let Ok(out) = std::process::Command::new(exe).args(["spec"]).arg(path).args(["--as", "brief"]).output() else { return json!({}) };
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let v: Value = text.find('{').and_then(|i| serde_json::from_str(&text[i..]).ok()).unwrap_or_else(|| json!({}));
|
||||
v.get("brief").cloned().unwrap_or(v)
|
||||
}
|
||||
|
||||
/// The words heard, from a words file (a JSON list of words, each a string or {word} or {text}): their text, and
|
||||
/// whether anyone speaks (an empty list is no one).
|
||||
pub fn words_of(path: &Path) -> Result<(String, bool), String> {
|
||||
let v: Value = serde_json::from_str(&std::fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))?).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
let list = v.as_array().or(v["words"].as_array()).ok_or_else(|| format!("{}: a list of words", path.display()))?;
|
||||
let words: Vec<&str> = list.iter().filter_map(|w| w.as_str().or(w["word"].as_str()).or(w["text"].as_str())).collect();
|
||||
Ok((words.join(" "), !words.is_empty()))
|
||||
}
|
||||
|
||||
impl Piece {
|
||||
/// The piece as raea finds it: the file probed, its brief (given or the nearest), its words.
|
||||
pub fn read(file: &Path, brief: Option<&Path>, words: Option<&Path>, voice: Option<bool>, extra: Option<String>) -> Result<Piece, String> {
|
||||
let probe = media::probe(file)?;
|
||||
// "none": no brief, even with one near (a caller that writes the whole state itself, as the app's critique does)
|
||||
let brief_file = match brief {
|
||||
Some(p) if p.as_os_str() == "none" => None,
|
||||
Some(p) => Some(p.to_path_buf()),
|
||||
None => brief_near(file),
|
||||
};
|
||||
let (words, heard) = match words {
|
||||
Some(w) => words_of(w).map(|(t, h)| (Some(t).filter(|t| !t.is_empty()), Some(h)))?,
|
||||
None => (None, None),
|
||||
};
|
||||
Ok(Piece {
|
||||
file: file.to_path_buf(),
|
||||
probe,
|
||||
brief: brief_file.as_deref().map(brief_of).unwrap_or_else(|| json!({})),
|
||||
project: brief_file.and_then(|b| b.parent().map(Path::to_path_buf)),
|
||||
words,
|
||||
voice: voice.or(heard).or((!probe.sound).then_some(false)),
|
||||
extra,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn modes(&self) -> Vec<String> {
|
||||
let m = &self.brief["mode"];
|
||||
let list: Vec<&str> = m.as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_else(|| m.as_str().into_iter().collect());
|
||||
list.iter().flat_map(|s| s.split(',')).map(|s| s.replace("(assumed)", "").trim().to_string()).filter(|s| !s.is_empty()).collect()
|
||||
}
|
||||
|
||||
pub fn facts(&self) -> Facts {
|
||||
let modes = self.modes();
|
||||
Facts { game: modes.iter().any(|m| m == "play"), modes, voice: self.voice, sound: self.probe.sound, video: self.probe.video }
|
||||
}
|
||||
|
||||
/// What clef reads before the media: what the piece is and what's known of it.
|
||||
pub fn state(&self) -> String {
|
||||
let b = &self.brief;
|
||||
let modes = self.modes();
|
||||
let what = if modes.is_empty() { "video".to_string() } else { modes.join(" and ") };
|
||||
// with no brief and the caller's own state, the caller says what the piece is
|
||||
let briefless = b.as_object().is_none_or(|o| o.is_empty());
|
||||
let mut s = match (b["title"].as_str(), briefless && self.extra.is_some()) {
|
||||
(_, true) => vec![],
|
||||
(Some(t), _) => vec![format!("A {what} piece: \"{t}\".")],
|
||||
(None, _) => vec![format!("A {what} piece.")],
|
||||
};
|
||||
for (k, say) in [("audience", "It's for"), ("believe", "It should leave them believing"), ("logline", "Its storyboard"), ("voice", "Its voice")] {
|
||||
if let Some(v) = b[k].as_str().filter(|v| !v.trim().is_empty()) {
|
||||
s.push(format!("{say}: {}.", v.trim().trim_end_matches('.')));
|
||||
}
|
||||
}
|
||||
if self.voice == Some(false) {
|
||||
s.push("No one speaks in it: its sound is the music and the effects, with no voice.".into());
|
||||
}
|
||||
if let Some(w) = &self.words {
|
||||
let cut: String = w.chars().take(1200).collect();
|
||||
s.push(format!("The words heard: \"{cut}{}\"", if cut.len() < w.len() { "..." } else { "" }));
|
||||
}
|
||||
if self.probe.seconds > 0.0 {
|
||||
s.push(format!("It runs {:.0} s.", self.probe.seconds));
|
||||
}
|
||||
if let Some(x) = &self.extra {
|
||||
s.push(x.trim().to_string());
|
||||
}
|
||||
s.join(" ")
|
||||
}
|
||||
}
|
||||
|
||||
/// Is anyone heard speaking: asked beside the questions that depend on it, at no cost (clef costs by media, not by
|
||||
/// questions), when no one knows yet.
|
||||
pub fn voice_question() -> Question {
|
||||
let mut v = Question::plain(VOICE, "Is anyone heard speaking in it (a voice saying words, not singing)?");
|
||||
v.sees = raea_core_ask::Sees::Nothing;
|
||||
v
|
||||
}
|
||||
|
||||
/// The questions kept for this piece, and those dropped with why. A question that doesn't apply is swapped for its
|
||||
/// variant when that one does; not knowing whether anyone speaks, both are kept.
|
||||
pub fn keep(questions: Vec<Question>, f: &Facts, rubric_md: Option<&str>) -> (Vec<Question>, Vec<(String, String)>) {
|
||||
let mut asked: Vec<Question> = Vec::new();
|
||||
let mut dropped = Vec::new();
|
||||
let add = |q: Question, asked: &mut Vec<Question>| {
|
||||
if !asked.iter().any(|a| a.id == q.id) {
|
||||
asked.push(q);
|
||||
}
|
||||
};
|
||||
for q in questions {
|
||||
let Some(why) = q.not_for(f) else {
|
||||
// not knowing whether anyone speaks, its variant goes in too: one call answers either way
|
||||
let twin = (f.voice.is_none() && q.when.voice.is_some()).then(|| q.swap.as_deref().and_then(|s| library::find(s, rubric_md))).flatten();
|
||||
add(q, &mut asked);
|
||||
if let Some(t) = twin {
|
||||
add(t, &mut asked);
|
||||
}
|
||||
continue;
|
||||
};
|
||||
match q.swap.as_deref().and_then(|s| library::find(s, rubric_md)).filter(|s| s.not_for(f).is_none()) {
|
||||
Some(s) => {
|
||||
dropped.push((q.id.clone(), format!("{why}: asked {} instead", s.id)));
|
||||
add(s, &mut asked);
|
||||
}
|
||||
None => dropped.push((q.id.clone(), why)),
|
||||
}
|
||||
}
|
||||
(asked, dropped)
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
//! Every answer kept (docs/ask.feature AK3), so a question can be labelled, calibrated and reworded later (AK6, AK7):
|
||||
//! each call in calls.jsonl (the file, the window, the state, the clips it sent by hash, the route and the cost) and each
|
||||
//! answer in answers.jsonl (the call, the question and its version, the reading). The clips themselves are kept by hash
|
||||
//! in media/, at most 2 GB, the oldest out first, so new words can be asked of the same media. A call keeps what its
|
||||
//! file was (`ident`), so a note on the render's copy in the feed labels it (labels.rs), and an answer keeps its whole
|
||||
//! question, so a verdict reads in its terms and `try_words` can reword it.
|
||||
|
||||
use std::io::Write as _;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_ask::{Question, Reading};
|
||||
use serde_json::{Value, json};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
/// How much cut media is kept.
|
||||
pub const MEDIA_CAP: u64 = 2 << 30;
|
||||
|
||||
pub fn dir() -> PathBuf {
|
||||
raea_io_clef::cache::dir()
|
||||
}
|
||||
|
||||
/// A new id: a prefix and twelve hex digits, from the time, the process and a counter.
|
||||
pub fn new_id(prefix: &str) -> String {
|
||||
static N: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
let t = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_nanos()).unwrap_or(0);
|
||||
let seed = format!("{t}-{}-{}", std::process::id(), N.fetch_add(1, std::sync::atomic::Ordering::Relaxed));
|
||||
let h = seed.bytes().fold(0xcbf2_9ce4_8422_2325u64, |h, b| (h ^ b as u64).wrapping_mul(0x0100_0000_01b3));
|
||||
format!("{prefix}-{:012x}", h & 0xffff_ffff_ffff)
|
||||
}
|
||||
|
||||
pub fn now() -> String {
|
||||
let s = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
|
||||
s.to_string()
|
||||
}
|
||||
|
||||
fn append(file: &str, row: &Value) {
|
||||
let d = dir();
|
||||
if std::fs::create_dir_all(&d).is_err() {
|
||||
return;
|
||||
}
|
||||
// one write a row: several runs (a script's, two at once) append to the same file, and a row written in pieces
|
||||
// could be split by another's
|
||||
if let Ok(mut f) = std::fs::OpenOptions::new().create(true).append(true).open(d.join(file)) {
|
||||
let _ = f.write_all(format!("{row}\n").as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
fn hex(digest: &[u8]) -> String {
|
||||
digest.iter().take(16).map(|b| format!("{b:02x}")).collect()
|
||||
}
|
||||
|
||||
/// What a file is, cheaply, and the size an ident names (raea-core-ask's).
|
||||
pub use raea_core_ask::ident::{ident, ident_len};
|
||||
|
||||
/// One of the record's files written whole, through a temporary file, so a reader never sees half of it.
|
||||
pub fn write_whole(file: &str, text: &str) -> Result<(), String> {
|
||||
let d = dir();
|
||||
let tmp = d.join(format!("{file}.{}.tmp", std::process::id()));
|
||||
let put = || -> std::io::Result<()> {
|
||||
std::fs::create_dir_all(&d)?;
|
||||
std::fs::write(&tmp, text)?;
|
||||
std::fs::rename(&tmp, d.join(file))
|
||||
};
|
||||
put().map_err(|e| format!("{}: {e}", d.display()))
|
||||
}
|
||||
|
||||
/// A clip kept by its hash, as `HASH.EXT` (already kept is left alone).
|
||||
pub fn keep_media(bytes: &[u8], ext: &str) -> String {
|
||||
let name = format!("{}.{ext}", hex(&Sha256::digest(bytes)));
|
||||
let d = dir().join("media");
|
||||
let p = d.join(&name);
|
||||
if !p.is_file() && std::fs::create_dir_all(&d).is_ok() {
|
||||
let _ = std::fs::write(&p, bytes);
|
||||
prune(MEDIA_CAP);
|
||||
}
|
||||
name
|
||||
}
|
||||
|
||||
/// A kept clip's bytes, by its name.
|
||||
pub fn media(name: &str) -> Option<Vec<u8>> {
|
||||
std::fs::read(dir().join("media").join(name)).ok()
|
||||
}
|
||||
|
||||
/// The kept media held to `cap` bytes, the least recently written going first.
|
||||
pub fn prune(cap: u64) {
|
||||
let Ok(rd) = std::fs::read_dir(dir().join("media")) else { return };
|
||||
let mut files: Vec<(std::time::SystemTime, u64, PathBuf)> = rd
|
||||
.flatten()
|
||||
.filter_map(|e| e.metadata().ok().and_then(|m| Some((m.modified().ok()?, m.len(), e.path()))))
|
||||
.collect();
|
||||
let mut total: u64 = files.iter().map(|f| f.1).sum();
|
||||
files.sort();
|
||||
for (_, len, p) in files {
|
||||
if total <= cap {
|
||||
break;
|
||||
}
|
||||
if std::fs::remove_file(&p).is_ok() {
|
||||
total -= len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One call kept; its id.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn call(file: &str, project: Option<&str>, from: f64, to: Option<f64>, state: &str, media: &[String], route: &str, cost: f64, cached: bool) -> String {
|
||||
let id = new_id("c");
|
||||
let row = json!({
|
||||
"id": id, "at": now(), "file": file, "ident": ident(Path::new(file)), "project": project, "from": from, "to": to, "state": state,
|
||||
"media": media, "route": route, "cost": cost, "cached": cached,
|
||||
});
|
||||
append("calls.jsonl", &row);
|
||||
id
|
||||
}
|
||||
|
||||
/// One answer kept; its id.
|
||||
pub fn answer(call: &str, file: &str, q: &Question, r: &Reading, flagged: bool) -> String {
|
||||
let id = new_id("a");
|
||||
let whole = serde_json::to_value(Question { calibration: None, ..q.clone() }).unwrap_or_default();
|
||||
let row = json!({
|
||||
"id": id, "at": now(), "call": call, "file": file, "question": q.id, "version": q.version(), "ask": q.ask,
|
||||
"value": r.value, "problem": r.problem, "choice": r.choice, "says": r.says, "flagged": flagged, "calibrated": q.calibrated(),
|
||||
"q": whole,
|
||||
});
|
||||
append("answers.jsonl", &row);
|
||||
id
|
||||
}
|
||||
|
||||
/// Every row of one of the record's files.
|
||||
pub fn rows(file: &str) -> Vec<Value> {
|
||||
std::fs::read_to_string(dir().join(file)).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).collect()
|
||||
}
|
||||
@@ -1,365 +0,0 @@
|
||||
//! One runner for every caller (docs/ask.feature AK3): a batch planned into calls (grouped by file, window, the files
|
||||
//! beside it and what of the picture its questions look at, at most 64 questions a call, the voice question added to a
|
||||
//! call whose questions depend on whether anyone speaks when that isn't known), each clip cut once, the calls
|
||||
//! made in parallel, the answers streamed back as they come and kept. A pool that's spent partway keeps what came and
|
||||
//! reports the rest as waiting for it. `dry` cuts the media and says what would be sent, and spends nothing. A group can
|
||||
//! carry clips kept from an earlier call instead of a file to cut (`try_words`), and every question goes out with the
|
||||
//! person's own calibration when it has earned one (calibrate.rs).
|
||||
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex, mpsc};
|
||||
|
||||
use raea_core_ask::{Kind, Picks, Question, Sees, Window, limits};
|
||||
use raea_io_clef::{Answered, Call, Fail, Media, media};
|
||||
use serde::Serialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::prepare::{self, Piece, VOICE};
|
||||
use crate::{calibrate, record};
|
||||
|
||||
/// What to ask of one file: its questions (prepared), those dropped with why, a window over all of them (else each
|
||||
/// question's own), and files set beside it (to pick between, or before and after).
|
||||
pub struct Entry {
|
||||
pub piece: Arc<Piece>,
|
||||
pub window: Option<Window>,
|
||||
pub questions: Vec<Question>,
|
||||
pub dropped: Vec<(String, String)>,
|
||||
pub with: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
/// One call's worth.
|
||||
pub struct Group {
|
||||
pub piece: Arc<Piece>,
|
||||
pub from: f64,
|
||||
pub to: Option<f64>,
|
||||
pub sees: Sees,
|
||||
pub hears: bool,
|
||||
pub with: Vec<PathBuf>,
|
||||
pub questions: Vec<Question>,
|
||||
/// clips kept from an earlier call, sent again in place of cutting the file
|
||||
pub kept: Option<Arc<Kept>>,
|
||||
}
|
||||
|
||||
/// An earlier call's clips and state, and their seconds of video and sound (for the estimate).
|
||||
pub struct Kept {
|
||||
pub media: Media,
|
||||
pub state: String,
|
||||
pub video_seconds: f64,
|
||||
pub sound_seconds: f64,
|
||||
}
|
||||
|
||||
/// One answer, or why a question wasn't asked or still waits: one line of JSON each.
|
||||
#[derive(Debug, Clone, Default, Serialize)]
|
||||
pub struct Answer {
|
||||
/// its id in the record (`labels::verdict` takes it)
|
||||
pub answer: Option<String>,
|
||||
pub file: String,
|
||||
pub id: String,
|
||||
pub version: String,
|
||||
pub from: f64,
|
||||
pub to: Option<f64>,
|
||||
pub says: Option<String>,
|
||||
pub value: Option<f64>,
|
||||
pub problem: Option<f64>,
|
||||
pub choice: Option<String>,
|
||||
pub flagged: bool,
|
||||
pub calibrated: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub not_asked: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub waits: Option<String>,
|
||||
pub route: Option<String>,
|
||||
pub cached: bool,
|
||||
}
|
||||
|
||||
/// What the run came to.
|
||||
#[derive(Debug, Clone, Default, Serialize)]
|
||||
pub struct Summary {
|
||||
pub asked: usize,
|
||||
pub answered: usize,
|
||||
pub calls: usize,
|
||||
pub cost: f64,
|
||||
pub estimate: f64,
|
||||
pub pool_left: Option<f64>,
|
||||
pub waiting: usize,
|
||||
pub flagged: usize,
|
||||
pub flagged_calibrated: usize,
|
||||
pub routes: BTreeSet<String>,
|
||||
/// the clips cut (each once, however many calls used it)
|
||||
pub clips: usize,
|
||||
}
|
||||
|
||||
/// What the runner tells its caller as it goes: an answer, or (dry) a call it would make.
|
||||
pub enum Event<'a> {
|
||||
Answer(&'a Answer),
|
||||
Would(&'a Value),
|
||||
}
|
||||
|
||||
pub struct Opts {
|
||||
pub jobs: usize,
|
||||
pub dry: bool,
|
||||
/// how a call is made: `raea_io_clef::ask` (a test gives its own)
|
||||
pub ask: fn(&Call) -> Result<Answered, Fail>,
|
||||
}
|
||||
|
||||
impl Opts {
|
||||
pub fn new(jobs: usize, dry: bool) -> Opts {
|
||||
Opts { jobs, dry, ask: raea_io_clef::ask }
|
||||
}
|
||||
}
|
||||
|
||||
const NAMES: [&str; 4] = ["first", "second", "third", "fourth"];
|
||||
|
||||
/// A pick's options: the files given, in order (all, or all but the first, the reference).
|
||||
fn picks(p: Picks, files: usize) -> Vec<String> {
|
||||
let n = files.min(NAMES.len());
|
||||
let skip = usize::from(p == Picks::AfterFirst);
|
||||
NAMES[skip.min(n)..n].iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
/// The batch as calls.
|
||||
pub fn plan(entries: &[Entry]) -> (Vec<Group>, Vec<Answer>) {
|
||||
let mut groups: Vec<Group> = Vec::new();
|
||||
let mut unasked = Vec::new();
|
||||
let mine = calibrate::local();
|
||||
for e in entries {
|
||||
let file = e.piece.file.display().to_string();
|
||||
for (id, why) in &e.dropped {
|
||||
unasked.push(Answer { file: file.clone(), id: id.clone(), not_asked: Some(why.clone()), ..Default::default() });
|
||||
}
|
||||
for q in &e.questions {
|
||||
let w = e.window.or(q.window).unwrap_or_default();
|
||||
let (from, to) = (w.from.unwrap_or(0.0).max(0.0), w.to);
|
||||
let mut q = q.clone();
|
||||
calibrate::apply(&mut q, &mine);
|
||||
if let Some(p) = q.picks {
|
||||
q.kind = Kind::Choose;
|
||||
q.options = picks(p, 1 + e.with.len());
|
||||
}
|
||||
let compares = q.picks.is_some_and(|_| q.options.len() < 2) || (q.uses.iter().any(|u| u == "with") && e.with.is_empty());
|
||||
if compares {
|
||||
unasked.push(Answer { file: file.clone(), version: q.version(), not_asked: Some("it compares files: set one or more beside it (--with)".into()), id: q.id, ..Default::default() });
|
||||
continue;
|
||||
}
|
||||
// one place in each call is kept for the voice question
|
||||
let same = |g: &&mut Group| Arc::ptr_eq(&g.piece, &e.piece) && g.from == from && g.to == to && g.sees == q.sees && g.with == e.with && g.questions.len() < limits::QUESTIONS - 1;
|
||||
match groups.iter_mut().find(same) {
|
||||
Some(g) => {
|
||||
g.hears |= q.hears;
|
||||
g.questions.push(q);
|
||||
}
|
||||
None => groups.push(Group { piece: e.piece.clone(), from, to, sees: q.sees, hears: q.hears, with: e.with.clone(), questions: vec![q], kept: None }),
|
||||
}
|
||||
}
|
||||
}
|
||||
for g in &mut groups {
|
||||
g.hears &= g.piece.probe.sound || g.with.iter().any(|f| media::probe(f).is_ok_and(|p| p.sound));
|
||||
if g.hears && g.piece.voice.is_none() && g.questions.iter().any(|q| q.when.voice.is_some()) {
|
||||
g.questions.push(prepare::voice_question());
|
||||
}
|
||||
}
|
||||
(groups, unasked)
|
||||
}
|
||||
|
||||
/// Clips cut once a run, by what they are.
|
||||
type Cuts = Mutex<HashMap<String, Result<Arc<Vec<u8>>, String>>>;
|
||||
|
||||
fn cut(cuts: &Cuts, key: String, make: impl FnOnce() -> Result<Vec<u8>, String>) -> Result<Arc<Vec<u8>>, String> {
|
||||
if let Some(r) = cuts.lock().unwrap().get(&key) {
|
||||
return r.clone();
|
||||
}
|
||||
let r = make().map(Arc::new);
|
||||
cuts.lock().unwrap().insert(key, r.clone());
|
||||
r
|
||||
}
|
||||
|
||||
/// A group's media, and its seconds of video and of sound (for the estimate).
|
||||
fn media_of(g: &Group, cuts: &Cuts) -> Result<(Media, f64, f64), String> {
|
||||
if let Some(k) = &g.kept {
|
||||
return Ok((k.media.clone(), k.video_seconds, k.sound_seconds));
|
||||
}
|
||||
let files: Vec<&Path> = std::iter::once(g.piece.file.as_path()).chain(g.with.iter().map(PathBuf::as_path)).collect();
|
||||
let (from, to) = (g.from, g.to);
|
||||
let span = |p: &media::Probe| (to.unwrap_or(p.seconds) - from).clamp(0.0, p.seconds.max(0.1));
|
||||
let mut m = Media::default();
|
||||
let (mut vs, mut ss) = (0.0, 0.0);
|
||||
for f in &files {
|
||||
let p = if *f == g.piece.file.as_path() { g.piece.probe } else { media::probe(f)? };
|
||||
let k = |what: &str| format!("{what}:{}:{from}:{to:?}", f.display());
|
||||
match g.sees {
|
||||
Sees::Video if p.video => {
|
||||
m.videos.push(cut(cuts, k("video"), || media::video(f, from, to))?.to_vec());
|
||||
vs += span(&p).min(limits::VIDEO_SECONDS);
|
||||
}
|
||||
Sees::Video | Sees::Stills if !p.video => m.stills.push(cut(cuts, k("still"), || media::still(f, None))?.to_vec()),
|
||||
Sees::Stills if files.len() == 1 => {
|
||||
let len = span(&p);
|
||||
for i in 0..limits::STILLS {
|
||||
let at = from + len * (i as f64 + 0.5) / limits::STILLS as f64;
|
||||
m.stills.push(cut(cuts, k(&format!("frame{i}")), || media::still(f, Some(at)))?.to_vec());
|
||||
}
|
||||
}
|
||||
Sees::Stills => m.stills.push(cut(cuts, k("frame"), || media::still(f, Some(from + span(&p) / 2.0)))?.to_vec()),
|
||||
_ => {}
|
||||
}
|
||||
if g.hears && p.sound {
|
||||
m.sounds.push(cut(cuts, k("sound"), || media::sound(f, from, to))?.to_vec());
|
||||
ss += span(&p).min(limits::SOUND_SECONDS);
|
||||
}
|
||||
}
|
||||
if m.videos.len() > limits::VIDEOS || m.stills.len() > limits::STILLS || m.sounds.len() > limits::SOUNDS {
|
||||
return Err(format!("too many files for one call: at most {} videos, {} stills and {} sounds", limits::VIDEOS, limits::STILLS, limits::SOUNDS));
|
||||
}
|
||||
Ok((m, vs, ss))
|
||||
}
|
||||
|
||||
enum Done {
|
||||
Asked(Answered, Vec<String>, String),
|
||||
Would(Value),
|
||||
Failed(String),
|
||||
Waits(String),
|
||||
}
|
||||
|
||||
/// Every entry asked, at most `jobs` calls at once, each event told to `out` as it comes (in the caller's thread).
|
||||
pub fn run(entries: Vec<Entry>, o: &Opts, out: &mut dyn FnMut(Event)) -> Summary {
|
||||
let (groups, unasked) = plan(&entries);
|
||||
run_groups(groups, unasked, o, out)
|
||||
}
|
||||
|
||||
/// Planned groups asked, the questions not asked told first.
|
||||
pub fn run_groups(groups: Vec<Group>, unasked: Vec<Answer>, o: &Opts, out: &mut dyn FnMut(Event)) -> Summary {
|
||||
let mut sum = Summary::default();
|
||||
for a in &unasked {
|
||||
out(Event::Answer(a));
|
||||
}
|
||||
let cuts: Cuts = Mutex::default();
|
||||
let (next, spent) = (AtomicUsize::new(0), AtomicBool::new(false));
|
||||
let spent_why = Mutex::new(String::new());
|
||||
let (tx, rx) = mpsc::channel::<(usize, Done)>();
|
||||
std::thread::scope(|s| {
|
||||
for _ in 0..o.jobs.clamp(1, 16).min(groups.len().max(1)) {
|
||||
let (tx, groups, cuts, next, spent, spent_why) = (tx.clone(), &groups, &cuts, &next, &spent, &spent_why);
|
||||
s.spawn(move || {
|
||||
loop {
|
||||
let i = next.fetch_add(1, Ordering::Relaxed);
|
||||
let Some(g) = groups.get(i) else { break };
|
||||
let done = if spent.load(Ordering::Relaxed) {
|
||||
Done::Waits(spent_why.lock().unwrap().clone())
|
||||
} else {
|
||||
match media_of(g, cuts) {
|
||||
Err(e) => Done::Failed(e),
|
||||
Ok((m, vs, ss)) => {
|
||||
let state = g.kept.as_ref().map_or_else(|| g.piece.state(), |k| k.state.clone());
|
||||
let call = Call { state, questions: g.questions.clone(), media: m };
|
||||
let estimate = limits::estimate(vs, ss, call.media.stills.len(), call.state.len(), call.questions.len());
|
||||
if o.dry {
|
||||
Done::Would(would(g, &call, estimate))
|
||||
} else {
|
||||
match (o.ask)(&call) {
|
||||
Ok(a) => Done::Asked(a, kept(&call.media), call.state),
|
||||
Err(Fail::Spent(why)) => {
|
||||
spent.store(true, Ordering::Relaxed);
|
||||
*spent_why.lock().unwrap() = why.clone();
|
||||
Done::Waits(why)
|
||||
}
|
||||
Err(f) => Done::Failed(f.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if tx.send((i, done)).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
drop(tx);
|
||||
for (i, done) in rx {
|
||||
told(&groups[i], done, &mut sum, out);
|
||||
}
|
||||
});
|
||||
sum.clips = cuts.lock().unwrap().values().filter(|c| c.is_ok()).count();
|
||||
sum
|
||||
}
|
||||
|
||||
/// The clips a call sent, kept by hash for `try_words`.
|
||||
fn kept(m: &Media) -> Vec<String> {
|
||||
let each = |v: &[Vec<u8>], ext: &str| v.iter().map(|b| record::keep_media(b, ext)).collect::<Vec<_>>();
|
||||
[each(&m.videos, "mp4"), each(&m.stills, "jpg"), each(&m.sounds, "mp3")].concat()
|
||||
}
|
||||
|
||||
fn would(g: &Group, call: &Call, estimate: f64) -> Value {
|
||||
let sizes = |v: &[Vec<u8>]| v.iter().map(Vec::len).collect::<Vec<_>>();
|
||||
json!({
|
||||
"file": g.piece.file.display().to_string(), "from": g.from, "to": g.to,
|
||||
"questions": call.questions.iter().map(|q| json!({"id": q.id, "ask": q.ask, "type": q.kind})).collect::<Vec<_>>(),
|
||||
"state": call.state,
|
||||
"media": {"videos": sizes(&call.media.videos), "stills": sizes(&call.media.stills), "sounds": sizes(&call.media.sounds)},
|
||||
"estimate_usd": estimate,
|
||||
})
|
||||
}
|
||||
|
||||
/// A finished call's answers told, kept and counted. When the voice question went along, the variant that doesn't
|
||||
/// apply (sound where no one speaks, sound-silent where someone does) is set aside.
|
||||
fn told(g: &Group, done: Done, sum: &mut Summary, out: &mut dyn FnMut(Event)) {
|
||||
let file = g.piece.file.display().to_string();
|
||||
// the voice question only decides between variants: it isn't told
|
||||
let asked: Vec<&Question> = g.questions.iter().filter(|q| q.id != VOICE).collect();
|
||||
let base = |q: &Question| Answer { file: file.clone(), id: q.id.clone(), version: q.version(), from: g.from, to: g.to, calibrated: q.calibrated(), ..Default::default() };
|
||||
match done {
|
||||
Done::Would(v) => {
|
||||
sum.calls += 1;
|
||||
sum.estimate += v["estimate_usd"].as_f64().unwrap_or(0.0);
|
||||
out(Event::Would(&v));
|
||||
}
|
||||
Done::Failed(why) | Done::Waits(why) if g.questions.is_empty() => drop(why),
|
||||
Done::Failed(why) => asked.iter().for_each(|q| out(Event::Answer(&Answer { not_asked: Some(why.clone()), ..base(q) }))),
|
||||
Done::Waits(why) => {
|
||||
sum.waiting += asked.len();
|
||||
asked.iter().for_each(|q| out(Event::Answer(&Answer { waits: Some(format!("waits for the pool: {why}")), ..base(q) })));
|
||||
}
|
||||
Done::Asked(a, clips, state) => {
|
||||
sum.calls += 1;
|
||||
sum.asked += asked.len();
|
||||
sum.cost += a.cost;
|
||||
sum.pool_left = a.pool_left.or(sum.pool_left);
|
||||
sum.routes.insert(a.route.clone());
|
||||
let project = g.piece.project.as_ref().map(|p| p.display().to_string());
|
||||
let call = record::call(&file, project.as_deref(), g.from, g.to, &state, &clips, &a.route, a.cost, a.cached);
|
||||
let heard = a.answers.get(VOICE).and_then(|v| v["noul"].as_f64());
|
||||
for q in g.questions.iter().filter(|q| q.id != VOICE) {
|
||||
let Some(ans) = a.answers.get(&q.id) else {
|
||||
out(Event::Answer(&Answer { not_asked: Some("no answer came back for it".into()), ..base(q) }));
|
||||
continue;
|
||||
};
|
||||
if let (Some(p), Some(v)) = (heard, q.when.voice) {
|
||||
if v != (p >= 0.5) {
|
||||
let who = if p >= 0.5 { "someone speaks" } else { "no one speaks" };
|
||||
out(Event::Answer(&Answer { not_asked: Some(format!("set aside: {who} ({p:.2})")), ..base(q) }));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let r = q.read(ans);
|
||||
let flagged = q.flagged(&r);
|
||||
sum.answered += 1;
|
||||
sum.flagged += usize::from(flagged);
|
||||
sum.flagged_calibrated += usize::from(flagged && q.calibrated());
|
||||
let id = record::answer(&call, &file, q, &r, flagged);
|
||||
out(Event::Answer(&Answer {
|
||||
answer: Some(id),
|
||||
says: Some(r.says),
|
||||
value: Some(r.value),
|
||||
problem: r.problem,
|
||||
choice: r.choice,
|
||||
flagged,
|
||||
route: Some(a.route.clone()),
|
||||
cached: a.cached,
|
||||
..base(q)
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
use raea_core_ask::{Facts, Kind, Picks, Question, Sees, Window, library};
|
||||
use raea_io_clef::media::Probe;
|
||||
use raea_io_clef::{Answered, Call, Fail};
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
use crate::prepare::{self, Piece, VOICE};
|
||||
use crate::runner::{self, Answer, Entry, Event, Opts};
|
||||
|
||||
fn rubric() -> String {
|
||||
std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/../../sdk/guides/craft/verbs/critique.md")).expect("the critique guide")
|
||||
}
|
||||
|
||||
pub(crate) fn setup() {
|
||||
static ONCE: std::sync::Once = std::sync::Once::new();
|
||||
// SAFETY: set once, before any test reads it, to the same value for every test
|
||||
ONCE.call_once(|| unsafe { std::env::set_var("RAEA_ASK_DIR", std::env::temp_dir().join(format!("raea-ask-test-{}", std::process::id()))) });
|
||||
}
|
||||
|
||||
fn ids(qs: &[Question]) -> Vec<&str> {
|
||||
qs.iter().map(|q| q.id.as_str()).collect()
|
||||
}
|
||||
|
||||
fn piece(file: &str, voice: Option<bool>) -> Arc<Piece> {
|
||||
let probe = Probe { seconds: 10.0, video: true, still: false, sound: true };
|
||||
Arc::new(Piece { file: PathBuf::from(file), probe, voice, ..Default::default() })
|
||||
}
|
||||
|
||||
fn entry(p: &Arc<Piece>, window: Option<Window>, questions: Vec<Question>) -> Entry {
|
||||
Entry { piece: p.clone(), window, questions, dropped: vec![], with: vec![] }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_one_speaking_asks_sound_silent_and_a_file_without_sound_isnt_listened_to() {
|
||||
let r = rubric();
|
||||
let sound = library::find("sound", Some(&r)).unwrap();
|
||||
let silent = Facts { voice: Some(false), sound: true, video: true, ..Default::default() };
|
||||
let (asked, dropped) = prepare::keep(vec![sound.clone()], &silent, Some(&r));
|
||||
assert_eq!(ids(&asked), ["sound-silent"]);
|
||||
assert!(dropped[0].1.contains("no one speaks") && dropped[0].1.contains("sound-silent instead"), "{dropped:?}");
|
||||
let mut listen = Question::plain("loud", "Is it loud?");
|
||||
listen.sees = Sees::Nothing;
|
||||
let (asked, dropped) = prepare::keep(vec![listen], &Facts { video: true, ..Default::default() }, None);
|
||||
assert!(asked.is_empty() && dropped[0].1.contains("no sound"), "{dropped:?}");
|
||||
// not knowing whether anyone speaks, both are kept, and the plan adds the voice question to their call
|
||||
let unknown = Facts { sound: true, video: true, ..Default::default() };
|
||||
let (asked, _) = prepare::keep(vec![sound], &unknown, Some(&r));
|
||||
assert_eq!(ids(&asked), ["sound", "sound-silent"]);
|
||||
let (groups, _) = runner::plan(&[entry(&piece("a.mp4", None), None, asked)]);
|
||||
assert_eq!(groups.len(), 1);
|
||||
assert_eq!(ids(&groups[0].questions), ["sound", "sound-silent", VOICE]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_state_says_what_the_piece_is() {
|
||||
let mut p = (*piece("a.mp4", Some(false))).clone();
|
||||
p.brief = json!({"title": "Spring launch", "mode": ["pitch"], "audience": "busy founders", "believe": "it saves them an hour."});
|
||||
p.extra = Some("raea measured -14 LUFS.".into());
|
||||
let s = p.state();
|
||||
for want in ["A pitch piece: \"Spring launch\".", "It's for: busy founders.", "believing: it saves them an hour.", "No one speaks", "runs 10 s", "-14 LUFS"] {
|
||||
assert!(s.contains(want), "{want}: {s}");
|
||||
}
|
||||
assert_eq!(p.facts().modes, ["pitch"]);
|
||||
// no brief and the caller's own state: the caller says what the piece is
|
||||
let own = Piece { extra: Some("A game: \"Rover\".".into()), ..(*piece("a.mp4", None)).clone() };
|
||||
assert_eq!(own.state(), "It runs 10 s. A game: \"Rover\".");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calls_hold_64_questions_and_split_by_window_and_what_they_look_at() {
|
||||
let p = piece("a.mp4", Some(true));
|
||||
let many: Vec<Question> = (0..65).map(|i| Question::plain(&format!("q{i}"), "Is it loud?")).collect();
|
||||
let (groups, _) = runner::plan(&[entry(&p, None, many)]);
|
||||
assert_eq!(groups.iter().map(|g| g.questions.len()).collect::<Vec<_>>(), [63, 2], "one place a call is kept for the voice question");
|
||||
let hook = Window { from: Some(0.0), to: Some(3.0) };
|
||||
let mut still = Question::plain("s", "Is the text readable?");
|
||||
still.sees = Sees::Stills;
|
||||
let (groups, _) = runner::plan(&[entry(&p, None, vec![Question::plain("a", "Is it loud?"), still]), entry(&p, Some(hook), vec![Question::plain("b", "Is it loud?")])]);
|
||||
assert_eq!(groups.len(), 3);
|
||||
let mut pick = Question::plain("best", "Which suits the brief best?");
|
||||
pick.picks = Some(Picks::All);
|
||||
let (groups, unasked) = runner::plan(&[entry(&p, None, vec![pick])]);
|
||||
assert!(groups.is_empty() && unasked[0].not_asked.as_deref().is_some_and(|n| n.contains("--with")), "{unasked:?}");
|
||||
let (groups, unasked) = runner::plan(&[entry(&p, None, vec![library::find("decide.changed", None).unwrap()])]);
|
||||
assert!(groups.is_empty() && !unasked[0].version.is_empty(), "{unasked:?}");
|
||||
}
|
||||
|
||||
/// clef's answers as a fake gives them: yes 0.8 to every yes question (0.9 to the voice question), the lowest level of
|
||||
/// a grade.
|
||||
fn answers(call: &Call) -> Map<String, Value> {
|
||||
call.questions
|
||||
.iter()
|
||||
.map(|q| {
|
||||
let a = match q.kind {
|
||||
Kind::Yes => json!({"noul": if q.id == VOICE { 0.9 } else { 0.8 }}),
|
||||
_ => json!({"choice": q.levels()[0], "probabilities": {q.levels()[0].clone(): 1.0}}),
|
||||
};
|
||||
(q.id.clone(), a)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn answered(call: &Call) -> Answered {
|
||||
Answered { answers: answers(call), cost: 0.001, cached: false, route: "a test".into(), pool_left: Some(1.5) }
|
||||
}
|
||||
|
||||
/// A 2 s clip with a picture and a tone, made with FFmpeg.
|
||||
fn clip(name: &str) -> PathBuf {
|
||||
let out = std::env::temp_dir().join(format!("raea-ask-{}-{name}.mp4", std::process::id()));
|
||||
let ff = raea_io_assets::ffmpeg_tool("ffmpeg", false).expect("FFmpeg");
|
||||
let ok = std::process::Command::new(ff)
|
||||
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc=size=320x240:rate=10:duration=2", "-f", "lavfi", "-i", "sine=frequency=440:duration=2"])
|
||||
.args(["-c:v", "mpeg4", "-c:a", "aac", "-shortest"])
|
||||
.arg(&out)
|
||||
.status()
|
||||
.expect("FFmpeg ran");
|
||||
assert!(ok.success());
|
||||
out
|
||||
}
|
||||
|
||||
fn run(entries: Vec<Entry>, jobs: usize, ask: fn(&Call) -> Result<Answered, Fail>) -> (runner::Summary, Vec<Answer>) {
|
||||
setup();
|
||||
let mut got = Vec::new();
|
||||
let sum = runner::run(entries, &Opts { jobs, dry: false, ask }, &mut |e| {
|
||||
if let Event::Answer(a) = e {
|
||||
got.push(a.clone());
|
||||
}
|
||||
});
|
||||
(sum, got)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_clip_is_cut_once_and_the_voice_answer_sets_a_variant_aside() {
|
||||
let file = clip("once");
|
||||
let p = Arc::new(Piece::read(&file, None, None, None, None).unwrap());
|
||||
assert!(p.probe.video && p.probe.sound && p.voice.is_none());
|
||||
let r = rubric();
|
||||
let (asked, _) = prepare::keep(vec![library::find("sound", Some(&r)).unwrap()], &p.facts(), Some(&r));
|
||||
let mut listen = Question::plain("loud", "Is it too loud?");
|
||||
listen.sees = Sees::Nothing;
|
||||
let (sum, got) = run(vec![entry(&p, None, [asked, vec![listen]].concat())], 4, |c| Ok(answered(c)));
|
||||
assert_eq!((sum.calls, sum.clips), (2, 2), "the picture's call and the sound's call share one cut of the sound");
|
||||
let by = |id: &str| got.iter().find(|a| a.id == id).unwrap_or_else(|| panic!("{id}: {got:?}"));
|
||||
assert!(by("sound").says.is_some() && by("loud").flagged);
|
||||
assert!(by("sound-silent").not_asked.as_deref().is_some_and(|n| n.contains("someone speaks (0.90)")), "{:?}", by("sound-silent"));
|
||||
assert!(!got.iter().any(|a| a.id == VOICE), "the voice question isn't told");
|
||||
assert_eq!((sum.answered, sum.cost, sum.pool_left), (2, 0.002, Some(1.5)));
|
||||
}
|
||||
|
||||
static CALLS: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
#[test]
|
||||
fn a_pool_spent_partway_keeps_what_came_and_the_rest_waits() {
|
||||
let file = clip("spent");
|
||||
let p = Arc::new(Piece::read(&file, None, None, Some(true), None).unwrap());
|
||||
let at = |s: f64| Some(Window { from: Some(s), to: Some(s + 0.5) });
|
||||
let entries = (0..4).map(|i| entry(&p, at(i as f64 * 0.4), vec![Question::plain(&format!("w{i}"), "Is it loud?")])).collect();
|
||||
let (sum, got) = run(entries, 1, |c| match CALLS.fetch_add(1, Ordering::SeqCst) {
|
||||
2 => Err(Fail::Spent("this month's pool is used up".into())),
|
||||
_ => Ok(answered(c)),
|
||||
});
|
||||
assert_eq!((sum.calls, sum.answered, sum.waiting), (2, 2, 2));
|
||||
assert_eq!(got.iter().filter(|a| a.waits.as_deref().is_some_and(|w| w.contains("used up"))).count(), 2);
|
||||
assert_eq!(CALLS.load(Ordering::SeqCst), 3, "nothing is sent after the pool is spent");
|
||||
}
|
||||
@@ -20,14 +20,12 @@ raea-io-ffmpeg = { path = "../../io/ffmpeg" }
|
||||
raea-sys-measure = { path = "../../systems/measure" }
|
||||
# what it reads of a video, through FFmpeg or raea's own decoders where it isn't installed
|
||||
raea-app-check-read = { path = "read" }
|
||||
# who can fix what it finds: the encode's or the picture's own, carried, a source
|
||||
# who can fix what it finds: the encode's or the picture's own, carried, a source (split out to keep this crate small)
|
||||
raea-app-check-cause = { path = "cause" }
|
||||
# the text rules on a render's manifest (split out: raea render holds its own text to them)
|
||||
raea-app-check-text = { path = "text" }
|
||||
# the flashing screen (WCAG 2.3.1)
|
||||
# the flashing screen (WCAG 2.3.1), split out to keep this crate small
|
||||
raea-app-check-flash = { path = "flash" }
|
||||
# what the person sent from the raea app, handed to the agent
|
||||
# what the person sent from the raea app, handed to the agent (split out to keep this crate small)
|
||||
raea-app-check-inbox = { path = "inbox" }
|
||||
# the Stop gate for a `make` job (docs/goal.feature MK2)
|
||||
raea-app-check-make = { path = "make" }
|
||||
serde_json = "1"
|
||||
@@ -53,7 +53,7 @@ pub fn luma(rgba: &[u8], width: usize, w: usize, h: usize) -> Vec<u8> {
|
||||
}
|
||||
|
||||
/// `frames` as `comp` draws them, never encoded, as luma `w` x `h` (top-left): `raea render COMP --at F,... -o DIR/`
|
||||
/// (PNG) run by `raea` from the project, kept out of its record (RAEA_RECORD=off)
|
||||
/// (PNG) run by `raea` from the project, kept out of its record as the quick check's stills are
|
||||
pub fn unencoded(raea: &Path, project: &Path, comp: &Path, frames: &[i64], w: usize, h: usize) -> R<Vec<Vec<u8>>> {
|
||||
let mut wanted: Vec<i64> = frames.to_vec();
|
||||
wanted.sort_unstable();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! The flashing screen behind `raea check` (apps/check flash.rs feeds it the decoded frames): a pure measure of pixels.
|
||||
//! The flashing screen behind `raea check` (apps/check flash.rs feeds it the decoded frames): a pure measure of pixels,
|
||||
//! in a crate of its own so the check stays small (tools/size.sh).
|
||||
|
||||
/// Flashing past WCAG 2.3.1: more than three flashes in any one second, over enough of the frame to matter. A flash is a
|
||||
/// pair of opposing changes in the same pixels, so a shape sliding past isn't one. Each window, a third of the frame wide
|
||||
|
||||
@@ -55,11 +55,6 @@ fn said(l: &Value) -> String {
|
||||
"result" => format!("a result{on}: {text}"),
|
||||
"correction" => format!("a correction{on}: {text}"),
|
||||
"sign" => format!("a sign-off{on} (ask {})", l["ask"]),
|
||||
// a show only to be looked at (raea show --fyi), looked at: Got it, with a word or none
|
||||
"seen" => {
|
||||
let word = text.strip_prefix("Seen").unwrap_or(&text).trim_start_matches(':').trim();
|
||||
if word.is_empty() { format!("seen{on}") } else { format!("seen{on}: {word}") }
|
||||
}
|
||||
k => format!("{}{on}: {text}", if k.is_empty() { "something" } else { k }),
|
||||
};
|
||||
format!("- {what}")
|
||||
@@ -73,17 +68,6 @@ pub fn told(agent: &str, v: &Value) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
let list = lines.iter().map(said).collect::<Vec<_>>().join("\n");
|
||||
// only Got it on what was shown to look at: nothing to take up
|
||||
if !lines.iter().any(|l| l["kind"] != "seen") {
|
||||
return Some(format!("raea: the person has looked at what you showed them (your inbox, ~/.raea/inbox/{inbox}.jsonl):\n{list}\nNothing to do about it; carry on."));
|
||||
}
|
||||
// a session started again (resumed) after the person wrote to it while it was closed (Shane 11-28: "notes reach
|
||||
// closed sessions"): what waited is handed over before anything else
|
||||
if v["hook_event_name"].as_str() == Some("SessionStart") {
|
||||
return Some(format!(
|
||||
"raea: while this session was closed, the person sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up first, before anything else. Answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."
|
||||
));
|
||||
}
|
||||
Some(format!(
|
||||
"raea: the person just sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up now, before going on: it may change what you're doing. What you say next shows under your session in their feed; answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."
|
||||
))
|
||||
@@ -94,17 +78,11 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
/// an empty inbox folder of the test's own
|
||||
fn scratch(tag: &str) -> std::path::PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-inbox-{tag}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_line_is_handed_over_once_and_a_half_written_one_waits() {
|
||||
let d = scratch("once");
|
||||
let d = std::env::temp_dir().join(format!("raea-inbox-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
let f = d.join("claude-code-abcd1234.jsonl");
|
||||
std::fs::write(&f, "{\"kind\":\"message\",\"text\":\"more epic\"}\n{\"kind\":\"no").unwrap();
|
||||
let first = unread(&d, "claude-code-abcd1234");
|
||||
@@ -119,25 +97,6 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn seen_is_said_as_seen_and_asks_nothing() {
|
||||
assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen"})), "- seen on item i-2 \"Lobby\"");
|
||||
assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen: lovely"})), "- seen on item i-2 \"Lobby\": lovely");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_waited_while_it_was_closed_is_handed_over_as_it_starts_again() {
|
||||
let d = scratch("start");
|
||||
std::fs::write(d.join("claude-code-5e55a0ff.jsonl"), "{\"kind\":\"edits\",\"item\":\"i-9\",\"title\":\"Cut\",\"text\":\"tighter open\"}\n").unwrap();
|
||||
// SAFETY: tests in this crate don't read RAEA_INBOX_DIR concurrently
|
||||
unsafe { std::env::set_var("RAEA_INBOX_DIR", &d) };
|
||||
let start = told("claude", &json!({"hook_event_name": "SessionStart", "source": "resume", "session_id": "5e55a0ff-1"})).unwrap();
|
||||
assert!(start.starts_with("raea: while this session was closed") && start.contains("- edits on item i-9 \"Cut\":\ntighter open"), "{start}");
|
||||
assert_eq!(told("claude", &json!({"hook_event_name": "UserPromptSubmit", "session_id": "5e55a0ff-1"})), None, "handed over once");
|
||||
unsafe { std::env::remove_var("RAEA_INBOX_DIR") };
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_inbox_is_named_as_raea_show_names_it() {
|
||||
assert_eq!(name("claude", &json!({"session_id": "15cd6bb0-8829-466f-a28a-bbca3d35be92"})).as_deref(), Some("claude-code-15cd6bb0"));
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
[package]
|
||||
name = "raea-app-check-make"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea hook`'s Stop gate for a `make` job (docs/goal.feature MK36): an agent can't end its turn until `raea goal check --at done` passes"
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1"
|
||||
# brief.ts found as raea finds a project (plain paths on Windows)
|
||||
dunce = "1"
|
||||
# the project's folder (record.rs `up`)
|
||||
raea-core-facts = { path = "../../../core/facts" }
|
||||
# the guard's counts, under the home folder
|
||||
raea-io-home = { path = "../../../io/home" }
|
||||
@@ -1,125 +0,0 @@
|
||||
//! raea-app-check-make: the Stop hook's moment of the loop (docs/goal.feature MK36): an agent working in a project with a
|
||||
//! brief.ts can't end its turn until `raea goal check --at done` passes: every goal the brief holds (or, with none, the
|
||||
//! floor) and every raea file reached from the brief (`registered`). Run by `raea goal check`, a child process, so this
|
||||
//! crate carries none of the rules. A session blocked three times with the same open items goes through: it's going in
|
||||
//! circles, and the person is better told than the agent looped.
|
||||
|
||||
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
/// How many times the same open items may block one session before the stop goes through.
|
||||
pub const SAME_BLOCKS: u32 = 3;
|
||||
|
||||
/// The project's brief.ts, at or above `cwd` inside its raea project: every brief is held, none is an outlier.
|
||||
pub fn brief_with_job(cwd: &Path) -> Option<PathBuf> {
|
||||
let project = raea_core_facts::record::up(cwd, ".raea/project");
|
||||
for d in dunce::canonicalize(cwd).ok()?.ancestors() {
|
||||
let p = d.join("brief.ts");
|
||||
if p.is_file() {
|
||||
return Some(p);
|
||||
}
|
||||
if project.as_deref() == Some(d) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn hash(parts: &[&str]) -> u64 {
|
||||
let mut h = DefaultHasher::new();
|
||||
parts.hash(&mut h);
|
||||
h.finish()
|
||||
}
|
||||
|
||||
/// Counts this session's blocks on the same open items in `guard` ("<items hash> <count>"); true while it may block.
|
||||
pub fn may_block(guard: &Path, items: &str) -> bool {
|
||||
let key = hash(&[items]).to_string();
|
||||
let count = std::fs::read_to_string(guard).ok().and_then(|t| {
|
||||
let (k, n) = t.trim().split_once(' ')?;
|
||||
(k == key).then(|| n.parse::<u32>().ok()).flatten()
|
||||
});
|
||||
let next = count.unwrap_or(0) + 1;
|
||||
let _ = std::fs::create_dir_all(guard.parent().unwrap_or(Path::new(".")));
|
||||
let _ = std::fs::write(guard, format!("{key} {next}"));
|
||||
next <= SAME_BLOCKS
|
||||
}
|
||||
|
||||
/// What the agent is told when its turn may not end, or None to let it end: no job here, the job passes, the runner
|
||||
/// didn't run (never block on raea's own failure), or the same items have blocked it three times already.
|
||||
pub fn stop(v: &Value) -> Option<String> {
|
||||
let cwd = PathBuf::from(v["cwd"].as_str()?);
|
||||
let brief = brief_with_job(&cwd)?;
|
||||
let exe = std::env::current_exe().ok()?;
|
||||
let out = std::process::Command::new(exe).args(["check", "--at", "done", "--json"]).current_dir(brief.parent()?).env("RAEA_RECORD", "off").output().ok()?;
|
||||
let r: Value = serde_json::from_slice(&out.stdout).ok()?;
|
||||
let home = raea_io_home::user_home()?;
|
||||
let session = v["session_id"].as_str().unwrap_or("");
|
||||
let guard = home.join(".raea/hooks/goal").join(format!("{:x}", hash(&[session, &brief.display().to_string()])));
|
||||
if r["passed"] == true {
|
||||
let _ = std::fs::remove_file(&guard);
|
||||
return None;
|
||||
}
|
||||
let items = open_items(&r);
|
||||
if !may_block(&guard, &items) {
|
||||
return None;
|
||||
}
|
||||
let goals: Vec<String> = r["goals"].as_array().into_iter().flatten().filter(|g| g["passed"] != true).filter_map(|g| g["name"].as_str().map(String::from)).collect();
|
||||
let open = if goals.is_empty() { String::new() } else { format!("goal {}, ", goals.join(", ")) };
|
||||
Some(format!("Not done ({open}{}): {items}. Fix each in its composition and render it again (its check runs at the render's end): `raea check --at done` lists them with their fixes, and review/goal.json holds them all.", brief.display()))
|
||||
}
|
||||
|
||||
/// The open items, one line each: each error-level finding (its check and file), then each check that broke.
|
||||
pub fn open_items(r: &Value) -> String {
|
||||
let mut items: Vec<String> = r["findings"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|x| x["level"] == "error")
|
||||
.map(|x| format!("{}{}: {}", x["check"].as_str().unwrap_or(""), x["file"].as_str().map(|f| format!(" {f}")).unwrap_or_default(), x["says"].as_str().unwrap_or("")))
|
||||
.collect();
|
||||
for b in r["broke"].as_array().into_iter().flatten() {
|
||||
items.push(format!("{} broke: {}", b["check"].as_str().unwrap_or(""), b["says"].as_str().unwrap_or("")));
|
||||
}
|
||||
items.join("; ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
fn tmp(name: &str) -> PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-goal-gate-{name}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(d.join("compositions")).unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_brief_is_held_with_or_without_a_goal() {
|
||||
let d = tmp("job");
|
||||
assert_eq!(brief_with_job(&d.join("compositions")), None, "no brief, nothing held");
|
||||
std::fs::write(d.join("brief.ts"), "export default brief({ title: \"x\" })").unwrap();
|
||||
assert_eq!(brief_with_job(&d.join("compositions")).map(|p| p.file_name().unwrap().to_owned()), Some("brief.ts".into()), "a brief without a goal is held to the floor and registered");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_same_open_items_block_three_times_then_go_through() {
|
||||
let g = tmp("guard").join("g");
|
||||
assert!(may_block(&g, "a") && may_block(&g, "a") && may_block(&g, "a"));
|
||||
assert!(!may_block(&g, "a"), "a fourth stop on the same items goes through");
|
||||
assert!(may_block(&g, "a; b"), "new items start the count again");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_items_list_each_error_then_each_broken_check() {
|
||||
let r = json!({"findings": [
|
||||
{"check": "deliverables", "level": "error", "file": null, "says": "missing: out/kit/lineup.png"},
|
||||
{"check": "cta", "level": "error", "file": "out/cuts/a_9x16.mp4", "says": "no CTA in its last 8 s"},
|
||||
{"check": "place", "level": "warn", "file": "out/cuts/a_9x16.mp4", "says": "a warning holds nothing"}],
|
||||
"broke": [{"check": "mine", "says": "x is undefined"}]});
|
||||
assert_eq!(open_items(&r), "deliverables: missing: out/kit/lineup.png; cta out/cuts/a_9x16.mp4: no CTA in its last 8 s; mine broke: x is undefined");
|
||||
}
|
||||
}
|
||||
+26
-16
@@ -3,10 +3,9 @@
|
||||
//! --agent A` adds them, and they hold inside the raea app too, which leaves each agent its own shell). Before a shell
|
||||
//! command: media opened in the Mac's viewer or a browser is stopped once while the raea app is installed, the reason
|
||||
//! naming `raea show`; the same command tried again goes through, so an agent that means it says so twice. After a
|
||||
//! file is saved: nothing (docs/check.feature: a render checks its own output at its end). As a turn ends: `raea check
|
||||
//! --at done` on the brief's goals (apps/check/make), which reads each deliverable's kept check. After any tool, and as
|
||||
//! a turn ends: what the person sent from the raea app (inbox.rs). A stop is exit 2 with the reason on stderr, which
|
||||
//! every harness hands its agent; what was sent goes back in the shape each one reads.
|
||||
//! file is saved: the quick check on a composition. After any tool, and as a turn ends: what the person sent from the raea
|
||||
//! app (inbox.rs). A stop is exit 2 with the reason on stderr, which every harness
|
||||
//! hands its agent; the quick check's findings go back in the shape each one reads.
|
||||
use serde_json::{Value, json};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -114,6 +113,17 @@ pub fn steer(files: &[String]) -> String {
|
||||
format!("raea: the raea app is installed here, so show this in it, not the Mac's viewer: `raea show {list}` (several stills make a storyboard; add --ask \"what you want from the person\"; inside the raea app, feed_post does the same). It brings the app's window up on it as an item the person can answer, and their answer comes to the inbox file it prints. If the Mac's viewer really is what's wanted (the person asked for it, or raea show can't), run the same command again and it goes through.")
|
||||
}
|
||||
|
||||
/// The files a tool call saved: `file_path` or `path` (Claude Code, Kimi Code, Gemini CLI), or the files an apply_patch
|
||||
/// adds or updates (Codex).
|
||||
fn saved(v: &Value) -> Vec<String> {
|
||||
let i = &v["tool_input"];
|
||||
if let Some(p) = i["file_path"].as_str().or(i["path"].as_str()).or(i["absolute_path"].as_str()) {
|
||||
return vec![p.to_string()];
|
||||
}
|
||||
let patch = i["command"].as_str().or(i["input"].as_str()).unwrap_or("");
|
||||
patch.lines().filter_map(|l| ["*** Add File: ", "*** Update File: "].iter().find_map(|head| l.strip_prefix(head))).map(str::trim).map(String::from).collect()
|
||||
}
|
||||
|
||||
/// Findings for the agent in the shape its harness reads after a tool: Gemini CLI's AfterTool context, Kimi Code's
|
||||
/// plain stdout, Claude Code's and Codex's PostToolUse context.
|
||||
fn after(agent: &str, text: &str) -> String {
|
||||
@@ -138,17 +148,9 @@ pub fn hook(args: &[String]) -> R<String> {
|
||||
let event = v["hook_event_name"].as_str().unwrap_or("");
|
||||
// what the person sent from the raea app since the last look (inbox.rs): handed over after any tool, and a turn about
|
||||
// to end goes on to take it up
|
||||
let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop" | "SessionStart" | "UserPromptSubmit") { crate::inbox::told(agent, &v) } else { None };
|
||||
// a session starting again, or the person writing to it in its terminal: what they sent from raea while it was
|
||||
// closed or idle goes in as context first (Claude Code's and Codex's SessionStart and UserPromptSubmit read
|
||||
// hookSpecificOutput.additionalContext)
|
||||
if matches!(event, "SessionStart" | "UserPromptSubmit") {
|
||||
return Ok(sent.map(|t| json!({"hookSpecificOutput": {"hookEventName": event, "additionalContext": t}}).to_string()).unwrap_or_default());
|
||||
}
|
||||
let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop") { crate::inbox::told(agent, &v) } else { None };
|
||||
if event == "Stop" {
|
||||
// what the person sent, and a brief whose goals don't pass at done (docs/goal.feature MK36): either keeps the turn going
|
||||
let reasons: Vec<String> = [sent, raea_app_check_make::stop(&v)].into_iter().flatten().collect();
|
||||
return Ok(if reasons.is_empty() { String::new() } else { json!({"decision": "block", "reason": reasons.join("\n\n")}).to_string() });
|
||||
return Ok(sent.map(|s| json!({"decision": "block", "reason": s}).to_string()).unwrap_or_default());
|
||||
}
|
||||
let after_tool = matches!(event, "PostToolUse" | "AfterTool");
|
||||
if let Some(cmd) = shell_command(&v).filter(|_| !after_tool) {
|
||||
@@ -161,8 +163,14 @@ pub fn hook(args: &[String]) -> R<String> {
|
||||
}
|
||||
return Ok(String::new());
|
||||
}
|
||||
// no check after a save (docs/check.feature CK1): a render checks its own output at its end, once
|
||||
Ok(sent.map(|t| after(agent, &t)).unwrap_or_default())
|
||||
let mut found = Vec::new();
|
||||
for path in saved(&v).iter().filter(|p| p.ends_with(".tsx") && std::fs::read_to_string(p).is_ok_and(|t| t.contains("registerRoot"))) {
|
||||
let (report, _) = crate::quick::quick(std::slice::from_ref(path), Vec::new())?;
|
||||
found.extend(report.lines().skip(1).filter(|l| !l.starts_with("ok ")).map(String::from));
|
||||
}
|
||||
let quick = (!found.is_empty()).then(|| format!("raea check --quick after this save:\n{}", found.join("\n")));
|
||||
let text = [sent, quick].into_iter().flatten().collect::<Vec<_>>().join("\n\n");
|
||||
Ok(if text.is_empty() { String::new() } else { after(agent, &text) })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -188,6 +196,8 @@ mod tests {
|
||||
assert_eq!(agent_of(&json!({"hook_event_name": "PreToolUse", "tool_name": "Bash"})), "claude");
|
||||
assert_eq!(shell_command(&json!({"tool_name": "shell_command", "tool_input": {"command": "open a.png"}})), Some("open a.png"));
|
||||
assert_eq!(shell_command(&json!({"tool_name": "apply_patch", "tool_input": {"command": "*** Begin Patch\n"}})), None);
|
||||
assert_eq!(saved(&json!({"tool_input": {"command": "*** Begin Patch\n*** Update File: a/E.tsx\n@@\n*** Add File: b.ts\n"}})), ["a/E.tsx", "b.ts"]);
|
||||
assert_eq!(saved(&json!({"tool_input": {"path": "E.tsx"}})), ["E.tsx"]);
|
||||
assert_eq!(after("kimi", "x"), "x");
|
||||
assert!(after("gemini", "x").contains("AfterTool") && after("codex", "x").contains("PostToolUse"));
|
||||
assert!(steer(&["a b.png".into()]).contains("`raea show \"a b.png\"`"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `raea check VIDEO.mp4 [--manifest render.json] [--words W.json] [--perception P.json] [--shape 9:16]
|
||||
//! `raea check VIDEO.mp4 [--manifest render.json] [--words W.json] [--perception P.json] [--things T.json] [--shape 9:16]
|
||||
//! [--platform tiktok|reels|shorts] [-o check.json]`: the floor's measurable lines on an export (docs/craft-system.md, I; sdk/guides/craft/floor.md).
|
||||
//! Each issue is ranked P0 (breaks the piece) to P3 (polish), with where it is and what to do. Rules on the file alone:
|
||||
//! loudness and true peak, a steady sound that stops dead (a source run out, a cut with no fade), stretches where nothing
|
||||
@@ -28,6 +28,7 @@ use raea_app_check_text::*;
|
||||
use raea_app_check_cause as cause;
|
||||
/// a video read through FFmpeg, or raea's own decoders where it isn't installed
|
||||
use raea_app_check_read::{self as read, Probe};
|
||||
pub mod quick;
|
||||
pub mod hook;
|
||||
pub use raea_app_check_inbox as inbox;
|
||||
#[cfg(test)]
|
||||
@@ -65,7 +66,7 @@ fn flag<'a>(args: &'a [String], name: &str) -> Option<&'a str> {
|
||||
args.iter().position(|a| a == name).and_then(|i| args.get(i + 1)).map(String::as_str)
|
||||
}
|
||||
|
||||
pub const USAGE: &str = "raea check VIDEO.mp4 [--manifest render.json] [--words W.json] [--perception P.json] [--shape 16:9|9:16|4:5|1:1] [--platform tiktok|reels|shorts] [-o check.json] (an export against the floor: clipped text, contrast, safe areas, freezes, flashing, cues, loudness, blotching, a placeholder brand kit; its findings errors, warns and notes)";
|
||||
pub const USAGE: &str = "raea check VIDEO.mp4 [--manifest render.json] [--words W.json] [--perception P.json] [--things T.json] [--shape 16:9|9:16|4:5|1:1] [--platform tiktok|reels|shorts] [--taste taste.ts|DIR] [-o check.json] (an export against the floor: clipped text, contrast, safe areas, freezes, flashing, cues, loudness, blotching, a placeholder brand kit, and with --things what `raea fingerprint things --json` found: a thing floating or passing through another, the camera lurching mid-move, an empty frame; its findings errors, warns and notes)";
|
||||
|
||||
/// A rule from the person's taste: a form raea can measure, its value, and the taste line it stands for.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -75,10 +76,9 @@ struct Taste {
|
||||
line: String,
|
||||
}
|
||||
|
||||
/// The checks among a person's taste rules (taste.ts and its kinds) that a video alone shows (the six forms), each
|
||||
/// with the line it stands for.
|
||||
/// The checks among a person's taste rules (taste.ts and its kinds), each with the line it stands for.
|
||||
fn taste_rules(tastes: &[raea_core_brief::Taste]) -> Vec<Taste> {
|
||||
tastes.iter().flat_map(|t| t.checks()).map(|(line, c)| Taste { form: c.form(), value: c.value(), line: line.to_string() }).collect()
|
||||
tastes.iter().flat_map(|t| &t.sections).flat_map(|s| &s.rules).filter_map(|r| r.check.map(|c| Taste { form: c.form(), value: c.value(), line: r.text.clone() })).collect()
|
||||
}
|
||||
|
||||
fn taste_of<'a>(rules: &'a [Taste], form: &str) -> Option<&'a Taste> {
|
||||
@@ -115,7 +115,7 @@ fn taste_text(rules: &[Taste], runs: &[Run], w: f64, h: f64, issues: &mut Vec<Is
|
||||
}
|
||||
|
||||
/// the flags `raea check` takes, each with a value
|
||||
const TAKES: [&str; 6] = ["--manifest", "--words", "--perception", "--shape", "--platform", "-o"];
|
||||
const TAKES: [&str; 8] = ["--manifest", "--words", "--perception", "--things", "--shape", "--platform", "--taste", "-o"];
|
||||
|
||||
fn run(args: &[String], tastes: Vec<raea_core_brief::Taste>) -> R<(String, bool)> {
|
||||
let (video, issues, passed, fps) = measured(args, taste_rules(&tastes))?;
|
||||
@@ -217,7 +217,7 @@ fn report(video: &str, issues: Vec<Issue>, more: Vec<Finding>, passed: Vec<Strin
|
||||
std::fs::write(out, serde_json::to_string_pretty(&j).unwrap()).map_err(|e| format!("{out}: {e}"))?;
|
||||
}
|
||||
let mut s = format!("raea check {video}\n");
|
||||
// kept in its project's record beside its renders (DR3), what `raea findings` and `raea goal next` read
|
||||
// kept in its project's record beside its renders (DR3), what `raea findings` and `raea next` read
|
||||
let kept = raea_core_facts::record::keep("raea check", std::path::Path::new(video), out.map(std::path::Path::new), &found, vec![], &raea_io_trace::utc(std::time::SystemTime::now()).1);
|
||||
let kept = kept.map(|e| format!("raea check: kept in the project's record as {} (raea findings reads it)", e.id));
|
||||
for line in found.iter().map(Finding::line).chain(passed.iter().map(|p| format!("ok {p}"))).chain(kept) {
|
||||
|
||||
@@ -15,16 +15,6 @@ pub(crate) const MOST: f32 = 4.0;
|
||||
pub(crate) const RUN: usize = 4;
|
||||
pub(crate) const BACK: usize = 4;
|
||||
pub(crate) const BLOTCHY: f64 = 0.009;
|
||||
/// The least blotching an encoder's patches have been measured at (the VideoToolbox exports' 0.012): a score between
|
||||
/// BLOTCHY and this, whose cause can't be told, is a warning, never an error (12-05: a 3D shot rendered at master
|
||||
/// quality read 0.010, from its shadows' own dithered edge, and was an error whose fix, master quality, it already had)
|
||||
pub(crate) const BLOTCHED: f64 = 0.012;
|
||||
|
||||
/// How a finding whose cause can't be told stands: an error when more than a fifth of the samples blotch and the worst
|
||||
/// is past BLOTCHED, else a warning
|
||||
pub(crate) fn untold_level(share: f64, worst: f64) -> u8 {
|
||||
if share > 0.2 && worst >= BLOTCHED { 1 } else { 2 }
|
||||
}
|
||||
|
||||
pub(crate) fn blotch_score(y: &[u8], w: usize, h: usize) -> Option<f64> {
|
||||
let (bw, bh) = (w / 8, h / 8);
|
||||
@@ -180,7 +170,7 @@ pub(crate) fn blotching_from(video: &str, probe: &Probe, scores: &[Option<f64>],
|
||||
let t = k as f64 * 2.0;
|
||||
seen += 1;
|
||||
worst = worst.max(s);
|
||||
if raea_io_trace::stat("RAEA_CHECK_DEBUG") {
|
||||
if std::env::var_os("RAEA_CHECK_DEBUG").is_some() {
|
||||
eprintln!("blotch {t:6.1}s {s:.3}");
|
||||
}
|
||||
if s > BLOTCHY {
|
||||
@@ -200,8 +190,8 @@ pub(crate) fn blotching_from(video: &str, probe: &Probe, scores: &[Option<f64>],
|
||||
let own = if a.0.before > 0 { format!("; {} of the samples show the footage's own too, which stays", a.0.before) } else { String::new() };
|
||||
(if a.0.worse as f64 / a.0.of.max(1) as f64 > 0.2 { 1 } else { 2 }, first.or(Some(at)), format!("the encode added blocky patches in dark areas: {} of {} samples are blotchier than the composition draws them unencoded; render with --quality master, which gives the darks the bits they need{own}", a.0.worse, a.0.of))
|
||||
}
|
||||
Some(Err(why)) => (untold_level(share, worst), Some(at), format!("{found}; whether the encode made them or the picture holds them couldn't be told ({why}): render with --quality master if the encode starved the darks")),
|
||||
None => (untold_level(share, worst), Some(at), format!("{found}: the encode starved the near-blacks, or the footage holds them; render with --quality master, and check a render made in a raea project to tell which")),
|
||||
Some(Err(why)) => (if share > 0.2 { 1 } else { 2 }, Some(at), format!("{found}; whether the encode made them or the picture holds them couldn't be told ({why}): render with --quality master if the encode starved the darks")),
|
||||
None => (if share > 0.2 { 1 } else { 2 }, Some(at), format!("{found}: the encode starved the near-blacks, or the footage holds them; render with --quality master, and check a render made in a raea project to tell which")),
|
||||
};
|
||||
issues.push(Issue { rule: "blotching", p, at, says });
|
||||
} else if seen > 0 {
|
||||
@@ -209,29 +199,26 @@ pub(crate) fn blotching_from(video: &str, probe: &Probe, scores: &[Option<f64>],
|
||||
}
|
||||
}
|
||||
|
||||
/// Caption contrast: at each text's middle frame, the pixels behind it where it is on that frame against its colour, at
|
||||
/// least 3:1. The pixels
|
||||
/// Caption contrast: at each text's middle frame, the pixels behind it against its colour, at least 3:1. The pixels
|
||||
/// behind are the half of the box least like the text.
|
||||
pub(crate) fn contrast(video: &str, runs: &[Run], w: f64, h: f64, probe: &Probe, issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let (sx, sy) = (probe.w / w, probe.h / h);
|
||||
let mut low = 0;
|
||||
let mut measured = 0;
|
||||
for r in runs.iter().filter(|r| r.size >= 20.0).take(80) {
|
||||
let (t, [x, y, bw, bh]) = r.middle(probe.fps);
|
||||
let [x, y, bw, bh] = r.box_;
|
||||
let crop = [(x * sx).max(0.0) as u32, (y * sy).max(0.0) as u32, (bw * sx) as u32, (bh * sy) as u32];
|
||||
if crop[0] + crop[2] > probe.w as u32 || crop[1] + crop[3] > probe.h as u32 {
|
||||
continue;
|
||||
}
|
||||
let t = (r.from + r.to) / 2.0;
|
||||
// the same measure `raea world` joins to a text from its render (raea-sys-measure, DR2)
|
||||
// each colour its words are drawn in (an accent word's beside the line's), held to the lowest
|
||||
let measure = |color: &str| if crate::read::native() { crate::read::contrast(video, t, crop, color) } else { raea_sys_measure::contrast(std::path::Path::new(video), t, crop, color) };
|
||||
let worst = r.middle_inks().into_iter().filter_map(|c| measure(c).map(|v| (v, c))).min_by(|a, b| a.0.total_cmp(&b.0));
|
||||
let Some((ratio, color)) = worst else { continue };
|
||||
let word = if color == r.middle_color() { String::new() } else { format!(" (its words in {color})") };
|
||||
let ratio = if crate::read::native() { crate::read::contrast(video, t, crop, &r.color) } else { raea_sys_measure::contrast(std::path::Path::new(video), t, crop, &r.color) };
|
||||
let Some(ratio) = ratio else { continue };
|
||||
measured += 1;
|
||||
if ratio < 3.0 {
|
||||
low += 1;
|
||||
issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{}{word} is {:.2}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text), (ratio * 100.0).floor() / 100.0) });
|
||||
issues.push(Issue { rule: "contrast", p: 1, at: Some(t), says: format!("{} is {ratio:.1}:1 against what's behind it; make it at least 3:1 (a band, a shadow for separation, or another colour)", quote(&r.text)) });
|
||||
}
|
||||
}
|
||||
if measured > 0 && low == 0 {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//! `raea check EDIT.tsx --quick` (docs/skills.feature SK10). The quick check renders three stills of a composition (a
|
||||
//! quarter in, the middle, the last frame, of the length frame 0's render reports) with their manifest, and runs the text rules
|
||||
//! and the person's text taste on it: clipped and cramped text, safe areas, sizes. Every agent's after-save hook runs
|
||||
//! it (hook.rs): after a .tsx that registers a root is saved, its findings go back to the agent; a clean check says
|
||||
//! nothing.
|
||||
use super::*;
|
||||
use std::path::Path;
|
||||
|
||||
/// The stills' frames: a quarter in, the middle and the last of the length a render reports (render.json's `length`,
|
||||
/// the composition's own however it's written; #86 read its source's `durationInFrames={N}` and took 90 for a name).
|
||||
fn samples(m: &Value) -> Option<[u64; 3]> {
|
||||
let n = m["length"].as_u64()?.max(1);
|
||||
Some([n / 4, n / 2, n - 1])
|
||||
}
|
||||
|
||||
/// `raea check EDIT.tsx --quick [--shape S] [--platform P] [-o check.json]`: (report, P0 or P1 found). `tastes` are the
|
||||
/// person's, evaluated by the raea CLI when --taste names them.
|
||||
pub fn quick(args: &[String], tastes: Vec<raea_core_brief::Taste>) -> R<(String, bool)> {
|
||||
let file = args.iter().find(|a| a.ends_with(".tsx")).ok_or("raea check --quick takes a composition: EDIT.tsx")?;
|
||||
let tmp = std::env::temp_dir().join(format!("raea-quick-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&tmp).map_err(|e| format!("{}: {e}", tmp.display()))?;
|
||||
let manifest = tmp.join("render.json");
|
||||
let me = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
// the stills are part of this check, which keeps the one entry in the project's record (DR3)
|
||||
let render = |at: &str| std::process::Command::new(&me).arg("render").arg(file).args(["--at", at, "-o"]).arg(format!("{}/", tmp.display())).arg("--manifest").arg(&manifest).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string());
|
||||
// frame 0 first, for the length (its manifest's), then the three stills
|
||||
let mut out = render("0")?;
|
||||
let at = std::fs::read_to_string(&manifest).ok().and_then(|t| samples(&serde_json::from_str(&t).ok()?));
|
||||
if let Some(at) = at {
|
||||
let _ = std::fs::remove_file(&manifest);
|
||||
out = render(&at.map(|f| f.to_string()).join(","))?;
|
||||
}
|
||||
// rendered when its manifest was written: a render whose stills clip exits 1 (DR3), and those findings are read here
|
||||
let result = if let (Some(at), true) = (at, manifest.is_file()) {
|
||||
on_manifest(file, &manifest, args, tastes, at)
|
||||
} else {
|
||||
// a render that fails is the finding: the agent sees why
|
||||
let (err, out) = (String::from_utf8_lossy(&out.stderr), String::from_utf8_lossy(&out.stdout));
|
||||
let why: Vec<&str> = err.lines().chain(out.lines()).filter(|l| l.contains("REFUSED") || l.contains("rror")).collect();
|
||||
let f = raea_core_facts::Finding::new("render", raea_core_facts::Level::Error, why.join("\n"), "raea check --quick");
|
||||
Ok((format!("raea check {file}: it doesn't render\n{}\nraea check: {}", f.line(), raea_core_facts::finding::count(&[f])), true))
|
||||
};
|
||||
let _ = std::fs::remove_dir_all(&tmp);
|
||||
result
|
||||
}
|
||||
|
||||
/// `raea check --quick`'s half (docs/skills.feature SK10): the text rules and the person's text taste on the manifest
|
||||
/// of a few stills (`raea render EDIT.tsx --at ... --manifest`), no video. What it can't see (contrast, freezes,
|
||||
/// sound, blotching) waits for the full check on the export.
|
||||
fn on_manifest(file: &str, manifest: &Path, args: &[String], tastes: Vec<raea_core_brief::Taste>, [a, b, c]: [u64; 3]) -> R<(String, bool)> {
|
||||
let at = manifest.display();
|
||||
let m: Value = serde_json::from_str(&std::fs::read_to_string(manifest).map_err(|e| format!("{at}: {e}"))?).map_err(|e| format!("{at}: {e}"))?;
|
||||
let (mut issues, mut passed) = (Vec::new(), vec![format!("looked at frames {a}, {b} and {c} of {}", c + 1)]);
|
||||
let runs = text_runs(&m);
|
||||
let (w, h) = (m["width"].as_f64().unwrap_or(1080.0), m["height"].as_f64().unwrap_or(1920.0));
|
||||
text_rules(&runs, None, w, h, flag(args, "--shape"), flag(args, "--platform"), &mut issues, &mut passed);
|
||||
taste_text(&taste_rules(&tastes), &runs, w, h, &mut issues, &mut passed);
|
||||
// and what the render of the stills found (the 3D's clipping, DR3)
|
||||
let more = serde_json::from_value(m["findings"].clone()).unwrap_or_default();
|
||||
report(file, issues, more, passed, flag(args, "-o"), m["fps"].as_f64().unwrap_or(30.0))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
/// the length is the render's, so a `durationInFrames={DUR}` (#86: 300 frames, read as 90) is sampled to its end
|
||||
#[test]
|
||||
fn frames_come_from_the_render() {
|
||||
assert_eq!(super::samples(&json!({"length": 240})), Some([60, 120, 239]));
|
||||
assert_eq!(super::samples(&json!({"length": 300})), Some([75, 150, 299]));
|
||||
assert_eq!(super::samples(&json!({"length": 1})), Some([0, 0, 0]));
|
||||
// a render that reported no length: no stills to look at, so the frame-0 render's failure is the finding
|
||||
assert_eq!(super::samples(&json!({"width": 640})), None);
|
||||
}
|
||||
}
|
||||
+12
-26
@@ -22,7 +22,7 @@ fn a_placeholder_brand_kit_is_flagged() {
|
||||
brand_kit(&["", video.to_str().unwrap()], &mut issues, &mut passed);
|
||||
(issues.iter().map(|i| i.p).collect::<Vec<_>>(), passed.len())
|
||||
};
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["no font-family in its CSS"]}}"#)), (vec![2], 0));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["no font-family in its CSS"]}}"#)), (vec![1], 0));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["x"],"by_hand":{"palette.accent":"hero button"}}}"#)), (vec![], 1));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":[]}}"#)), (vec![], 1));
|
||||
assert_eq!(rules(None), (vec![2], 0));
|
||||
@@ -51,10 +51,6 @@ fn flat_dark_is_clean_and_stepped_dark_is_blotchy() {
|
||||
(20.0 - (x * x + y * y).sqrt() / 24.0).max(6.0) as u8
|
||||
}).collect();
|
||||
assert!(blotch_score(&rings, w, h).unwrap() < BLOTCHY / 2.0);
|
||||
// a cause that can't be told: an error only past an encoder's measured blotching, on more than a fifth of samples
|
||||
assert_eq!(untold_level(1.0, 0.010), 2);
|
||||
assert_eq!(untold_level(1.0, 0.09), 1);
|
||||
assert_eq!(untold_level(0.1, 0.09), 2);
|
||||
assert_eq!(x264_crf(b"..\x05x264 - core 165 r3222 - H.264/MPEG-4 AVC codec - options: cabac=1 rc=crf mbtree=1 crf=12.0 qcomp=0.60"), Some(12.0));
|
||||
assert_eq!(x264_crf(b"Lavf61 VideoToolbox"), None);
|
||||
}
|
||||
@@ -71,8 +67,8 @@ fn taste_checks_hold_text_to_the_persons_line() {
|
||||
Taste { form: "text-above", value: 62.0, line: "Captions sit clear of the bottom.".into() },
|
||||
Taste { form: "text-hold", value: 2.0, line: "Text holds two seconds".into() },
|
||||
]);
|
||||
let low = Run { text: "Render anything.".into(), from: 1.0, to: 4.0, box_: [800.0, 800.0, 300.0, 60.0], boxes: vec![[800.0, 800.0, 300.0, 60.0]], colors: vec![], inks: vec![], color: String::new(), size: 48.0 };
|
||||
let high = Run { text: "raea".into(), from: 5.0, to: 6.0, box_: [800.0, 300.0, 300.0, 60.0], boxes: vec![[800.0, 300.0, 300.0, 60.0]], colors: vec![], inks: vec![], color: String::new(), size: 48.0 };
|
||||
let low = Run { text: "Render anything.".into(), from: 1.0, to: 4.0, box_: [800.0, 800.0, 300.0, 60.0], boxes: vec![[800.0, 800.0, 300.0, 60.0]], color: String::new(), size: 48.0 };
|
||||
let high = Run { text: "raea".into(), from: 5.0, to: 6.0, box_: [800.0, 300.0, 300.0, 60.0], boxes: vec![[800.0, 300.0, 300.0, 60.0]], color: String::new(), size: 48.0 };
|
||||
let (mut issues, mut passed) = (vec![], vec![]);
|
||||
taste_text(&rules, &[low, high], 1920.0, 1080.0, &mut issues, &mut passed);
|
||||
let says: Vec<_> = issues.iter().map(|i| (i.rule, i.p, i.at)).collect();
|
||||
@@ -189,14 +185,15 @@ fn a_bed_close_under_the_voice_and_a_loud_stretch_without_it_are_found() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_states_the_zones_check_measures() {
|
||||
// zones() is where the numbers live; placement.md says them in words, held to it here
|
||||
fn the_floor_and_placement_state_the_zones_check_measures() {
|
||||
// zones() is where the numbers live; floor.md and placement.md say them in words, held to it here
|
||||
let words = |t: &str| t.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
let floor = words(include_str!("../../../sdk/guides/craft/floor.md"));
|
||||
let placement = words(include_str!("../../../sdk/guides/craft/motion/placement.md"));
|
||||
let n = |v: f64| format!("{v:.0}");
|
||||
let [t, r, b, l] = zones(1080.0, 1920.0, Some("9:16"), None);
|
||||
let said = [
|
||||
format!("that is top {}, bottom {}, right {} and left {} px at 1080 wide", n(t), n(b), n(r), n(l)),
|
||||
format!("keep the top {} px, the bottom {}, the right {} and the left {} clear", n(t), n(b), n(r), n(l)),
|
||||
["tiktok", "reels", "shorts"].map(|p| {
|
||||
let [t, r, b, _] = zones(1080.0, 1920.0, Some("9:16"), Some(p));
|
||||
let name = match p { "tiktok" => "TikTok", "reels" => "Reels", _ => "Shorts" };
|
||||
@@ -207,8 +204,10 @@ fn placement_states_the_zones_check_measures() {
|
||||
{ let [t, r, b, l] = zones(1920.0, 1080.0, Some("16:9"), None); assert!(t == b && r == l); format!("16:9 top and bottom {}, sides {}", n(t), n(r)) },
|
||||
];
|
||||
for s in &said {
|
||||
assert!(placement.contains(s.as_str()), "placement.md doesn't say {s:?}");
|
||||
assert!(floor.contains(s.as_str()), "floor.md doesn't say {s:?}");
|
||||
}
|
||||
let s = format!("that is top {}, bottom {}, right {} and left {} px at 1080 wide", n(t), n(b), n(r), n(l));
|
||||
assert!(placement.contains(&s), "placement.md doesn't say {s:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -268,7 +267,7 @@ fn typing_is_one_run_and_cues_find_their_word() {
|
||||
|
||||
#[test]
|
||||
fn a_caption_is_timed_from_the_first_word_it_shows() {
|
||||
let run = |text: &str, from: f64| Run { text: text.into(), from, to: from + 1.0, box_: [0.0; 4], boxes: vec![], colors: vec![], inks: vec![], color: String::new(), size: 48.0 };
|
||||
let run = |text: &str, from: f64| Run { text: text.into(), from, to: from + 1.0, box_: [0.0; 4], boxes: vec![], color: String::new(), size: 48.0 };
|
||||
let words: Vec<Word> = [("half", 12.2), ("of", 12.66), ("the", 12.8), ("spend", 12.96)].iter().map(|(t, s)| Word { text: (*t).into(), start: *s, end: *s }).collect();
|
||||
let (mut issues, mut passed) = (vec![], vec![]);
|
||||
// on with "of": on time, though "spend" (its first word of weight) is said 0.3 s later
|
||||
@@ -336,7 +335,7 @@ fn safe_area_tests_the_letters_not_the_box() {
|
||||
|
||||
#[test]
|
||||
fn a_card_sharing_one_word_with_another_line_isnt_held_to_it() {
|
||||
let run = |text: &str, from: f64| Run { text: text.into(), from, to: from + 2.0, box_: [0.0; 4], boxes: vec![], colors: vec![], inks: vec![], color: String::new(), size: 48.0 };
|
||||
let run = |text: &str, from: f64| Run { text: text.into(), from, to: from + 2.0, box_: [0.0; 4], boxes: vec![], color: String::new(), size: 48.0 };
|
||||
let said = |ws: &[(&str, f64)]| ws.iter().map(|(t, s)| Word { text: (*t).into(), start: *s, end: *s }).collect::<Vec<Word>>();
|
||||
let words = said(&[("at", 37.9), ("wirestock", 38.2), ("i", 38.9), ("worked", 39.0), ("on", 39.2), ("a", 39.3), ("sora", 39.5), ("campaign", 40.2)]);
|
||||
let (mut issues, mut passed) = (vec![], vec![]);
|
||||
@@ -421,16 +420,3 @@ fn things_found_are_findings_and_an_unknown_rule_is_not() {
|
||||
let _ = std::fs::remove_file(&p);
|
||||
assert_eq!(passed.len(), 1, "nothing found is a pass");
|
||||
}
|
||||
|
||||
/// #236: a text that moves is read where it is on its middle frame, not where it ends.
|
||||
#[test]
|
||||
fn a_moving_text_is_read_where_it_is() {
|
||||
let ink = |f: usize| [56.7 + 4.0 * f as f64, 1000.0, 26.7, 40.0];
|
||||
let run = Run { text: "E".into(), from: 0.0, to: 8.0, box_: [996.0, 1000.0, 60.0, 40.0], boxes: (0..240).map(ink).collect(), colors: vec![], inks: vec![], color: String::new(), size: 40.0 };
|
||||
let (t, b) = run.middle(30.0);
|
||||
assert_eq!(t, 4.0);
|
||||
assert!((b[0] - 520.0).abs() < 1e-9 && b[1..] == [1000.0, 60.0, 40.0], "{b:?}");
|
||||
let still = Run { boxes: vec![ink(0); 240], box_: [40.0, 1000.0, 60.0, 40.0], ..run };
|
||||
assert_eq!(still.middle(30.0), (4.0, [40.0, 1000.0, 60.0, 40.0]));
|
||||
}
|
||||
|
||||
+7
-107
@@ -43,57 +43,13 @@ pub struct Run {
|
||||
/// a full-width box is nowhere near x = 0, #89): a text the camera carries (a sign on a panning street) moves
|
||||
/// through the frame's edges and zones, which only counts against it when no frame shows it clear
|
||||
pub boxes: Vec<[f64; 4]>,
|
||||
/// its colour on each of those frames, beside `boxes`: a text can change colour while it reads the same (a step
|
||||
/// chip lighting up, grey on dark to dark on yellow), and its contrast is its colour on the frame it's measured at
|
||||
pub colors: Vec<String>,
|
||||
/// the colours its words are drawn in on each of those frames, beside `colors`, when any differs from the line's (the
|
||||
/// manifest's `inks`: a caption's accent word); empty when every word is in the line's colour
|
||||
pub inks: Vec<Vec<String>>,
|
||||
/// its colour on its last frame
|
||||
pub color: String,
|
||||
pub size: f64,
|
||||
}
|
||||
|
||||
impl Run {
|
||||
/// The frame midway through those that show its whole text, and its box on that frame: `box_` (the last frame's)
|
||||
/// moved back by how far its letters travel from there to where they end. A text that moves was read at its last
|
||||
/// place on its middle frame (#236).
|
||||
pub fn middle(&self, fps: f64) -> (f64, [f64; 4]) {
|
||||
let n = self.boxes.len();
|
||||
let (Some(last), true) = (self.boxes.last(), fps > 0.0 && n > 1) else { return ((self.from + self.to) / 2.0, self.box_) };
|
||||
let (at, [x, y, w, h]) = (self.boxes[n / 2], self.box_);
|
||||
(self.to - (n - n / 2) as f64 / fps, [x + at[0] - last[0], y + at[1] - last[1], w, h])
|
||||
}
|
||||
|
||||
/// Its colour on the frame `middle` measures: the one it had there, not the one it ended with.
|
||||
pub fn middle_color(&self) -> &str {
|
||||
let n = self.boxes.len();
|
||||
match self.colors.get(n / 2) {
|
||||
Some(c) if n > 1 && self.colors.len() == n => c,
|
||||
_ => &self.color,
|
||||
}
|
||||
}
|
||||
|
||||
/// Every colour its words are drawn in on that frame: the line's, and an accent span's beside it (12-06: a line
|
||||
/// recorded only by its own colour hid a dark word on a dark plate)
|
||||
pub fn middle_inks(&self) -> Vec<&str> {
|
||||
let n = self.boxes.len();
|
||||
let mut all = vec![self.middle_color()];
|
||||
let at = if n > 1 && self.inks.len() == n { self.inks.get(n / 2) } else { self.inks.last() };
|
||||
for i in at.into_iter().flatten() {
|
||||
if !all.contains(&i.as_str()) {
|
||||
all.push(i);
|
||||
}
|
||||
}
|
||||
all
|
||||
}
|
||||
}
|
||||
|
||||
/// The brand kit the cut was styled from (brand/ at or above the manifest's or the video's folder, as render finds
|
||||
/// brand.css): a kit `raea brand` read from a thin fetch that nobody corrected by hand is a placeholder, and a brand.css
|
||||
/// with no brand.json beside it wasn't read from the brand at all, both P2: where a kit came from is a note for the person
|
||||
/// at sign-off, not a fault in the cut (12-05, run 39: all four of Body Shop's cuts held an error for a fetch of the
|
||||
/// brand's site that read 40 of its 95 colour and face variables)
|
||||
/// brand.css): a kit `raea brand` read from a thin fetch that nobody corrected by hand is a placeholder, P1; a brand.css
|
||||
/// with no brand.json beside it wasn't read from the brand at all, P2
|
||||
pub fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for start in near.iter().filter(|p| !p.is_empty()) {
|
||||
@@ -114,7 +70,7 @@ pub fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String
|
||||
let thin: Vec<&str> = kit["source"]["thin"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
|
||||
let by_hand = kit["source"]["by_hand"].as_object().is_some_and(|o| !o.is_empty());
|
||||
if !thin.is_empty() && !by_hand {
|
||||
issues.push(Issue { rule: "brand", p: 2, at: None, says: format!("styled from a placeholder kit: raea brand's fetch of {} was thin ({}) and nothing in brand.json's source.by_hand says it was checked; read the live site in a browser and fix the kit (raea guide brand, \"When the fetch was thin\")", kit["domain"].as_str().unwrap_or("the site"), thin.join("; ")) });
|
||||
issues.push(Issue { rule: "brand", p: 1, at: None, says: format!("styled from a placeholder kit: raea brand's fetch of {} was thin ({}) and nothing in brand.json's source.by_hand says it was checked; read the live site in a browser and fix the kit (raea guide brand, \"When the fetch was thin\")", kit["domain"].as_str().unwrap_or("the site"), thin.join("; ")) });
|
||||
} else {
|
||||
passed.push(format!("brand: the cut is styled from {}'s kit{}", kit["domain"].as_str().unwrap_or("the brand"), if by_hand { ", checked by hand" } else { "" }));
|
||||
}
|
||||
@@ -146,24 +102,18 @@ pub fn text_runs(manifest: &Value) -> Vec<Run> {
|
||||
});
|
||||
let mut r = match found {
|
||||
Some(i) => open.remove(i),
|
||||
None => Run { text: text.clone(), from: t, to: t, box_: b, boxes: Vec::new(), colors: Vec::new(), inks: Vec::new(), color: String::new(), size: 0.0 },
|
||||
None => Run { text: text.clone(), from: t, to: t, box_: b, boxes: Vec::new(), color: String::new(), size: 0.0 },
|
||||
};
|
||||
let color = x["color"].as_str().unwrap_or("rgb(255, 255, 255)").to_string();
|
||||
let inks: Vec<String> = x["inks"].as_array().map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect()).unwrap_or_default();
|
||||
if text.len() > r.text.len() {
|
||||
r.boxes.clear();
|
||||
r.colors.clear();
|
||||
r.inks.clear();
|
||||
}
|
||||
if text.len() >= r.text.len() {
|
||||
r.text = text;
|
||||
r.box_ = b;
|
||||
r.boxes.push(ink.unwrap_or(b));
|
||||
r.colors.push(color.clone());
|
||||
r.inks.push(inks);
|
||||
}
|
||||
r.to = t + 1.0 / fps;
|
||||
r.color = color;
|
||||
r.color = x["color"].as_str().unwrap_or("rgb(255, 255, 255)").to_string();
|
||||
r.size = x["size"].as_f64().unwrap_or(0.0);
|
||||
next.push(r);
|
||||
}
|
||||
@@ -214,11 +164,7 @@ pub fn face_cover(runs: &[Run], faces: &[(f64, f64, [f64; 4])], issues: &mut Vec
|
||||
}
|
||||
}
|
||||
|
||||
/// The app's right-hand buttons start this far down the frame (sdk/video/src/zones.ts RAIL): the right zone is under it.
|
||||
/// 12-05: a centred end card at 35% down was an error for the right zone, where no app draws anything.
|
||||
pub const RAIL: f64 = 0.45;
|
||||
|
||||
/// the zones where text can't go, as [top, right, bottom, left] at 1080 wide (sdk/guides/craft/motion/placement.md)
|
||||
/// the zones where text can't go, as [top, right, bottom, left] at 1080 wide (sdk/guides/craft/floor.md)
|
||||
pub fn zones(w: f64, h: f64, shape: Option<&str>, platform: Option<&str>) -> [f64; 4] {
|
||||
let r = w / h;
|
||||
let shape = shape.unwrap_or(if r < 0.7 { "9:16" } else if r < 0.9 { "4:5" } else if r < 1.2 { "1:1" } else { "16:9" });
|
||||
@@ -250,8 +196,7 @@ pub fn text_rules(runs: &[Run], heard: Option<&[Word]>, w: f64, h: f64, shape: O
|
||||
let [x, y, bw, bh] = r.box_;
|
||||
let q = quote(&r.text);
|
||||
let off = |&[x, y, bw, bh]: &[f64; 4]| x < -1.0 || y < -1.0 || x + bw > w + 1.0 || y + bh > h + 1.0;
|
||||
// the right zone is the app's buttons, which start RAIL down the frame: above them the right edge is clear
|
||||
let zoned = |&[x, y, bw, bh]: &[f64; 4]| y < zt || (x + bw > w - zr && y + bh > RAIL * h) || y + bh > h - zb || x < zl;
|
||||
let zoned = |&[x, y, bw, bh]: &[f64; 4]| y < zt || x + bw > w - zr || y + bh > h - zb || x < zl;
|
||||
if r.boxes.iter().all(off) {
|
||||
clipped += 1;
|
||||
issues.push(Issue { rule: "clipped", p: 0, at: Some(r.from), says: format!("{q} runs off the frame (box {x:.0},{y:.0} {bw:.0}x{bh:.0} in {w:.0}x{h:.0}); fit it or break the line") });
|
||||
@@ -337,48 +282,3 @@ pub fn cues(runs: &[Run], words: &[Word], issues: &mut Vec<Issue>, passed: &mut
|
||||
passed.push(format!("cues: {checked} texts land on their words"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
/// The right zone is the app's buttons, from RAIL down: a centred end card above them is clear (12-05, an end card 35%
|
||||
/// down was an error); the same card over the buttons isn't.
|
||||
#[test]
|
||||
fn the_right_zone_starts_where_the_apps_buttons_do() {
|
||||
let right = |y: f64| {
|
||||
let m = serde_json::json!({"fps": 1.0, "frames": [{"frame": 0, "text": [{"text": "THE BODY SHOP", "box": [134.0, y, 812.0, 112.0]}]}]});
|
||||
let (mut issues, mut passed) = (vec![], vec![]);
|
||||
text_rules(&text_runs(&m), None, 1080.0, 1920.0, None, None, &mut issues, &mut passed);
|
||||
issues.into_iter().filter(|i| i.rule == "safe-area").map(|i| i.says).collect::<String>()
|
||||
};
|
||||
assert_eq!(right(682.0), "");
|
||||
assert!(right(1290.0).contains("at the right (keep 140 px clear)"), "{}", right(1290.0));
|
||||
}
|
||||
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn a_text_that_lights_up_is_measured_in_its_colour_at_the_middle() {
|
||||
// a step chip: grey on dark for six frames, then dark on yellow for four (the same words)
|
||||
let m = json!({"fps": 10.0, "frames": (0..10).map(|f| json!({"frame": f, "text": [
|
||||
{"text": "03 MAP", "box": [500, 120, 130, 52], "size": 23, "color": if f < 6 { "rgb(169, 169, 174)" } else { "rgb(10, 10, 11)" }}
|
||||
]})).collect::<Vec<_>>()});
|
||||
let runs = text_runs(&m);
|
||||
assert_eq!(runs.len(), 1);
|
||||
assert_eq!(runs[0].color, "rgb(10, 10, 11)", "its last colour");
|
||||
assert_eq!(runs[0].middle_color(), "rgb(169, 169, 174)", "the frame contrast measures is still grey");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_line_with_an_accent_word_is_measured_in_both_colours() {
|
||||
// a white caption with one word in dark red: the manifest's line colour alone hid the red word
|
||||
let m = json!({"fps": 10.0, "frames": (0..4).map(|f| json!({"frame": f, "text": [
|
||||
{"text": "Stay out longer.", "box": [100, 1400, 880, 90], "size": 84, "color": "rgb(255, 255, 255)", "inks": ["rgb(255, 255, 255)", "rgb(120, 0, 0)"]}
|
||||
]})).collect::<Vec<_>>()});
|
||||
let runs = text_runs(&m);
|
||||
assert_eq!(runs[0].middle_inks(), vec!["rgb(255, 255, 255)", "rgb(120, 0, 0)"]);
|
||||
// a line drawn in its own colour only has no inks, and is measured in that colour alone
|
||||
let plain = json!({"fps": 10.0, "frames": [{"frame": 0, "text": [{"text": "raea", "box": [0, 0, 10, 10], "size": 40, "color": "rgb(1, 2, 3)"}]}]});
|
||||
assert_eq!(text_runs(&plain)[0].middle_inks(), vec!["rgb(1, 2, 3)"]);
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,8 @@ raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# a render's record named by when it was (UTC)
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
# frame purity (SG9): the video's frames decoded, the stills read
|
||||
raea-io-media = { path = "../../io/media", default-features = false, features = ["apple", "soft"] }
|
||||
image = { version = "0.25", default-features = false, features = ["png"] }
|
||||
serde_json = "1"
|
||||
# `raea check PROJECT | EDIT.tsx` (DR4): the taste files' rules, the floor on a composition's newest render, the
|
||||
# `raea check PROJECT | EDIT.tsx` (DR4): taste and controllers' rules, the floor on a composition's newest render, the
|
||||
# project's compositions
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
raea-app-check = { path = "../check" }
|
||||
|
||||
+31
-115
@@ -1,13 +1,13 @@
|
||||
//! `raea check PROJECT|EDIT.tsx` (docs/direction.feature DR4): every check that applies, run over each
|
||||
//! composition's worlds. The rules come from raea's floor and the taste files: the person's, the workspace's and the
|
||||
//! project's; each is one of raea's named checks (systems.rs) or a project's TS check (ts.rs), and where it was
|
||||
//! written changes nothing about how it runs. A check that needs a render runs on the
|
||||
//! composition's worlds. The rules come from raea's floor, the person's taste (and the workspace's), and the
|
||||
//! workspace's and the project's controllers; each is one of raea's named checks (systems.rs) or a project's TS check
|
||||
//! (ts.rs), and where it was written changes nothing about how it runs. A check that needs a render runs on the
|
||||
//! composition's newest render; with none, it waits, and the command says what for. `raea check VIDEO.mp4` is the
|
||||
//! floor alone (apps/check).
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::taste;
|
||||
use raea_core_brief::{controller, taste};
|
||||
use raea_core_facts::{finding, record, Facts, Finding, Level, Rule, Shot};
|
||||
use raea_runtime_bundle::flag;
|
||||
use raea_runtime_world::{Ask, Render};
|
||||
@@ -18,10 +18,10 @@ use crate::ts;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea check [PROJECT|EDIT.tsx] [--composition ID] [--only ID] [--render OUT | --no-render] [--json] (every check that applies to each composition, over its frames: raea's floor on its newest render, the person's, the workspace's and the project's taste.ts (each line's check: one of raea's forms or checks by name, or a project's .ts check); what needs a render and has none waits, and says so)";
|
||||
pub const USAGE: &str = "raea check [PROJECT|EDIT.tsx] [--composition ID] [--only ID] [--taste T] [--render OUT | --no-render] [--json] (every check that applies to each composition, over its frames: raea's floor on its newest render, the person's taste, the workspace's and the project's rules (a controller's rule fields: one of raea's checks by name, or a project's .ts check); what needs a render and has none waits, and says so)";
|
||||
|
||||
/// The flags raea check takes with a value (its own, and the floor's on a video).
|
||||
const TAKES: [&str; 9] = ["--composition", "--only", "--render", "--manifest", "--words", "--perception", "--shape", "--platform", "-o"];
|
||||
const TAKES: [&str; 10] = ["--composition", "--only", "--taste", "--render", "--manifest", "--words", "--perception", "--shape", "--platform", "-o"];
|
||||
|
||||
/// What the CLI lends `raea check`: its TS evaluator and headless run, and the taste kinds a mode needs (as `raea
|
||||
/// context` reads the person's taste).
|
||||
@@ -71,12 +71,7 @@ fn tastes(project: &Path, given: Vec<PathBuf>, host: &Host) -> Vec<PathBuf> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// the workspace's, then the project's own (the same file when the project is the workspace's folder)
|
||||
for f in record::up(project, ".raea/workspace").map(|ws| ws.join("taste.ts")).into_iter().chain([project.join("taste.ts")]) {
|
||||
if f.is_file() && !out.contains(&f) {
|
||||
out.push(f);
|
||||
}
|
||||
}
|
||||
out.extend(record::up(project, ".raea/workspace").map(|ws| ws.join("taste.ts")).filter(|f| f.is_file()));
|
||||
out
|
||||
}
|
||||
|
||||
@@ -103,8 +98,8 @@ fn rules(project: &Path, given: Vec<PathBuf>, host: &Host) -> (Vec<Rule>, Vec<Fi
|
||||
(out, bad, notes)
|
||||
}
|
||||
|
||||
/// raea's floor and every taste file's rules (the person's, the workspace's, the project's), and a finding for each
|
||||
/// file of them raea couldn't read.
|
||||
/// raea's floor, the person's taste and the workspace's and project's controllers' rules, and a finding for each file
|
||||
/// of them raea couldn't read.
|
||||
fn held(project: &Path, given: Vec<PathBuf>, host: &Host) -> (Vec<Rule>, Vec<Finding>) {
|
||||
// raea's own: the floor, and the reading check (DR28: its findings keep their own levels, so no rule level)
|
||||
let read = Rule { level: None, ..Rule::named("text-read", "text can be read for as long as it needs, and OCR reads it", Default::default(), Level::Warn, "raea") };
|
||||
@@ -112,12 +107,26 @@ fn held(project: &Path, given: Vec<PathBuf>, host: &Host) -> (Vec<Rule>, Vec<Fin
|
||||
let mut bad = Vec::new();
|
||||
let name = |f: &Path| f.strip_prefix(project).unwrap_or(f).display().to_string();
|
||||
for f in tastes(project, given, host) {
|
||||
let (dir, by) = (f.parent().unwrap_or(Path::new(".")).to_path_buf(), format!("taste {}", name(&f)));
|
||||
match (host.ts.eval)(&f).and_then(|j| raea_core_brief::read::<taste::Taste>(&name(&f), &j)) {
|
||||
Ok(t) => out.extend(t.sections.iter().flat_map(|s| &s.rules).filter_map(|r| Rule::of_taste(r, &dir, &by))),
|
||||
Ok(t) => out.extend(t.sections.iter().flat_map(|s| &s.rules).filter_map(|r| Some(Rule::of_taste(&r.text, r.check?, &name(&f))))),
|
||||
Err(e) => bad.push(Finding::new("taste", Level::Error, format!("raea can't read it: {e}"), "raea check").about(name(&f), None)),
|
||||
}
|
||||
}
|
||||
let ws = record::up(project, ".raea/workspace");
|
||||
for (dir, scope) in ws.iter().map(|w| (raea_app_registry::shared_dir(w, "controllers"), "workspace")).chain([(project.join("controllers"), "project")]) {
|
||||
// a workspace's own folder is its project's too: read once
|
||||
if scope == "project" && ws.as_deref() == Some(project) {
|
||||
continue;
|
||||
}
|
||||
let mut files: Vec<PathBuf> = std::fs::read_dir(&dir).into_iter().flatten().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "ts")).collect();
|
||||
files.sort();
|
||||
for f in files {
|
||||
match (host.ts.eval)(&f).and_then(|j| controller::of_json(&j)) {
|
||||
Ok(c) => out.extend(Rule::of_controller(&c, &dir, &format!("{scope} {}", name(&f)))),
|
||||
Err(e) => bad.push(Finding::new("controller", Level::Error, format!("raea can't read it: {e}"), "raea check").about(name(&f), None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
(out, bad)
|
||||
}
|
||||
|
||||
@@ -125,7 +134,7 @@ fn held(project: &Path, given: Vec<PathBuf>, host: &Host) -> (Vec<Rule>, Vec<Fin
|
||||
fn compositions(target: &Path, args: &[String]) -> R<Vec<(PathBuf, Option<String>)>> {
|
||||
let one = flag(args, "--composition");
|
||||
let (dir, file) = if target.is_dir() { (target.to_path_buf(), None) } else { (target.parent().unwrap_or(Path::new(".")).to_path_buf(), Some(dunce::canonicalize(&target).map_err(|e| format!("{}: {e}", target.display()))?)) };
|
||||
let reg = raea_app_registry::scan(&dir);
|
||||
let reg = raea_app_registry::scan(&dir, &[]);
|
||||
let mut out: Vec<(PathBuf, Option<String>)> = Vec::new();
|
||||
for c in ®.compositions {
|
||||
let path = reg.dir.join(&c.file);
|
||||
@@ -240,16 +249,6 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
None => hows.iter().filter(|(_, h)| matches!(h, How::Named(n) if n.render && n.name != "text-read")).for_each(|(r, _)| needs(&mut waits, r)),
|
||||
}
|
||||
}
|
||||
// traced light held still (raea light steady): with the floor, a composition lit by Solari carries what its newest
|
||||
// hold of each frame found, kept in the project's record; with none yet, it waits for one
|
||||
if floor && traced(tsx) {
|
||||
let held = light_held(tsx, id.as_deref());
|
||||
if held.is_empty() {
|
||||
let c = id.as_ref().map(|i| format!(" --composition {i}")).unwrap_or_default();
|
||||
waits.push(("light-steady".into(), format!("a held frame of its traced light (raea light steady {}{c} --frame N -o DIR)", tsx.display())));
|
||||
}
|
||||
found.extend(held.into_iter().filter(|f| f.level != Level::Note));
|
||||
}
|
||||
// the project's own checks, in one run
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
let mut plan = Vec::new();
|
||||
@@ -259,7 +258,10 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
needs(&mut waits, r);
|
||||
continue;
|
||||
}
|
||||
let k = file_index(&mut files, &m.file);
|
||||
let k = files.iter().position(|f| *f == m.file).unwrap_or_else(|| {
|
||||
files.push(m.file.clone());
|
||||
files.len() - 1
|
||||
});
|
||||
let mut on = m.frames.pick(&worlds);
|
||||
if let (true, Some(j)) = (m.render, &join_on_of(&worlds)) {
|
||||
on.retain(|f| j.contains(f));
|
||||
@@ -279,55 +281,6 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
Ok(Checked { file: tsx.to_path_buf(), id, found: finding::ranked(found), waits, render, shots, fps })
|
||||
}
|
||||
|
||||
/// Whether a composition is lit by traced light: its file, or a .tsx beside it or a folder down, names SolariLighting.
|
||||
fn traced(tsx: &Path) -> bool {
|
||||
let mut files = vec![tsx.to_path_buf()];
|
||||
let tsxs = |d: &Path| -> Vec<PathBuf> { std::fs::read_dir(d).into_iter().flatten().flatten().map(|e| e.path()).collect() };
|
||||
if let Some(dir) = tsx.parent() {
|
||||
files.extend(tsxs(dir).into_iter().flat_map(|p| if p.is_dir() { tsxs(&p) } else { vec![p] }).filter(|p| p.extension().is_some_and(|x| x == "tsx")));
|
||||
}
|
||||
for f in files {
|
||||
if let Ok(text) = std::fs::read_to_string(&f) {
|
||||
if text.contains("SolariLighting") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// The findings of the newest hold of each frame of a composition (`raea light steady`), from its project's record.
|
||||
fn light_held(tsx: &Path, id: Option<&str>) -> Vec<Finding> {
|
||||
let Some(project) = dunce::canonicalize(tsx).ok().and_then(|t| record::up(t.parent()?, ".raea/project")) else { return Vec::new() };
|
||||
let of = record::rel(&project, tsx);
|
||||
let mut newest: std::collections::BTreeMap<i64, Vec<Finding>> = std::collections::BTreeMap::new();
|
||||
for e in record::read(&project) {
|
||||
if e.by != "raea light steady" || e.of != of {
|
||||
continue;
|
||||
}
|
||||
let mut mine = Vec::new();
|
||||
for f in e.findings {
|
||||
let mut about = f.about.iter().map(|a| a.name.as_str());
|
||||
if id.is_none_or(|id| about.any(|n| n == id)) {
|
||||
mine.push(f);
|
||||
}
|
||||
}
|
||||
if let Some(frame) = mine.first().and_then(|f| f.frames) {
|
||||
newest.insert(frame[0], mine);
|
||||
}
|
||||
}
|
||||
newest.into_values().flatten().collect()
|
||||
}
|
||||
|
||||
/// Where `f` is in `files`, added at the end when it isn't yet: the one run's checks, each file once.
|
||||
fn file_index(files: &mut Vec<PathBuf>, f: &Path) -> usize {
|
||||
if let Some(at) = files.iter().position(|x| x == f) {
|
||||
return at;
|
||||
}
|
||||
files.push(f.to_path_buf());
|
||||
files.len() - 1
|
||||
}
|
||||
|
||||
/// Whether `r` runs on the composition `tsx` (`id` where its file registers several) of `project`: a rule a note's ask
|
||||
/// scopes to one (`of`) runs there alone.
|
||||
fn applies(r: &Rule, project: &Path, tsx: &Path, id: Option<&str>) -> bool {
|
||||
@@ -381,9 +334,6 @@ pub fn check(args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
return Err(format!("--only {only}: no rule here has that id"));
|
||||
}
|
||||
}
|
||||
if target.is_file() && target.to_string_lossy().ends_with(".story.ts") {
|
||||
return check_story(&target, &rules, unread, args, host);
|
||||
}
|
||||
let mut all = Vec::new();
|
||||
for (tsx, id) in compositions(&target, args)? {
|
||||
let mine: Vec<Rule> = rules.iter().filter(|r| applies(r, &project, &tsx, id.as_deref())).cloned().collect();
|
||||
@@ -410,7 +360,7 @@ pub fn check(args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
// a note's ask's finding says which ask, as two asks can run one check
|
||||
out.extend(c.found.iter().map(|f| if f.by.starts_with("note ") { format!("{} [{}]", f.line(), f.by) } else { f.line() }));
|
||||
out.extend(c.waits.iter().map(|(r, w)| format!("waits {r}: needs {w}")));
|
||||
// kept in its project's record (DR3), what raea findings and raea goal next read
|
||||
// kept in its project's record (DR3), what raea findings and raea next read
|
||||
if let Some(e) = record::keep("raea check", &c.file, None, &c.found, vec![], &stamp) {
|
||||
out.push(format!("raea check: kept in the project's record as {} (raea findings reads it)", e.id));
|
||||
}
|
||||
@@ -422,40 +372,6 @@ pub fn check(args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
Ok((out.join("\n"), bad))
|
||||
}
|
||||
|
||||
/// `raea check NAME.story.ts` (docs/story.feature ST5a): a story checked before anything is drawn. Every rule whose .ts
|
||||
/// check reads stories (`over: "story"` or `"both"`) runs once with no frames, so only its `after` speaks; the check
|
||||
/// imports the story it holds (raea/story's storyCheck), and the file named says which project and that no composition
|
||||
/// is wanted.
|
||||
fn check_story(file: &Path, rules: &[Rule], unread: Vec<Finding>, args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
let (mut found, mut files, mut plan) = (Vec::new(), Vec::<PathBuf>::new(), Vec::new());
|
||||
for r in rules {
|
||||
let Some(f) = r.file() else { continue };
|
||||
match ts::meta(f, &host.ts) {
|
||||
Ok(m) if m.story => {
|
||||
let k = file_index(&mut files, &m.file);
|
||||
plan.push(ts::Planned { check: k, frames: Vec::new(), values: r.values.clone(), level: r.level, by: r.by.clone() });
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(e) => found.push(Finding::new(&r.id, Level::Error, e, &r.by)),
|
||||
}
|
||||
}
|
||||
if plan.is_empty() {
|
||||
found.push(Finding::new("story", Level::Note, "no check here reads a story: a .ts check over \"story\" or \"both\" (raea/story's storyCheck is one) named in taste.ts", "raea check"));
|
||||
}
|
||||
found.extend(ts::run(&files, &plan, &[], &host.ts)?);
|
||||
let found = finding::ranked(found);
|
||||
let bad = unread.iter().chain(&found).any(|f| f.level == Level::Error);
|
||||
if args.iter().any(|a| a == "--json") {
|
||||
return Ok((serde_json::to_string_pretty(&json!({"unread": unread, "story": file, "findings": found})).unwrap_or_default(), bad));
|
||||
}
|
||||
let mut out: Vec<String> = unread.iter().map(Finding::line).collect();
|
||||
out.push(format!("raea check {} (a story: no frames)", file.display()));
|
||||
out.extend(found.iter().map(Finding::line));
|
||||
let every: Vec<Finding> = unread.into_iter().chain(found).collect();
|
||||
out.push(format!("raea check: {}", finding::count(&every)));
|
||||
Ok((out.join("\n"), bad))
|
||||
}
|
||||
|
||||
/// `raea check ...`: its exit code (1 on an error found, 2 when it couldn't check).
|
||||
pub fn cli(args: &[String], host: &Host) -> i32 {
|
||||
raea_app_check::said(check(args, host), "raea check: ")
|
||||
|
||||
@@ -7,8 +7,6 @@ pub use world::{cli, find, Find, USAGE};
|
||||
// how `raea render` ends: its findings counted last, and 1 on an error not let through (DR3)
|
||||
mod rendered;
|
||||
pub use rendered::rendered;
|
||||
// frame purity at a render's end: a sample of its frames rendered again and held to the video's (SG9)
|
||||
mod pure;
|
||||
|
||||
// `raea findings`: the project's record read back, fixed, new and carried (DR3)
|
||||
pub mod findings;
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
//! SG9 (docs/stage-guards.feature): a frame looks the same however it is reached. When a video render with 3D in it ends,
|
||||
//! a sample of its frames is rendered again by one more raea (`render --at`: each frame reached by a jump, none by the
|
||||
//! frames before it) and held to the same frame of the video. A patch that differs beyond the encoder's noise means a
|
||||
//! part kept state from an earlier frame: a shape, words, a colour or another part's row held over (SG1–SG4's faults,
|
||||
//! and any later one of their kind). That frame is rendered alone (`--frame N`, in its own process) to be sure, and the
|
||||
//! error names the frame, the patch, the parts under it (the stills' manifest, raea-sys-stage's on_screen) and where
|
||||
//! the two pictures are kept. A frame that differs only when reached by a jump is the engine's fault, not the
|
||||
//! composition's: a warning. RAEA_FRAME_PURE=0 skips the check (the stills it renders set it).
|
||||
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use raea_core_facts::{Finding, Level};
|
||||
use serde_json::Value;
|
||||
|
||||
/// Sampled: every this many frames, the last frame, and the frame after each remount (more than 20 parts mounting or
|
||||
/// unmounting at once, as the render's manifest lists them), for a render of more than MIN_FRAMES
|
||||
const EVERY: u64 = 300;
|
||||
const MIN_FRAMES: u64 = 60;
|
||||
/// at most this many samples, spread evenly
|
||||
const MOST: usize = 64;
|
||||
/// A pixel differs when a channel differs by more than this (of 255) through a 3x3 erosion, which drops lone pixels (a
|
||||
/// glyph's edge noise, the encoder's, its colour bleeding along an edge) and keeps a patch: tools/frame-pure-3d.sh's
|
||||
/// bar, where a cut letter was 318. The largest channel, not luma: an orange part over a grey floor differs by 68 in
|
||||
/// luma and 116 in blue, and a part that kept another frame's colour is often as bright as its own
|
||||
const LEVELS: f32 = 96.0;
|
||||
/// A frame differs when more of its pixels than this share differ (207 at 1080p), and at least LEAST
|
||||
const SHARE: f64 = 1e-4;
|
||||
const LEAST: usize = 64;
|
||||
/// The flags of the render the stills repeat (each takes a value, then the bare ones): what it draws and at what size
|
||||
const KEEP: [&str; 12] = ["--composition", "--w", "--h", "--fps", "--frames", "--words", "--perception", "--input", "--stage", "--props", "--scale", "--hold"];
|
||||
const KEEP_BARE: [&str; 2] = ["--clay", "--lite"];
|
||||
const BY: &str = "raea render (frame-pure)";
|
||||
|
||||
/// The frames to sample of a render `length` frames long, given its remounts.
|
||||
pub(crate) fn samples(length: u64, remounts: &[u64]) -> Vec<u64> {
|
||||
if length <= MIN_FRAMES {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut s: Vec<u64> = (1..).map(|k| k * EVERY).take_while(|f| *f < length).collect();
|
||||
s.push(length - 1);
|
||||
s.extend(remounts.iter().map(|f| f + 1).filter(|f| *f < length));
|
||||
s.sort_unstable();
|
||||
s.dedup();
|
||||
// more than MOST: the last of each of MOST even runs, so the last frame stays
|
||||
let n = s.len();
|
||||
if n > MOST {
|
||||
s = s.into_iter().enumerate().filter(|(i, _)| (i + 1) * MOST / n > i * MOST / n).map(|(_, f)| f).collect();
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
/// Where two RGBA frames of one size differ: the count of pixels with a channel off by more than LEVELS through a 3x3
|
||||
/// erosion (every pixel round it differs too), and their box [x0, y0, x1, y1].
|
||||
pub(crate) fn patch(a: &[u8], b: &[u8], w: usize, h: usize) -> (usize, [usize; 4]) {
|
||||
let d: Vec<f32> = (0..w * h)
|
||||
.map(|i| {
|
||||
let c = |k: usize| (f32::from(a[i * 4 + k]) - f32::from(b[i * 4 + k])).abs();
|
||||
c(0).max(c(1)).max(c(2))
|
||||
})
|
||||
.collect();
|
||||
let (mut n, mut bx) = (0, [usize::MAX, usize::MAX, 0, 0]);
|
||||
for y in 1..h.saturating_sub(1) {
|
||||
for x in 1..w.saturating_sub(1) {
|
||||
if (y - 1..=y + 1).all(|yy| (x - 1..=x + 1).all(|xx| d[yy * w + xx] > LEVELS)) {
|
||||
n += 1;
|
||||
bx = [bx[0].min(x), bx[1].min(y), bx[2].max(x + 1), bx[3].max(y + 1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
(n, if n == 0 { [0; 4] } else { bx })
|
||||
}
|
||||
|
||||
fn differs(n: usize, w: usize, h: usize) -> bool {
|
||||
n > LEAST.max((SHARE * (w * h) as f64) as usize)
|
||||
}
|
||||
|
||||
/// The render's own flags the stills repeat.
|
||||
fn kept(args: &[String]) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
for (i, a) in args.iter().enumerate() {
|
||||
if KEEP.contains(&a.as_str()) {
|
||||
out.extend(args.get(i..i + 2).into_iter().flatten().cloned());
|
||||
} else if KEEP_BARE.contains(&a.as_str()) {
|
||||
out.push(a.clone());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// One more raea rendering `file` at `at` into `dir` (its stills, frame-00000.png on, in `at`'s order, and its
|
||||
/// manifest); its own errors are let through, since these are pictures to compare, not the render. Stills past 3,600
|
||||
/// frames make their 3D live at each (render_bundle's LIVE_PAST): 64 of a 13,175-frame film reached by rows went past
|
||||
/// 30 GB and were killed.
|
||||
fn stills(file: &str, args: &[String], at: &[u64], dir: &Path) -> Result<Value, String> {
|
||||
let me = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let list: Vec<String> = at.iter().map(u64::to_string).collect();
|
||||
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let manifest = dir.join("stills.json");
|
||||
let (flag, out) = if at.len() == 1 { ("--frame", dir.join("frame-00000.png").display().to_string()) } else { ("--at", format!("{}/", dir.display())) };
|
||||
let o = Command::new(me).arg("render").arg(file).args(kept(args)).args([flag, &list.join(","), "-o", &out, "--manifest"]).arg(&manifest).env("RAEA_RECORD", "off").env("RAEA_FRAME_PURE", "0").env("RAEA_DESPITE", "all: frame-pure's own stills")
|
||||
// nothing here reads the stills' clipping or staging, only their pictures and parts on screen: the checks cost
|
||||
// the film's 44 stills 1.6 GB, beside the render that's still held (SG4a: its 8.6 GB peak)
|
||||
.env("RAEA_CLIP_CHECK", "0").env("RAEA_STAGE_CHECK", "0").output().map_err(|e| e.to_string())?;
|
||||
let m = std::fs::read(&manifest).ok().and_then(|b| serde_json::from_slice::<Value>(&b).ok());
|
||||
m.ok_or_else(|| format!("the stills didn't render: {}", String::from_utf8_lossy(&o.stderr).lines().rev().find(|l| !l.trim().is_empty()).unwrap_or("no message")))
|
||||
}
|
||||
|
||||
fn png(p: &Path) -> Option<(Vec<u8>, usize, usize)> {
|
||||
let img = image::open(p).ok()?.into_rgba8();
|
||||
let (w, h) = img.dimensions();
|
||||
Some((img.into_raw(), w as usize, h as usize))
|
||||
}
|
||||
|
||||
/// The parts on screen at `frame` whose boxes meet `bx`, most overlap first (the manifest of the frame rendered alone:
|
||||
/// its `parts` hold that one frame).
|
||||
fn under(m: &Value, frame: u64, bx: [usize; 4]) -> Vec<String> {
|
||||
let at = &m["parts"][0];
|
||||
if at["frame"] != frame {
|
||||
return Vec::new();
|
||||
}
|
||||
let b = bx.map(|v| v as f64);
|
||||
let mut hit: Vec<(f64, String)> = at["parts"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|p| {
|
||||
let r: Vec<f64> = p[1].as_array()?.iter().filter_map(Value::as_f64).collect();
|
||||
let r: [f64; 4] = r.try_into().ok()?;
|
||||
let over = (b[2].min(r[2]) - b[0].max(r[0])).max(0.0) * (b[3].min(r[3]) - b[1].max(r[1])).max(0.0);
|
||||
(over > 0.0).then(|| (over, p[0].as_str().unwrap_or("a part").to_string()))
|
||||
})
|
||||
.collect();
|
||||
hit.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
hit.into_iter().map(|h| h.1).take(3).collect()
|
||||
}
|
||||
|
||||
/// SG9 on a finished render: its findings, none when it isn't a video with 3D in it of more than MIN_FRAMES.
|
||||
pub fn check(args: &[String], out: &Path, manifest: &Value) -> Vec<Finding> {
|
||||
let (Some(file), true) = (args.get(1), manifest["has3d"].as_bool() == Some(true)) else { return Vec::new() };
|
||||
if std::env::var("RAEA_FRAME_PURE").as_deref() == Ok("0") || args.iter().any(|a| a == "--frame" || a == "--at") {
|
||||
return Vec::new();
|
||||
}
|
||||
let remounts: Vec<u64> = manifest["remounts"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
|
||||
let at = samples(manifest["length"].as_u64().unwrap_or(0), &remounts);
|
||||
let fps = manifest["fps"].as_f64().unwrap_or(30.0);
|
||||
if at.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let dir = std::env::temp_dir().join(format!("raea-frame-pure-{}", std::process::id()));
|
||||
let found = run(file, args, out, &at, fps, &dir).unwrap_or_else(|e| vec![Finding::new("frame-pure", Level::Note, format!("frame purity wasn't checked: {e}"), BY)]);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
found
|
||||
}
|
||||
|
||||
fn run(file: &str, args: &[String], out: &Path, at: &[u64], fps: f64, dir: &Path) -> Result<Vec<Finding>, String> {
|
||||
std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;
|
||||
stills(file, args, at, &dir.join("at"))?;
|
||||
let mut video = raea_io_media::preferred().into_iter().find_map(|b| b.open_video(out).ok()).ok_or_else(|| format!("{}: no decoder opens it", out.display()))?;
|
||||
let keep = out.with_extension("frame-pure");
|
||||
let mut found = Vec::new();
|
||||
for (i, &f) in at.iter().enumerate() {
|
||||
let Some((jump, w, h)) = png(&dir.join(format!("at/frame-{i:05}.png"))) else { continue };
|
||||
let v = video.frame_at((f as f64 + 0.5) / fps)?;
|
||||
if (v.width as usize, v.height as usize) != (w, h) {
|
||||
return Err(format!("the video is {}x{}, its stills {w}x{h}", v.width, v.height));
|
||||
}
|
||||
if !differs(patch(&v.rgba, &jump, w, h).0, w, h) {
|
||||
continue;
|
||||
}
|
||||
// reached by a jump it differs: rendered alone, in its own process, to be sure
|
||||
let one = dir.join(format!("alone-{f}"));
|
||||
let alone_m = stills(file, args, &[f], &one)?;
|
||||
let Some((alone, _, _)) = png(&one.join("frame-00000.png")) else { continue };
|
||||
let (n, bx) = patch(&v.rgba, &alone, w, h);
|
||||
let parts = under(&alone_m, f, bx);
|
||||
let named = if parts.is_empty() { String::new() } else { format!(" over {}", parts.join(", ")) };
|
||||
let finding = if differs(n, w, h) {
|
||||
std::fs::create_dir_all(&keep).map_err(|e| e.to_string())?;
|
||||
let (seq, own) = (keep.join(format!("frame-{f:05}-render.png")), keep.join(format!("frame-{f:05}-alone.png")));
|
||||
image::save_buffer(&seq, &v.rgba, w as u32, h as u32, image::ColorType::Rgba8).map_err(|e| e.to_string())?;
|
||||
std::fs::copy(one.join("frame-00000.png"), &own).map_err(|e| e.to_string())?;
|
||||
let mut x = Finding::new("frame-pure", Level::Error, format!("{n} pixels{named} (x {}-{}, y {}-{}) differ from the frame rendered alone: a part kept an earlier frame's shape, words, colour or row. The two are {} and {}", bx[0], bx[2], bx[1], bx[3], seq.display(), own.display()), BY).frames(f as i64, f as i64 + 1).measure("pixels", n as f64, "px", Some(LEAST.max((SHARE * (w * h) as f64) as usize) as f64));
|
||||
for p in &parts {
|
||||
x = x.about(p.clone(), None);
|
||||
}
|
||||
x.fix("find what that part takes from the frames before (a key it keeps, a prop read once), or `raea bug` with both pictures when it's raea's")
|
||||
} else {
|
||||
Finding::new("frame-pure-jump", Level::Warn, format!("frame {f}{named} differs when the render jumps to it from frame {}, not alone or in sequence: raea's, not the composition's (`raea bug` with this line)", if i > 0 { at[i - 1].to_string() } else { "0".into() }), BY).frames(f as i64, f as i64 + 1)
|
||||
};
|
||||
found.push(finding);
|
||||
}
|
||||
Ok(found)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn samples_every_300th_the_last_and_after_each_remount() {
|
||||
assert!(samples(60, &[]).is_empty());
|
||||
assert_eq!(samples(180, &[]), vec![179]);
|
||||
assert_eq!(samples(1000, &[40, 599, 999]), vec![41, 300, 600, 900, 999]);
|
||||
let many = samples(1_000_000, &[]);
|
||||
assert_eq!((many.len(), many.last()), (MOST, Some(&999_999)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_patch_counts_but_lone_pixels_and_noise_dont() {
|
||||
let (w, h) = (64, 32);
|
||||
let a = vec![40u8; w * h * 4];
|
||||
let mut b = a.clone();
|
||||
// noise: every pixel off by 20, and lone pixels off by 200
|
||||
b.iter_mut().for_each(|v| *v += 20);
|
||||
for i in (0..w * h).step_by(7) {
|
||||
b[i * 4..i * 4 + 3].copy_from_slice(&[240, 240, 240]);
|
||||
}
|
||||
assert_eq!(patch(&a, &b, w, h).0, 0);
|
||||
// a 10x6 block of words turned white at x 20, y 8: its eroded inside, 8x4
|
||||
for y in 8..14 {
|
||||
for x in 20..30 {
|
||||
b[(y * w + x) * 4..(y * w + x) * 4 + 3].copy_from_slice(&[255, 255, 255]);
|
||||
}
|
||||
}
|
||||
let (n, bx) = patch(&a, &b, w, h);
|
||||
assert_eq!(n, 32);
|
||||
assert_eq!(bx, [21, 9, 29, 13]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_stills_repeat_what_the_render_draws_and_nothing_else() {
|
||||
let a: Vec<String> = ["render", "e.tsx", "-o", "out.mp4", "--composition", "k3", "--kbps", "8000", "--clay", "--despite", "type-small", "why", "--frames", "90"].iter().map(|s| s.to_string()).collect();
|
||||
assert_eq!(kept(&a), ["--composition", "k3", "--clay", "--frames", "90"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_parts_under_a_patch_most_overlap_first() {
|
||||
let m = serde_json::json!({"parts": [{"frame": 600, "parts": [["floor", [0.0, 500.0, 1920.0, 1080.0]], ["counter", [800.0, 300.0, 1000.0, 400.0]], ["sky", [0.0, 0.0, 1920.0, 200.0]]]}]});
|
||||
assert_eq!(under(&m, 600, [850, 350, 1000, 520]), ["counter", "floor"]);
|
||||
assert!(under(&m, 300, [850, 350, 1000, 520]).is_empty());
|
||||
}
|
||||
}
|
||||
@@ -47,9 +47,8 @@ pub fn rendered(args: &[String]) -> i32 {
|
||||
if let Some(m) = manifest {
|
||||
if let Some(mut v) = std::fs::read(&m).ok().and_then(|b| serde_json::from_slice::<Value>(&b).ok()) {
|
||||
// a video's text, held to the check's text rules as it finishes, a check's round sooner
|
||||
if let Some(o) = out.as_deref().filter(|o| matches!(o.extension().and_then(|x| x.to_str()), Some("mp4" | "mov"))) {
|
||||
// and a sample of its frames rendered again, each held to the video's (SG9, pure.rs)
|
||||
for f in text_found(&v).into_iter().chain(crate::pure::check(args, o, &v)) {
|
||||
if out.as_deref().and_then(|o| o.extension()).is_some_and(|x| x == "mp4" || x == "mov") {
|
||||
for f in text_found(&v) {
|
||||
println!("{}", f.line());
|
||||
found.push(f);
|
||||
}
|
||||
@@ -61,7 +60,7 @@ pub fn rendered(args: &[String]) -> i32 {
|
||||
let _ = std::fs::write(&m, v.to_string());
|
||||
}
|
||||
}
|
||||
// a render that is part of another (a review's tiles) leaves the entry to that one
|
||||
// a render that is part of another (a review's tiles, a quick check's stills) leaves the entry to that one
|
||||
let file = args.get(1).filter(|a| !a.starts_with('-') && std::env::var("RAEA_RECORD").as_deref() != Ok("off")).map(PathBuf::from);
|
||||
if let Some(e) = file.and_then(|f| record::keep("raea render", &f, out.as_deref(), &found, excused, &raea_io_trace::utc(SystemTime::now()).1)) {
|
||||
println!("raea render: kept in the project's record as {} (raea findings reads it)", e.id);
|
||||
|
||||
@@ -53,7 +53,7 @@ fn placement_and_margin_name_the_worst_frame_of_a_run() {
|
||||
|
||||
#[test]
|
||||
fn a_rule_with_no_value_says_so() {
|
||||
let r = Rule { level: Some(Level::Warn), ..Rule::named("text-hold", "", Map::new(), Level::Error, "taste taste.ts") };
|
||||
let r = Rule { level: Some(Level::Warn), ..Rule::named("text-hold", "", Map::new(), Level::Error, "project controllers/rules.ts") };
|
||||
let got = text(&r, &piece(3, |_| vec![]));
|
||||
assert_eq!((got.len(), got[0].level), (1, Level::Warn));
|
||||
assert!(got[0].says.contains("needs a value"));
|
||||
|
||||
@@ -27,8 +27,6 @@ pub struct Meta {
|
||||
pub render: bool,
|
||||
pub level: Level,
|
||||
pub frames: Frames,
|
||||
/// it runs on a story with no frames (`over: "story" | "both"`): what `raea check NAME.story.ts` runs
|
||||
pub story: bool,
|
||||
}
|
||||
|
||||
/// The declaration of the check `file`'s default export is.
|
||||
@@ -48,12 +46,7 @@ pub fn meta(file: &Path, host: &Host) -> R<Meta> {
|
||||
Some(o) => return Err(format!("{name}: a check's level is error, warn or note, not \"{o}\"")),
|
||||
};
|
||||
let frames = Frames::of(&v["frames"]).map_err(|e| format!("{name}: {e}"))?;
|
||||
let story = match s("over").as_deref() {
|
||||
None | Some("frames") => false,
|
||||
Some("story" | "both") => true,
|
||||
Some(o) => return Err(format!("{name}: a check is over \"frames\", \"story\" or \"both\", not \"{o}\"")),
|
||||
};
|
||||
Ok(Meta { file: file.to_path_buf(), id, text: s("text").unwrap_or_default(), render, level, frames, story })
|
||||
Ok(Meta { file: file.to_path_buf(), id, text: s("text").unwrap_or_default(), render, level, frames })
|
||||
}
|
||||
|
||||
/// One planned run: the check (its index in `files`), its frames, and its rule's values, level (None: the check's
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
[package]
|
||||
name = "raea-app-double"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "The fingerprint's flags asked again of the decision model (docs/ask.feature AK8): each flagged moment in its axis's own words on its own window, the answers beside the flags and kept as another eye's evidence"
|
||||
|
||||
[dependencies]
|
||||
# the runner every ask goes through, and the question format
|
||||
raea-app-ask = { path = "../ask" }
|
||||
raea-core-ask = { path = "../../core/ask" }
|
||||
# the score's moments, the axes' words and the evidence rows clef's answers become
|
||||
raea-sys-fingerprint = { path = "../../systems/fingerprint" }
|
||||
raea-sys-fingerprint-use = { path = "../../systems/fingerprint-use" }
|
||||
raea-sys-columns = { path = "../../systems/columns" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
||||
[dev-dependencies]
|
||||
# a clip made with FFmpeg, and clef's answers as the tests give them
|
||||
raea-io-assets = { path = "../../io/assets" }
|
||||
raea-io-clef = { path = "../../io/clef" }
|
||||
serde_json = "1"
|
||||
@@ -1,167 +0,0 @@
|
||||
//! The fingerprint's flags asked again (docs/ask.feature AK8). `raea fingerprint score FILE --ask flags` (or `ask:
|
||||
//! "flags"` in fingerprint.ts) puts each flagged moment to the decision model in its axis's own words, on that moment's
|
||||
//! window alone, so it costs by the flags and never by the piece; `--ask unsure` also asks each window an axis puts in
|
||||
//! its plausible band without flagging it. Moments on the same window share a call. Each flag then says "clef agrees
|
||||
//! (0.71)" or "clef doesn't see it (0.08)", and each answer becomes an `eye:clef` evidence row, which trains the axis's
|
||||
//! head and never counts as the person's (FP6d). The question carries the axis's words as its label words, so the
|
||||
//! person's notes calibrate it as they do any question (AK6, AK7).
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use raea_app_ask::prepare::Piece;
|
||||
use raea_app_ask::runner::{self, Entry, Event};
|
||||
pub use raea_app_ask::runner::Opts;
|
||||
use raea_core_ask::{Question, Sees, Window};
|
||||
use raea_sys_columns::Columns;
|
||||
use raea_sys_columns::window::Modality;
|
||||
use raea_sys_fingerprint::evidence::{Row, features};
|
||||
use raea_sys_fingerprint::folder::Folder;
|
||||
use raea_sys_fingerprint::taxonomy::{Axis, Fingerprint};
|
||||
use raea_sys_fingerprint_use::score::{Scored, clock};
|
||||
use serde::Serialize;
|
||||
|
||||
/// One moment asked again.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct Double {
|
||||
pub a: f64,
|
||||
pub b: f64,
|
||||
pub axis: String,
|
||||
/// the axis in the person's words
|
||||
pub words: String,
|
||||
/// whether the fingerprint flagged it (else it was unsure of it)
|
||||
pub flagged: bool,
|
||||
/// clef's problem score, when it answered
|
||||
pub problem: Option<f64>,
|
||||
/// clef agrees: past even odds, or past the question's threshold once the person's labels calibrated it
|
||||
pub agrees: Option<bool>,
|
||||
/// its answer's id in the ask record (~/.raea/ask/answers.jsonl)
|
||||
pub answer: Option<String>,
|
||||
/// why it wasn't asked or still waits
|
||||
pub not_asked: Option<String>,
|
||||
}
|
||||
|
||||
impl Double {
|
||||
/// What clef made of it, as a flag's line says it.
|
||||
pub fn said(&self) -> String {
|
||||
match (self.agrees, self.problem, &self.not_asked) {
|
||||
(Some(true), Some(p), _) => format!("clef agrees ({p:.2})"),
|
||||
(Some(false), Some(p), _) => format!("clef doesn't see it ({p:.2})"),
|
||||
(_, _, Some(why)) => format!("clef wasn't asked: {why}"),
|
||||
_ => "clef gave no answer".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The moments asked again, a line each under the score's summary, as its flags are written (the app reads them).
|
||||
pub fn lines(ds: &[Double]) -> String {
|
||||
let each = ds.iter().map(|d| format!(" {}-{} {}: {}{}\n", clock(d.a), clock(d.b), d.axis, d.said(), if d.flagged { "" } else { " (the fingerprint was unsure)" }));
|
||||
format!("asked again of clef ({} moment{}):\n{}", ds.len(), if ds.len() == 1 { "" } else { "s" }, each.collect::<String>())
|
||||
}
|
||||
|
||||
/// The moments to ask: every flag, and with `unsure` each run of windows an axis puts in its plausible band unflagged.
|
||||
pub fn moments(s: &Scored, fp: &Fingerprint, which: &str) -> Vec<Double> {
|
||||
let words = |axis: &str| fp.axis(axis).and_then(|a| a.words.first().cloned()).unwrap_or_else(|| axis.to_string());
|
||||
let one = |a: f64, b: f64, axis: &str, flagged: bool| Double { a, b, axis: axis.into(), words: words(axis), flagged, problem: None, agrees: None, answer: None, not_asked: None };
|
||||
let mut out: Vec<Double> = s.moments.iter().map(|m| one(m.a, m.b, &m.axis, true)).collect();
|
||||
if which == "unsure" {
|
||||
for w in &s.windows {
|
||||
for x in w.axes.iter().filter(|x| !x.flagged && x.band == Some("plausible")) {
|
||||
match out.iter_mut().rev().find(|d| d.axis == x.axis && !d.flagged) {
|
||||
Some(d) if w.a <= d.b => d.b = w.b,
|
||||
_ => out.push(one(w.a, w.b, &x.axis, false)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// An axis as a question: is its defect there (or, for a quality, is it there), looking or listening as it does.
|
||||
pub fn question(axis: &Axis) -> Question {
|
||||
let words = axis.words.first().cloned().unwrap_or_else(|| axis.name.replace(['-', '_'], " "));
|
||||
let good = axis.polarity == "good";
|
||||
let ask = if good { format!("Is this {words}?") } else { format!("Is there {words} here?") };
|
||||
let mut q = Question::plain(&format!("fp.{}", axis.name), &ask);
|
||||
if good {
|
||||
q.flags = vec!["no".into()];
|
||||
}
|
||||
let listens = matches!(axis.modality, Modality::Sound | Modality::Events);
|
||||
q.sees = if listens { Sees::Nothing } else { Sees::Video };
|
||||
q.hears = listens;
|
||||
q.label_words = axis.words.clone();
|
||||
q
|
||||
}
|
||||
|
||||
/// Each moment asked of `file`, a call a window, at most `o.jobs` at once; the moments with clef's answers. A moment
|
||||
/// that couldn't be asked (no route, the pool spent, the file unreadable) says why, and the score goes on without it.
|
||||
pub fn ask(file: &Path, fp: &Fingerprint, mut ds: Vec<Double>, o: &Opts) -> Vec<Double> {
|
||||
let piece = match Piece::read(file, None, None, None, None) {
|
||||
Ok(p) => Arc::new(p),
|
||||
Err(why) => {
|
||||
for d in &mut ds {
|
||||
d.not_asked = Some(format!("the file couldn't be read: {why}"));
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
};
|
||||
let entries = ds
|
||||
.iter()
|
||||
.filter_map(|d| {
|
||||
let q = question(fp.axis(&d.axis)?);
|
||||
Some(Entry { piece: piece.clone(), window: Some(Window { from: Some(d.a), to: Some(d.b) }), questions: vec![q], dropped: vec![], with: vec![] })
|
||||
})
|
||||
.collect();
|
||||
runner::run(entries, o, &mut |e| {
|
||||
let Event::Answer(r) = e else { return };
|
||||
let Some(d) = ds.iter_mut().find(|d| format!("fp.{}", d.axis) == r.id && d.a == r.from && r.to == Some(d.b)) else { return };
|
||||
d.problem = r.problem;
|
||||
d.agrees = r.says.as_ref().map(|_| r.flagged);
|
||||
d.answer = r.answer.clone();
|
||||
d.not_asked = r.not_asked.clone().or_else(|| r.waits.clone());
|
||||
});
|
||||
ds
|
||||
}
|
||||
|
||||
/// The answered moments kept in the fingerprint's ledger as clef's evidence, over the file's columns; a moment asked
|
||||
/// again replaces clef's last row for it. How many it kept.
|
||||
pub fn keep(dir: &Folder, c: &Columns, project: &str, ds: &[Double]) -> Result<usize, String> {
|
||||
let rows: Vec<Row> = ds.iter().filter_map(|d| row(d, &c.media, project)).collect();
|
||||
if rows.is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
let mut l = dir.ledger().map_err(|e| e.to_string())?;
|
||||
let mut n = 0;
|
||||
for r in rows {
|
||||
l.retain(|x| !(x.source == r.source && x.media == r.media && x.axis == r.axis && x.a == r.a && x.b == r.b));
|
||||
let f = features(c, r.a, r.b);
|
||||
l.push(r, &f);
|
||||
n += 1;
|
||||
}
|
||||
dir.write_ledger(&l).map_err(|e| e.to_string())?;
|
||||
Ok(n)
|
||||
}
|
||||
|
||||
/// An answered moment as another eye's evidence row.
|
||||
pub fn row(d: &Double, media: &str, project: &str) -> Option<Row> {
|
||||
Some(Row {
|
||||
media: media.into(),
|
||||
a: d.a,
|
||||
b: d.b,
|
||||
axis: d.axis.clone(),
|
||||
bad: d.agrees?,
|
||||
weight: 1.0,
|
||||
who: "clef".into(),
|
||||
source: "eye:clef".into(),
|
||||
project: project.into(),
|
||||
kind: None,
|
||||
region: None,
|
||||
words: None,
|
||||
at: 0,
|
||||
pin: None,
|
||||
band: None,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -1,88 +0,0 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use raea_app_ask::runner::Opts;
|
||||
use raea_core_ask::Sees;
|
||||
use raea_io_clef::{Answered, Call, Fail};
|
||||
use raea_sys_fingerprint::taxonomy::base;
|
||||
use raea_sys_fingerprint_use::score::{AxisScore, Moment, Scored, Window};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{ask, lines, moments, question, row};
|
||||
|
||||
fn moment(a: f64, b: f64, axis: &str) -> Moment {
|
||||
Moment { a, b, axis: axis.into(), words: String::new(), by: "head", state: "gating".into(), band: Some("strong"), gating: true, peak: 1.0, at: None }
|
||||
}
|
||||
|
||||
fn window(a: f64, axis: &str, band: &'static str, flagged: bool) -> Window {
|
||||
let s = AxisScore { axis: axis.into(), value: 0.5, by: "head", state: "advice".into(), band: Some(band), flagged, gating: false };
|
||||
Window { a, b: a + 2.0, axes: vec![s], seen: None, heard: None, level: -20.0, overall: None }
|
||||
}
|
||||
|
||||
fn scored(moments: Vec<Moment>, windows: Vec<Window>) -> Scored {
|
||||
Scored { file: "a.mp4".into(), media: "m".into(), dur: 10.0, fingerprint: "test".into(), moments, windows }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flags_are_asked_and_unsure_adds_the_plausible_windows_run_together() {
|
||||
let fp = base("test");
|
||||
let s = scored(vec![moment(0.0, 3.0, "blur")], vec![window(4.0, "glitch", "plausible", false), window(5.0, "glitch", "plausible", false), window(8.0, "glitch", "weak", false)]);
|
||||
assert_eq!(moments(&s, &fp, "flags").len(), 1);
|
||||
let unsure = moments(&s, &fp, "unsure");
|
||||
assert_eq!(unsure.iter().map(|d| (d.a, d.b, d.axis.as_str(), d.flagged)).collect::<Vec<_>>(), [(0.0, 3.0, "blur", true), (4.0, 7.0, "glitch", false)]);
|
||||
assert!(unsure[0].words.contains("blurry"), "an axis is asked in its own words: {}", unsure[0].words);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_axis_asks_as_it_senses_and_a_quality_is_flagged_on_no() {
|
||||
let fp = base("test");
|
||||
let blur = question(fp.axis("blur").unwrap());
|
||||
assert!(blur.ask.starts_with("Is there a blurry") && blur.sees == Sees::Video && !blur.hears && blur.flags.is_empty());
|
||||
assert_eq!(blur.label_words, fp.axis("blur").unwrap().words, "the person's notes in the axis's words label it");
|
||||
let muffled = question(fp.axis("muffled voice").unwrap());
|
||||
assert!(muffled.sees == Sees::Nothing && muffled.hears);
|
||||
let mut good = fp.axis("blur").unwrap().clone();
|
||||
good.polarity = "good".into();
|
||||
let q = question(&good);
|
||||
assert!(q.ask.starts_with("Is this ") && q.flags == ["no"]);
|
||||
}
|
||||
|
||||
/// clef as a fake: yes to the blur question, no to anything else.
|
||||
fn blur_only(call: &Call) -> Result<Answered, Fail> {
|
||||
let answers = call.questions.iter().map(|q| (q.id.clone(), json!({"noul": if q.id == "fp.blur" { 0.8 } else { 0.1 }}))).collect();
|
||||
Ok(Answered { answers, cost: 0.001, cached: false, route: "a test".into(), pool_left: None })
|
||||
}
|
||||
|
||||
/// A 6 s clip with a picture and a tone.
|
||||
fn clip() -> PathBuf {
|
||||
let out = std::env::temp_dir().join(format!("raea-double-{}.mp4", std::process::id()));
|
||||
let ff = raea_io_assets::ffmpeg_tool("ffmpeg", false).expect("FFmpeg");
|
||||
let ok = std::process::Command::new(ff)
|
||||
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc=size=320x240:rate=10:duration=6", "-f", "lavfi", "-i", "sine=frequency=440:duration=6"])
|
||||
.args(["-c:v", "mpeg4", "-c:a", "aac", "-shortest"])
|
||||
.arg(&out)
|
||||
.status()
|
||||
.expect("FFmpeg ran");
|
||||
assert!(ok.success());
|
||||
out
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_flag_is_asked_on_its_own_window_and_said_beside_it_and_kept_as_clefs() {
|
||||
// SAFETY: this crate's only test that reads it, set before the runner starts
|
||||
unsafe { std::env::set_var("RAEA_ASK_DIR", std::env::temp_dir().join(format!("raea-double-ask-{}", std::process::id()))) };
|
||||
let fp = base("test");
|
||||
let file = clip();
|
||||
let s = scored(vec![moment(0.0, 2.0, "blur"), moment(0.0, 2.0, "glitch"), moment(3.0, 5.0, "muffled voice")], vec![]);
|
||||
let ds = ask(&file, &fp, moments(&s, &fp, "flags"), &Opts { jobs: 2, dry: false, ask: blur_only });
|
||||
let said: Vec<String> = ds.iter().map(|d| format!("{}: {}", d.axis, d.said())).collect();
|
||||
assert_eq!(said, ["blur: clef agrees (0.80)", "glitch: clef doesn't see it (0.10)", "muffled voice: clef doesn't see it (0.10)"]);
|
||||
assert!(lines(&ds).starts_with("asked again of clef (3 moments):\n 0:00-0:02 blur: clef agrees (0.80)\n"), "{}", lines(&ds));
|
||||
let gone = ask(&std::env::temp_dir().join("raea-double-none.mp4"), &fp, moments(&s, &fp, "flags"), &Opts { jobs: 2, dry: false, ask: blur_only });
|
||||
assert!(gone.iter().all(|d| d.agrees.is_none() && d.said().starts_with("clef wasn't asked")), "a file it can't read asks nothing: {gone:?}");
|
||||
let r = row(&ds[0], "m", "p").unwrap();
|
||||
assert!(r.bad && r.source == "eye:clef" && r.who == "clef" && (r.a, r.b) == (0.0, 2.0));
|
||||
assert!(!row(&ds[1], "m", "p").unwrap().bad);
|
||||
let mut unanswered = ds[0].clone();
|
||||
unanswered.agrees = None;
|
||||
assert!(row(&unanswered, "m", "p").is_none(), "a moment clef didn't answer isn't evidence");
|
||||
}
|
||||
@@ -33,7 +33,7 @@ pub(crate) fn session(entry: &str, file: Option<&Path>, rest: &[String], secs: f
|
||||
let bridge = blender_bridge::start(&bin, file, rest)?;
|
||||
*BRIDGE.lock().map_err(|e| e.to_string())? = Some((bridge.port, bridge.token.clone()));
|
||||
let out = std::env::temp_dir().join(format!("raea-blender-{}.js", std::process::id()));
|
||||
let ran = raea_runtime_bundle::bundle_entry(entry, &out, &[]).and_then(|_| raea_runtime_export::run_bundle_to_terminal(&out, secs));
|
||||
let ran = raea_runtime_bundle::bundle_entry(entry, &out, &[]).and_then(|_| raea_runtime_export::run_bundle(&out, secs));
|
||||
let _ = std::fs::remove_file(&out);
|
||||
let _ = post(&json!({ "sid": "raea", "ops": [{ "o": "quit" }] }));
|
||||
*BRIDGE.lock().map_err(|e| e.to_string())? = None;
|
||||
|
||||
@@ -13,10 +13,6 @@ raea-io-home = { path = "../../io/home" }
|
||||
raea-sys-fingerprint = { path = "../../systems/fingerprint" }
|
||||
# scoring and the sheet, which one judges a piece, diff and profiles
|
||||
raea-sys-fingerprint-use = { path = "../../systems/fingerprint-use" }
|
||||
# score --ask: each flag asked again of the decision model (docs/ask.feature AK8)
|
||||
raea-app-double = { path = "../double" }
|
||||
# the critic a note is read by: a fresh session of the project's own agent (critic.rs)
|
||||
raea-io-clef = { path = "../../io/clef" }
|
||||
raea-sys-fingerprint-things = { path = "../../systems/fingerprint-things" }
|
||||
# the encoders and the columns they make
|
||||
raea-sys-columns = { path = "../../systems/columns" }
|
||||
|
||||
@@ -21,13 +21,13 @@ 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 [--was OLD] [--ask flags|unsure] [--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 | 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 postmortem [PROJECT] [--ask N] [--tally] | raea fingerprint things FILE [--project P] [--json] | 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, and patch heads that say where in the frame a picture defect is; 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 (where in the frame, and the layers there, when its patch head points held out), then every axis per window with --json, a sheet PNG with --sheet, or the piece second by second in words with --timeline, and with --was OLD whether each of OLD's gating flags is fixed, still there, or looks disguised (nearer the axis's disguised defects than clean work), and with --ask flags each flag put to clef again on its own window, whether clef agrees said beside it and kept as clef's evidence (unsure: the moments it's unsure of too); 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 session of the project's own agent read its 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; postmortem scores every version in a project's feed and asks you at most ten yes/no questions in the app, each with its moment playing, where the fingerprint disagrees with your labels or is least sure, and --tally makes your answers evidence and says how each head's held-out score moved; things finds a piece's shots, its things (a render's layers, and the marks drawn on its notes) with their depth, and the camera's path, and says where a thing floats, two pass through each other, the camera lurches mid-move or nothing is on screen, for a person to look at; --json prints it as JSON)";
|
||||
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 [--was OLD] [--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 postmortem [PROJECT] [--ask N] [--tally] | raea fingerprint things FILE [--project P] [--json] | 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, and patch heads that say where in the frame a picture defect is; 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 (where in the frame, and the layers there, when its patch head points held out), then every axis per window with --json, a sheet PNG with --sheet, or the piece second by second in words with --timeline, and with --was OLD whether each of OLD's gating flags is fixed, still there, or looks disguised (nearer the axis's disguised defects than clean work); 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; postmortem scores every version in a project's feed and asks you at most ten yes/no questions in the app, each with its moment playing, where the fingerprint disagrees with your labels or is least sure, and --tally makes your answers evidence and says how each head's held-out score moved; things finds a piece's shots, its things (a render's layers, and the marks drawn on its notes) with their depth, and the camera's path, and says where a thing floats, two pass through each other, the camera lurches mid-move or nothing is on screen, as JSON for `raea check --things` with --json)";
|
||||
|
||||
/// 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); 30] = [
|
||||
pub(crate) const FLAGS: [(&str, bool); 31] = [
|
||||
("--fp", true),
|
||||
("--was", true),
|
||||
("--to", true),
|
||||
@@ -51,6 +51,7 @@ pub(crate) const FLAGS: [(&str, bool); 30] = [
|
||||
("--as", true),
|
||||
("--against", true),
|
||||
("--profile", true),
|
||||
("--by", true),
|
||||
("--ask", true),
|
||||
("--tally", false),
|
||||
("--bad", false),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Notes become evidence (docs/fingerprint.feature FP5a, FP5b). `raea fingerprint read PROJECT` has a fresh session of
|
||||
//! the project's own agent (its host's critic, raea_io_clef::critic; never one raea or the agent picks) read each pinned note on the project's videos into a kind (defect, direction, praise or
|
||||
//! Notes become evidence (docs/fingerprint.feature FP5a, FP5b). `raea fingerprint read PROJECT [--by kimi|claude]`
|
||||
//! has a fresh agent session read each pinned note on the project's videos into a kind (defect, direction, praise or
|
||||
//! both) and an axis from the fingerprint's own axes, kept in the fingerprint's readings.jsonl. Nothing trains on them
|
||||
//! yet: `raea fingerprint readings --ask N` puts N readings to the person as questions in the app (`raea show
|
||||
//! --question`, answers to the "fingerprint" inbox), `readings --tally` counts how often the person agreed, and only
|
||||
@@ -99,9 +99,30 @@ pub fn fold(notes: &mut [Reading], fp: &Fingerprint, ans: &[Value], by: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
/// One fresh session of the project's own agent, through its host (raea_io_clef::critic): its words
|
||||
fn ask(cwd: &Path, p: &str) -> Result<String, String> {
|
||||
raea_io_clef::critic::ask(cwd, p)
|
||||
/// One fresh session's words: kimi's or claude's stream, the assistant's text joined
|
||||
fn ask(by: &str, p: &str) -> Result<String, String> {
|
||||
let mut c = std::process::Command::new(by);
|
||||
match by {
|
||||
"kimi" => c.args(["-p", p, "--output-format", "stream-json"]),
|
||||
"claude" => c.args(["-p", p, "--output-format", "stream-json", "--verbose", "--allowedTools", ""]),
|
||||
o => return Err(format!("--by {o}: kimi or claude")),
|
||||
};
|
||||
let out = c.output().map_err(|e| format!("couldn't run {by}: {e}"))?;
|
||||
let mut text = String::new();
|
||||
for line in String::from_utf8_lossy(&out.stdout).lines() {
|
||||
let Ok(v) = serde_json::from_str::<Value>(line) else { continue };
|
||||
let content = if v["role"] == "assistant" { &v["content"] } else if v["type"] == "assistant" { &v["message"]["content"] } else if v["type"] == "result" { &v["result"] } else { continue };
|
||||
match content {
|
||||
Value::String(s) => text += s,
|
||||
Value::Array(a) => a.iter().filter_map(|p| p["text"].as_str()).for_each(|s| text += s),
|
||||
_ => {}
|
||||
}
|
||||
text.push('\n');
|
||||
}
|
||||
if text.trim().is_empty() {
|
||||
return Err(format!("{by} said nothing: {}", String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")));
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
pub fn readings_of(dir: &Folder) -> Vec<Reading> {
|
||||
@@ -112,12 +133,12 @@ pub fn write_readings(dir: &Folder, r: &[Reading]) -> std::io::Result<()> {
|
||||
std::fs::write(dir.dir.join("readings.jsonl"), r.iter().filter_map(|x| serde_json::to_string(x).ok()).map(|l| l + "\n").collect::<String>())
|
||||
}
|
||||
|
||||
/// `raea fingerprint read PROJECT`
|
||||
/// `raea fingerprint read PROJECT [--by kimi|claude]`
|
||||
pub(crate) fn read_here(args: &[String], cwd: &Path) -> i32 {
|
||||
let run = || -> Result<String, String> {
|
||||
let w = words(args)?;
|
||||
let project = w.first().map_or(cwd.to_path_buf(), |p| cwd.join(p));
|
||||
let by = "agent";
|
||||
let by = flag(args, "--by").unwrap_or("kimi");
|
||||
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);
|
||||
@@ -127,15 +148,15 @@ pub(crate) fn read_here(args: &[String], cwd: &Path) -> i32 {
|
||||
return Ok(format!("no new pinned notes in {}", project.display()));
|
||||
}
|
||||
for chunk in notes.chunks_mut(40) {
|
||||
let text = ask(&project, &prompt(&fp, chunk))?;
|
||||
let ans = answer(&text).ok_or_else(|| "the critic answered no readings JSON".to_string())?;
|
||||
let text = ask(by, &prompt(&fp, chunk))?;
|
||||
let ans = answer(&text).ok_or_else(|| format!("{by} answered no readings JSON"))?;
|
||||
fold(chunk, &fp, &ans, by);
|
||||
eprintln!("read {} notes", chunk.len());
|
||||
}
|
||||
let read = notes.iter().filter(|n| !n.kind.is_empty()).count();
|
||||
kept.extend(notes.into_iter().filter(|n| !n.kind.is_empty()));
|
||||
write_readings(&dir, &kept).map_err(|e| e.to_string())?;
|
||||
Ok(format!("{read} notes read into labels by a fresh session of the project's agent, kept in {}; none trains a head until you've checked them: raea fingerprint readings --ask 50", dir.dir.join("readings.jsonl").display()))
|
||||
Ok(format!("{read} notes read into labels by {by}, kept in {}; none trains a head until you've checked them: raea fingerprint readings --ask 50", dir.dir.join("readings.jsonl").display()))
|
||||
};
|
||||
match run() {
|
||||
Ok(o) => {
|
||||
@@ -264,7 +285,7 @@ mod tests {
|
||||
let fp = raea_sys_fingerprint::taxonomy::base("me");
|
||||
let mut n = vec![Reading { note: "n1".into(), ..Default::default() }, Reading { note: "n2".into(), ..Default::default() }, Reading { note: "n3".into(), ..Default::default() }];
|
||||
let ans = answer("I read them.\n[{\"id\": \"n1\", \"kind\": \"defect\", \"axis\": \"glitch\"}, {\"id\": \"n2\", \"kind\": \"direction\", \"axis\": \"made up\"}, {\"id\": \"n3\", \"kind\": \"rant\", \"axis\": null}]").unwrap();
|
||||
fold(&mut n, &fp, &ans, "agent");
|
||||
fold(&mut n, &fp, &ans, "kimi");
|
||||
assert_eq!((n[0].kind.as_str(), n[0].axis.as_deref()), ("defect", Some("glitch")));
|
||||
assert_eq!((n[1].kind.as_str(), n[1].axis.as_deref()), ("direction", None), "an axis the fingerprint hasn't is dropped");
|
||||
assert_eq!(n[2].kind, "", "a kind it doesn't know is no reading");
|
||||
|
||||
@@ -303,16 +303,6 @@ fn scored(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result
|
||||
let found = checks(&file);
|
||||
arbitrate(&mut s, &fp, &found);
|
||||
raea_sys_fingerprint_things::located::locate(enc, &file, &raea_sys_fingerprint_use::patch::load(&dir.dir), &mut s)?;
|
||||
// AK8: each flag asked again of the decision model on its own window, the answers kept as clef's evidence
|
||||
let doubles = match flag(args, "--ask").map(str::to_string).or_else(|| fp.ask.clone()) {
|
||||
Some(which) => {
|
||||
anyhow::ensure!(which == "flags" || which == "unsure", "--ask takes flags or unsure, not {which}");
|
||||
let d = raea_app_double::ask(&file, &fp, raea_app_double::moments(&s, &fp, &which), &raea_app_double::Opts::new(4, false));
|
||||
raea_app_double::keep(&dir, &c, &project_of(&file), &d).map_err(|e| anyhow!(e))?;
|
||||
d
|
||||
}
|
||||
None => Vec::new(),
|
||||
};
|
||||
// FP9a: each gating flag on the cut before, judged on this one, and its axis's disguises rerun on the fix
|
||||
let fixes = match flag(args, "--was") {
|
||||
Some(old) => {
|
||||
@@ -324,7 +314,7 @@ fn scored(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result
|
||||
None => None,
|
||||
};
|
||||
let mut out = if has(args, "--json") {
|
||||
serde_json::to_string_pretty(&json!({"fingerprint": {"name": fp.name, "about": fp.about, "why": why}, "scored": s, "clef": doubles, "checks": found.iter().map(|(r, a, b, says)| json!({"check": r, "a": a, "b": b, "says": says})).collect::<Vec<_>>(), "fixes": fixes}))?
|
||||
serde_json::to_string_pretty(&json!({"fingerprint": {"name": fp.name, "about": fp.about, "why": why}, "scored": s, "checks": found.iter().map(|(r, a, b, says)| json!({"check": r, "a": a, "b": b, "says": says})).collect::<Vec<_>>(), "fixes": fixes}))?
|
||||
} else if let Some(f) = &fixes {
|
||||
let mut t = format!("judged by {}: {why}\n", fp.name);
|
||||
t += &raea_sys_fingerprint_use::fixed::said(f);
|
||||
@@ -333,9 +323,6 @@ fn scored(enc: &mut Encoders, args: &[String], cwd: &Path, eval: Eval) -> Result
|
||||
} else {
|
||||
let mut t = format!("judged by {}: {why}\n", fp.name);
|
||||
t += &summary(&s);
|
||||
if !doubles.is_empty() {
|
||||
t += &raea_app_double::lines(&doubles);
|
||||
}
|
||||
t += &format!("checks: {}\n", if found.is_empty() { "no findings".to_string() } else { format!("{} findings", found.len()) });
|
||||
for (r, a, _, says) in &found {
|
||||
t += &format!(" {} {r}: {says}\n", clock(*a));
|
||||
|
||||
@@ -74,11 +74,11 @@ pub fn export(args: &[String]) -> R<String> {
|
||||
}
|
||||
};
|
||||
if !player.exists() {
|
||||
return Err(format!("no game player at {}: this raea ships without raea-game, which a game's export is made from; `raea bug \"export-game: no player\"` asks for it (docs/nobuild.feature NB3a)", player.display()));
|
||||
return Err(format!("no player at {} (build it: cargo build --profile game -p raea-app-game --bin raea-game --features player)", player.display()));
|
||||
}
|
||||
// the release build's player is ~128 MB stripped, the game profile's ~74 MB (fat LTO, one codegen unit; lightspeed
|
||||
// R7): say so when the bigger one ships because it's the newer, to a checkout's build (an installed raea has only its own)
|
||||
if !player.to_string_lossy().contains("/game/") && player.to_string_lossy().contains("/target/") && flag(args, "--player").is_none() {
|
||||
// R7): say so when the bigger one ships because it's the newer
|
||||
if !player.to_string_lossy().contains("/game/") && flag(args, "--player").is_none() {
|
||||
let mb = std::fs::metadata(&player).map(|m| m.len() as f64 / 1048576.0).unwrap_or(0.0);
|
||||
eprintln!("raea export-game: shipping the release build's player ({mb:.0} MB before stripping): `cargo build --profile game -p raea-app-game --bin raea-game --features player` makes the ~74 MB one, which ships when it's the newer");
|
||||
}
|
||||
|
||||
@@ -99,18 +99,13 @@ fn shape(expr: &str, out: &Path, meshes: &mut BTreeMap<String, String>) -> R<Val
|
||||
Some(f) => f.clone(),
|
||||
None => {
|
||||
let f = format!("meshes/mesh{k}.glb");
|
||||
// export() empties meshes/ before the parts are walked, so the folder is made here, where a file first needs it
|
||||
let dir = out.join("meshes");
|
||||
if let Err(e) = std::fs::create_dir_all(&dir) {
|
||||
return Err(format!("{}: {e}", dir.display()));
|
||||
}
|
||||
// and as an .obj, which Godot imports as a mesh of its own (a .glb comes in as a scene)
|
||||
let (glb, obj) = (out.join(&f).to_string_lossy().into_owned(), out.join(f.replace(".glb", ".obj")).to_string_lossy().into_owned());
|
||||
match expr.strip_prefix("buffer:") {
|
||||
// a mesh given by its own vertices (a <BufferMesh>, a three.js geometry through raea/r3f): written as it
|
||||
// is, with its normals and texture coordinates, since it needn't be a closed solid
|
||||
Some(b) => {
|
||||
let (t, uv) = raea_core_shape::buffer_tris(&raea_core_shape::buffer_json(b)?)?;
|
||||
let (t, uv) = raea_core_shape::buffer_tris(b)?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &glb, "glb")?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &obj, "obj")?;
|
||||
}
|
||||
@@ -317,8 +312,7 @@ mod tests {
|
||||
#[test]
|
||||
fn primitives_cross_as_themselves_and_the_rest_as_a_mesh() {
|
||||
let out = std::env::temp_dir().join(format!("raea-interchange-shape-{}", std::process::id()));
|
||||
// no meshes/ beforehand, as export() leaves it: shape() makes it (it once failed every solid in a fresh export)
|
||||
std::fs::create_dir_all(&out).unwrap();
|
||||
std::fs::create_dir_all(out.join("meshes")).unwrap();
|
||||
let mut m = BTreeMap::new();
|
||||
assert_eq!(shape("box(1, 2, 3)", &out, &mut m).unwrap(), json!({ "type": "cuboid", "size": [1.0, 2.0, 3.0] }));
|
||||
assert_eq!(shape("sphere(0.5)", &out, &mut m).unwrap()["type"], "sphere");
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "raea-app-judge"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea judge: a review's sheets judged by clef-omni on a frozen rubric, the pass decided in code, calibrated against the person's eye before it gates"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# what a judge saw, as raea's one Finding (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
serde_json = "1"
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
ureq = { version = "2", features = ["json"] }
|
||||
base64 = "0.22"
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
|
||||
@@ -0,0 +1,149 @@
|
||||
//! A judge that is an agent CLI rather than clef-omni: `raea judge DIR --by kimi|claude` (Shane, 11-06: "use claude or
|
||||
//! kimi cli as the judge"). Each call is a new session, run in DIR with only the sheets to look at (kimi's media tool;
|
||||
//! claude with Read alone), given the fresh-context judge prompt (sdk/guides/craft/bevy/prompts.md section 3) and
|
||||
//! never the code or the builder's notes. It answers JSON: the seven scores 0-10, the blind read and every defect named;
|
||||
//! the pass, done and stall are still decided in code (rubric::pass, progress). `raea judge eye DIR --by kimi` records
|
||||
//! its reading as the eye clef is calibrated against.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
use crate::rubric::SCORES;
|
||||
|
||||
pub const BY: [&str; 2] = ["kimi", "claude"];
|
||||
|
||||
/// The judge prompt: the sheets by name, the brief's words, and the JSON to answer.
|
||||
pub fn prompt(dir: &Path, brief: &Value, target: Option<&Path>) -> String {
|
||||
let words = ["look", "logline", "notDoing"].iter().filter_map(|k| brief.get(*k).map(|v| format!("{k}: {}", v.as_str().map(str::to_string).unwrap_or_else(|| v.to_string())))).collect::<Vec<_>>().join("; ");
|
||||
let target = target.map(|t| format!(" The target picture, what it must read as, is {}.", t.display())).unwrap_or_default();
|
||||
format!(
|
||||
"You review a 3D scene from images only, as the person who will use it would. You have never seen how it was built and you never will. \
|
||||
Judge what is in the pixels; do not guess at intentions. Only look at images; change no file.\n\n\
|
||||
PART 1, BLIND: open {d}/hero-colour.png first, one frame. In one sentence: what place is this, what time, what era? List five objects you can name. \
|
||||
Is it a photograph or a render, and which three tells decided it?\n\n\
|
||||
PART 2, SCORED. The brief: \"{words}\".{target} This round's sheets: {d}/colour.png and {d}/clay.png, each six tiles, left to right, top to bottom: \
|
||||
hero, front, right, top, iso, low (0.3 m off the floor). Clay is every surface light grey and matte. Open both.\n\n\
|
||||
Score each 0-10 (5 = a believable draft; 7 = a production base an artist would accept; 9 = indistinguishable from real). Halves are allowed.\n\
|
||||
- composition: camera, framing, layout, the position and scale of every major object.\n\
|
||||
- form, judged on CLAY: silhouettes read at a glance; parts have real thickness; nothing blobby, melted or a primitive standing in for a thing; repeated things vary.\n\
|
||||
- assembly, judged on CLAY first: nothing floats, sinks, pokes through or rests on the wrong thing; joints touch; the low tile shows the feet.\n\
|
||||
- materials: every surface reads as its real material, with wear where use puts it; nothing a flat default colour.\n\
|
||||
- light: motivated by the place's own sources; exposure and contrast believable.\n\
|
||||
- detail: close views hold real geometry or texture, not a smooth stand-in; printed matter reads.\n\
|
||||
- world: one coherent real place; nothing off-era or invented beyond the brief.\n\n\
|
||||
Then list the defects, most damaging first: at most 8, each field one short sentence. \"blocking\" means someone using this scene would notice it in the views it will be seen in. \
|
||||
Name exactly what gives it away (not \"the dryer looks fake\" but \"the dryer door is a flat disc with no rim or glass depth\").\n\n\
|
||||
End your answer with only this JSON, nothing after it:\n\
|
||||
{{\"blind\": {{\"place\": \"\", \"objects\": [], \"photo\": \"yes|no\", \"tells\": []}}, \
|
||||
\"scores\": {{\"composition\": 0, \"form\": 0, \"assembly\": 0, \"materials\": 0, \"light\": 0, \"detail\": 0, \"world\": 0}}, \
|
||||
\"defects\": [{{\"tile\": \"\", \"where\": \"\", \"wrong\": \"\", \"real\": \"\", \"fix\": \"\", \"level\": \"blocking|detail\"}}], \
|
||||
\"show_as_is\": \"\"}}",
|
||||
d = dir.display()
|
||||
)
|
||||
}
|
||||
|
||||
/// The last JSON object in the text that has scores (an agent may think aloud, or draft the JSON twice).
|
||||
pub fn last_verdict(text: &str) -> Option<Value> {
|
||||
let starts: Vec<usize> = text.match_indices('{').map(|(i, _)| i).collect();
|
||||
for &s in starts.iter().rev() {
|
||||
let mut de = serde_json::Deserializer::from_str(&text[s..]).into_iter::<Value>();
|
||||
if let Some(Ok(v)) = de.next()
|
||||
&& v.get("scores").is_some_and(Value::is_object)
|
||||
{
|
||||
return Some(v);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// The verdict read into the judge's own shape: scores (0-10, the seven categories), defects (present, level, named
|
||||
/// by what is wrong), the blind read's photo (1 a photo, 0 a render) and the agent's own words.
|
||||
pub fn read(v: &Value) -> (Map<String, Value>, Vec<Value>, Value) {
|
||||
let mut scores = Map::new();
|
||||
for (k, _, _) in SCORES {
|
||||
if let Some(x) = v["scores"][k].as_f64().filter(|x| (0.0..=10.0).contains(x)) {
|
||||
scores.insert(k.into(), json!(x));
|
||||
}
|
||||
}
|
||||
let defects = v["defects"].as_array().into_iter().flatten().filter(|d| d["wrong"].as_str().is_some_and(|w| !w.trim().is_empty())).map(|d| {
|
||||
let level = if d["level"].as_str().unwrap_or("").starts_with("block") { "blocking" } else { "detail" };
|
||||
let wrong = d["wrong"].as_str().unwrap_or("");
|
||||
json!({"defect": wrong.chars().take(80).collect::<String>(), "present": true, "level": level, "sheet": d["tile"], "asked": wrong,
|
||||
"where": d["where"], "real": d["real"], "fix": d["fix"]})
|
||||
}).collect();
|
||||
let photo = match v["blind"]["photo"].as_str() {
|
||||
Some(p) if p.starts_with('y') => json!(1.0),
|
||||
Some(p) if p.starts_with('n') => json!(0.0),
|
||||
_ => Value::Null,
|
||||
};
|
||||
(scores, defects, photo)
|
||||
}
|
||||
|
||||
/// One fresh judging session by `by` over DIR's sheets: its verdict JSON. Its steps stream (kimi's stream-json), each
|
||||
/// said on stderr as it comes, so a watcher sees it working through a judgement that can take minutes.
|
||||
pub fn ask(by: &str, dir: &Path, brief: &Value, target: Option<&Path>) -> Result<Value, String> {
|
||||
use std::io::BufRead as _;
|
||||
let dir = dunce::canonicalize(&dir).map_err(|e| format!("judge: {}: {e}", dir.display()))?;
|
||||
let p = prompt(&dir, brief, target);
|
||||
let mut cmd = match by {
|
||||
"kimi" => {
|
||||
let mut c = std::process::Command::new("kimi");
|
||||
c.args(["-p", &p, "--output-format", "stream-json"]);
|
||||
c
|
||||
}
|
||||
"claude" => {
|
||||
let mut c = std::process::Command::new("claude");
|
||||
c.args(["-p", &p, "--allowedTools", "Read", "--output-format", "stream-json", "--verbose"]);
|
||||
c
|
||||
}
|
||||
o => return Err(format!("judge: --by {o}: the judges are clef (the default), {}", BY.join(", "))),
|
||||
};
|
||||
let mut child = cmd.current_dir(&dir).stdout(std::process::Stdio::piped()).stderr(std::process::Stdio::piped()).spawn()
|
||||
.map_err(|e| format!("judge: couldn't run {by}: {e} (is the {by} CLI installed and signed in?)"))?;
|
||||
let mut said = Vec::new();
|
||||
let mut last = String::new();
|
||||
for line in std::io::BufReader::new(child.stdout.take().ok_or("judge: no output pipe")?).lines().map_while(Result::ok) {
|
||||
let Ok(v) = serde_json::from_str::<Value>(&line) else { continue };
|
||||
said.extend(texts(&v));
|
||||
let step = match (v["role"].as_str(), v["type"].as_str()) {
|
||||
(Some("tool") | Some("user"), _) => "looked at a picture".to_string(),
|
||||
(Some("assistant"), _) | (_, Some("assistant")) => texts(&v).last().map_or_else(|| "thinking".into(), |t| t[..t.floor_char_boundary(100)].to_string()),
|
||||
_ => continue,
|
||||
};
|
||||
if step != last {
|
||||
eprintln!("judge ({by}): {}", step.replace('\n', " "));
|
||||
last = step;
|
||||
}
|
||||
}
|
||||
let out = child.wait_with_output().map_err(|e| format!("judge: {by}: {e}"))?;
|
||||
let text = said.join("\n");
|
||||
if !out.status.success() && last_verdict(&text).is_none() {
|
||||
return Err(format!("judge: {by} failed: {}", String::from_utf8_lossy(&out.stderr).lines().rev().find(|l| !l.trim().is_empty()).unwrap_or("no output")));
|
||||
}
|
||||
last_verdict(&text).ok_or_else(|| format!("judge: {by} answered no verdict JSON: {}", text.trim().chars().rev().take(300).collect::<String>().chars().rev().collect::<String>()))
|
||||
}
|
||||
|
||||
/// The words in one streamed line: kimi's {role: assistant, content: "..."}; claude's {type: assistant, message:
|
||||
/// {content: [{type: text, text}]}} and its final {type: result, result}.
|
||||
fn texts(v: &Value) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
if v["role"] == "assistant"
|
||||
&& let Some(s) = v["content"].as_str()
|
||||
{
|
||||
out.push(s.to_string());
|
||||
}
|
||||
for c in v["message"]["content"].as_array().into_iter().flatten() {
|
||||
if c["type"] == "text"
|
||||
&& let Some(s) = c["text"].as_str()
|
||||
{
|
||||
out.push(s.to_string());
|
||||
}
|
||||
}
|
||||
if v["type"] == "result"
|
||||
&& let Some(s) = v["result"].as_str()
|
||||
{
|
||||
out.push(s.to_string());
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//! One clef-omni call on Workers AI (as apps/app/host/critique.ts makes it): the state paragraph, the questions by id,
|
||||
//! the images as data URLs (each made a JPEG at most 1600 px wide first). Keys: CLOUDFLARE_ACCOUNT_ID and
|
||||
//! CLOUDFLARE_API_TOKEN from raea's settings (the environment, then ~/.raea/env).
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use base64::Engine as _;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
fn jpeg(p: &PathBuf) -> Result<String, String> {
|
||||
let img = image::open(p).map_err(|e| format!("{}: {e}", p.display()))?;
|
||||
let img = if img.width() > 1600 { img.resize(1600, u32::MAX, image::imageops::FilterType::Triangle) } else { img };
|
||||
let mut buf = std::io::Cursor::new(Vec::new());
|
||||
img.to_rgb8().write_to(&mut buf, image::ImageFormat::Jpeg).map_err(|e| e.to_string())?;
|
||||
Ok(format!("data:image/jpeg;base64,{}", base64::engine::general_purpose::STANDARD.encode(buf.into_inner())))
|
||||
}
|
||||
|
||||
/// The answers by question id, and the call's cost in dollars ($0.15 a million input tokens).
|
||||
pub fn ask(state: &str, questions: &Value, images: &[PathBuf]) -> Result<(Value, f64), String> {
|
||||
let (Some(acct), Some(token)) = (raea_io_home::setting("CLOUDFLARE_ACCOUNT_ID"), raea_io_home::setting("CLOUDFLARE_API_TOKEN")) else {
|
||||
return Err("judge: clef-omni on Workers AI needs CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (the environment or ~/.raea/env)".into());
|
||||
};
|
||||
let imgs: Vec<String> = images.iter().map(jpeg).collect::<Result<_, _>>()?;
|
||||
let body = json!({"state": state, "questions": questions, "images": imgs});
|
||||
let url = format!("https://api.cloudflare.com/client/v4/accounts/{acct}/ai/run/@cf/cloudflare/clef-omni");
|
||||
let res = ureq::post(&url).set("authorization", &format!("Bearer {token}")).timeout(std::time::Duration::from_secs(180)).send_json(body);
|
||||
let j: Value = match res {
|
||||
Ok(r) => r.into_json().map_err(|e| format!("clef: {e}"))?,
|
||||
Err(ureq::Error::Status(code, r)) => return Err(format!("clef: HTTP {code}: {}", r.into_string().unwrap_or_default().chars().take(300).collect::<String>())),
|
||||
Err(e) => return Err(format!("clef: {e}")),
|
||||
};
|
||||
if j["success"] != true {
|
||||
return Err(format!("clef: {}", j["errors"].to_string().chars().take(300).collect::<String>()));
|
||||
}
|
||||
let cost = j["result"]["usage"]["input_tokens"].as_f64().unwrap_or(0.0) * 0.15 / 1e6;
|
||||
Ok((j["result"]["answers"].clone(), cost))
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
//! Shane's eye, the judge's calibration. `raea judge eye DIR form=5 light=7 ... [--pass yes|no]` records his scores for a
|
||||
//! round the judge has already judged (DIR/judge.json), with the judge's raw scores beside them, in
|
||||
//! ~/.raea/judge/eye.jsonl. `raea judge calibrate` fits, per category, a line from the judge's score to his
|
||||
//! (least squares), and says how often the mapped judge's pass agrees with his. The judge gates only once it has 10
|
||||
//! rounds or more, some passed by the eye and some not, and agrees on 8 in 10 or better; until then `gating` is false and its verdict is advice
|
||||
//! (clef has rated almost everything acceptable: docs/craft-system.md). `raea judge eye DIR --by kimi|claude` records a
|
||||
//! fresh agent session's reading instead (Shane, 11-06), each row saying whose eye it is.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde_json::{Map, Value, json};
|
||||
|
||||
use crate::rubric::{SCORES, pass};
|
||||
|
||||
fn home() -> PathBuf {
|
||||
raea_io_home::env_path("RAEA_JUDGE_DIR", ".raea/judge")
|
||||
}
|
||||
|
||||
/// The calibration in force, if one was made.
|
||||
pub fn calibration() -> Option<Value> {
|
||||
serde_json::from_str(&std::fs::read_to_string(home().join("calibration.json")).ok()?).ok()
|
||||
}
|
||||
|
||||
/// The judge's scores mapped through the calibration's lines, kept to 0-10.
|
||||
pub fn apply(c: &Value, scores: &mut Map<String, Value>) {
|
||||
for (k, v) in scores.iter_mut() {
|
||||
if let (Some(x), Some(a), Some(b)) = (v.as_f64(), c["maps"][k]["a"].as_f64(), c["maps"][k]["b"].as_f64()) {
|
||||
*v = json!(((a * x + b).clamp(0.0, 10.0) * 100.0).round() / 100.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn record(args: &[String]) -> Result<String, String> {
|
||||
let dir = args.get(2).map(PathBuf::from).ok_or("raea judge eye DIR CATEGORY=SCORE... [--pass yes|no]")?;
|
||||
let verdict: Value = serde_json::from_str(&std::fs::read_to_string(dir.join("judge.json")).map_err(|_| format!("judge eye: no {}: judge the round first (raea judge {})", dir.join("judge.json").display(), dir.display()))?).map_err(|e| e.to_string())?;
|
||||
// an agent's reading as the eye (`--by kimi`): a fresh session's scores, and its pass by the same rule in code
|
||||
if let Some(by) = args.iter().position(|a| a == "--by").and_then(|i| args.get(i + 1)) {
|
||||
let v = crate::agent::ask(by, &dir, &json!({}), None)?;
|
||||
let (eye, defects, _) = crate::agent::read(&v);
|
||||
if eye.len() < SCORES.len() {
|
||||
return Err(format!("judge eye: {by} scored only {} of {} categories", eye.len(), SCORES.len()));
|
||||
}
|
||||
let eye_pass = pass(&eye, &defects).0;
|
||||
let row = json!({"dir": verdict["dir"], "by": by, "judge": verdict["raw"], "judge_pass": verdict["pass"], "defects": verdict["defects"], "eye": eye, "eye_pass": eye_pass, "eye_defects": defects});
|
||||
append(&row)?;
|
||||
let shown: Vec<String> = eye.iter().map(|(k, v)| format!("{k} {v}")).collect();
|
||||
return Ok(format!("APPLIED {by}'s eye on {} recorded ({}): {}; raea judge calibrate fits clef to it", dir.display(), if eye_pass { "a pass" } else { "not yet" }, shown.join(", ")));
|
||||
}
|
||||
let mut eye = Map::new();
|
||||
let mut said_pass = None;
|
||||
let mut i = 3;
|
||||
while i < args.len() {
|
||||
if args[i] == "--pass" {
|
||||
said_pass = Some(matches!(args.get(i + 1).map(String::as_str), Some("yes" | "true" | "y")));
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
let (k, v) = args[i].split_once('=').ok_or_else(|| format!("judge eye: {:?} isn't CATEGORY=SCORE", args[i]))?;
|
||||
if !SCORES.iter().any(|s| s.0 == k) {
|
||||
return Err(format!("judge eye: no category {k}: {}", SCORES.iter().map(|s| s.0).collect::<Vec<_>>().join(", ")));
|
||||
}
|
||||
let x: f64 = v.parse().ok().filter(|x| (0.0..=10.0).contains(x)).ok_or_else(|| format!("judge eye: {k} is a score 0-10, got {v:?}"))?;
|
||||
eye.insert(k.into(), json!(x));
|
||||
i += 1;
|
||||
}
|
||||
if eye.is_empty() {
|
||||
return Err("judge eye: give your scores, e.g. composition=6 form=5 assembly=7 materials=4 light=6 detail=5 world=6".into());
|
||||
}
|
||||
// his pass: as he says it, else the same rule on his scores with the judge's defects
|
||||
let eye_pass = said_pass.unwrap_or_else(|| pass(&eye, verdict["defects"].as_array().map(Vec::as_slice).unwrap_or(&[])).0);
|
||||
let row = json!({"dir": verdict["dir"], "by": "shane", "judge": verdict["raw"], "judge_pass": verdict["pass"], "defects": verdict["defects"], "eye": eye, "eye_pass": eye_pass});
|
||||
append(&row)?;
|
||||
Ok(format!("APPLIED your eye on {} recorded ({}): raea judge calibrate fits the judge to it", dir.display(), if eye_pass { "a pass" } else { "not yet" }))
|
||||
}
|
||||
|
||||
/// One eye row onto ~/.raea/judge/eye.jsonl; a newer reading of the same round by the same eye replaces the older.
|
||||
fn append(row: &Value) -> Result<(), String> {
|
||||
std::fs::create_dir_all(home()).map_err(|e| e.to_string())?;
|
||||
let path = home().join("eye.jsonl");
|
||||
let mut rows: Vec<Value> = std::fs::read_to_string(&path).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).filter(|r: &Value| !(r["dir"] == row["dir"] && whose(r) == whose(&row))).collect();
|
||||
rows.push(row.clone());
|
||||
std::fs::write(&path, rows.iter().map(Value::to_string).collect::<Vec<_>>().join("\n") + "\n").map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Least squares y = a x + b; flat x (one value) maps by the mean offset.
|
||||
fn fit(xy: &[(f64, f64)]) -> (f64, f64) {
|
||||
let n = xy.len() as f64;
|
||||
let (mx, my) = (xy.iter().map(|p| p.0).sum::<f64>() / n, xy.iter().map(|p| p.1).sum::<f64>() / n);
|
||||
let sxx: f64 = xy.iter().map(|p| (p.0 - mx).powi(2)).sum();
|
||||
if sxx < 1e-9 {
|
||||
return (1.0, my - mx);
|
||||
}
|
||||
let a = xy.iter().map(|p| (p.0 - mx) * (p.1 - my)).sum::<f64>() / sxx;
|
||||
(a, my - a * mx)
|
||||
}
|
||||
|
||||
/// The fit over rows of {judge, eye, defects, eye_pass}: per-category maps and errors, and the pass agreement.
|
||||
pub fn fit_rows(rows: &[Value]) -> Value {
|
||||
let mut maps = Map::new();
|
||||
for (k, _, _) in SCORES {
|
||||
let xy: Vec<(f64, f64)> = rows.iter().filter_map(|r| Some((r["judge"][k].as_f64()?, r["eye"][k].as_f64()?))).collect();
|
||||
if xy.len() < 2 {
|
||||
continue;
|
||||
}
|
||||
let (a, b) = fit(&xy);
|
||||
let mae = |f: &dyn Fn(f64) -> f64| xy.iter().map(|(x, y)| (f(*x) - y).abs()).sum::<f64>() / xy.len() as f64;
|
||||
let r2 = |x: f64| (x * 1000.0).round() / 1000.0;
|
||||
maps.insert(k.into(), json!({"a": r2(a), "b": r2(b), "n": xy.len(), "maeRaw": r2(mae(&|x| x)), "maeMapped": r2(mae(&|x| (a * x + b).clamp(0.0, 10.0)))}));
|
||||
}
|
||||
let cal = json!({"maps": maps});
|
||||
let mut agree = 0;
|
||||
for r in rows {
|
||||
let mut s = r["judge"].as_object().cloned().unwrap_or_default();
|
||||
apply(&cal, &mut s);
|
||||
let p = pass(&s, r["defects"].as_array().map(Vec::as_slice).unwrap_or(&[])).0;
|
||||
if Value::Bool(p) == r["eye_pass"] {
|
||||
agree += 1;
|
||||
}
|
||||
}
|
||||
let n = rows.len();
|
||||
let agreement = if n == 0 { 0.0 } else { agree as f64 / n as f64 };
|
||||
// agreement means something only when the eye passed some rounds and failed others: all fails agree trivially
|
||||
let passes = rows.iter().filter(|r| r["eye_pass"] == true).count();
|
||||
let both = passes > 0 && passes < n;
|
||||
json!({"maps": maps, "rounds": n, "eyePasses": passes, "agreement": (agreement * 1000.0).round() / 1000.0, "gate": n >= 10 && agreement >= 0.8 && both})
|
||||
}
|
||||
|
||||
pub fn calibrate(args: &[String]) -> Result<String, String> {
|
||||
let rows: Vec<Value> = std::fs::read_to_string(home().join("eye.jsonl")).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).collect();
|
||||
if rows.is_empty() {
|
||||
return Err("judge calibrate: no rounds with your eye yet (raea judge eye DIR form=5 ...)".into());
|
||||
}
|
||||
let mut cal = fit_rows(&rows);
|
||||
let mut eyes: Vec<String> = rows.iter().map(whose).map(str::to_string).collect();
|
||||
eyes.sort();
|
||||
eyes.dedup();
|
||||
cal["eyes"] = json!(eyes);
|
||||
std::fs::write(home().join("calibration.json"), serde_json::to_string_pretty(&cal).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
if args.iter().any(|a| a == "--json") {
|
||||
return Ok(serde_json::to_string_pretty(&cal).unwrap_or_default());
|
||||
}
|
||||
let mut t: Vec<String> = cal["maps"].as_object().into_iter().flatten().map(|(k, m)| format!("{k:<12} eye = {} x judge {:+} (off by {} raw, {} mapped, {} rounds)", m["a"], m["b"], m["maeRaw"], m["maeMapped"], m["n"])).collect();
|
||||
t.push(format!("agreement on the pass: {} over {} rounds (eyes: {}); {}", cal["agreement"], cal["rounds"], eyes.join(", "), if cal["gate"] == true { "the judge gates now".to_string() } else if cal["rounds"].as_u64() >= Some(10) && cal["agreement"].as_f64() >= Some(0.8) { format!("advice only: the eye passed {} of {} rounds, and agreement means something only with passes and fails both (judge a scene that is good)", cal["eyePasses"], cal["rounds"]) } else { "advice only until 10 rounds agree 8 in 10, with passes and fails both".to_string() }));
|
||||
Ok(t.join("\n"))
|
||||
}
|
||||
|
||||
/// Whose eye a row records: Shane's when it doesn't say.
|
||||
fn whose(r: &Value) -> &str {
|
||||
r["by"].as_str().unwrap_or("shane")
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
//! `raea judge`: a review's sheets (`raea render --review DIR`) judged by clef-omni on the frozen rubric (rubric.rs),
|
||||
//! fresh every round and blind to the code, with the pass decided here in code. Until it is calibrated against Shane's
|
||||
//! eye (`raea judge eye`, `raea judge calibrate`, eye.rs) its verdict is advice: `gating` says which.
|
||||
//!
|
||||
//! raea judge DIR [--by clef|kimi|claude] [--brief brief.ts] [--target T.png] [--json] [--dry]
|
||||
//! raea judge eye DIR composition=6 form=5 ... [--pass yes|no] (or --by kimi: an agent's reading as the eye)
|
||||
//! raea judge calibrate [--json]
|
||||
//!
|
||||
//! DIR/judge.json is the verdict; DIR's parent's judge.log.jsonl holds every round's, so "done" (two passes in a row,
|
||||
//! each a fresh call) and the stall (the mean up by less than a point over two rounds) are read from it.
|
||||
|
||||
mod agent;
|
||||
mod clef;
|
||||
mod eye;
|
||||
pub mod rubric;
|
||||
|
||||
pub use agent::BY;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_facts::{Finding, Level, finding};
|
||||
use raea_runtime_bundle::flag;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub const USAGE: &str = "raea judge DIR [--by clef|kimi|claude] [--brief brief.ts] [--target T.png] [--json] [--dry] | judge eye DIR (CATEGORY=SCORE ... [--pass yes|no] | --by kimi|claude) | judge calibrate [--json] (a --review folder's sheets judged blind: clef-omni on the frozen rubric, or a fresh kimi or claude session on the judge prompt; the pass decided in code; clef advises until calibrated against your eye or an agent's)";
|
||||
|
||||
/// The brief's words, from `raea spec brief.ts --as brief` (look, logline, notDoing), or nothing.
|
||||
fn brief_of(path: Option<&str>) -> Result<Value, String> {
|
||||
let Some(p) = path else { return Ok(json!({})) };
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::process::Command::new(exe).args(["spec", p, "--as", "brief"]).output().map_err(|e| e.to_string())?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let start = text.find('{').ok_or_else(|| format!("judge: {p} didn't read as a brief: {}", String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")))?;
|
||||
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("judge: {p}: {e}"))?;
|
||||
Ok(v.get("brief").cloned().unwrap_or(v))
|
||||
}
|
||||
|
||||
/// The rounds judged so far beside this one (DIR's parent's judge.log.jsonl).
|
||||
fn log_of(dir: &Path) -> PathBuf {
|
||||
dir.parent().unwrap_or(dir).join("judge.log.jsonl")
|
||||
}
|
||||
|
||||
/// Done and stall, from the log's rounds (oldest first), in code.
|
||||
pub fn progress(rounds: &[Value]) -> Value {
|
||||
let passes = rounds.iter().rev().take_while(|r| r["pass"] == true).count();
|
||||
let means: Vec<f64> = rounds.iter().filter_map(|r| r["mean"].as_f64()).collect();
|
||||
let stall = means.len() >= 3 && {
|
||||
let best_before = means[..means.len() - 2].iter().cloned().fold(f64::MIN, f64::max);
|
||||
let best_now = means[means.len() - 2..].iter().cloned().fold(f64::MIN, f64::max);
|
||||
best_now - best_before < 1.0
|
||||
};
|
||||
// the same blocking defect present in the last two rounds
|
||||
let named = |r: &Value| -> Vec<String> { rubric::blocking(r["defects"].as_array().map(Vec::as_slice).unwrap_or_default()).into_iter().map(str::to_string).collect() };
|
||||
let again: Vec<String> = match rounds {
|
||||
[.., a, b] => named(a).into_iter().filter(|d| named(b).contains(d)).collect(),
|
||||
_ => Vec::new(),
|
||||
};
|
||||
json!({"rounds": rounds.len(), "passesInARow": passes, "done": passes >= 2, "stall": stall || !again.is_empty(), "again": again})
|
||||
}
|
||||
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
match args.get(1).map(String::as_str) {
|
||||
Some("eye") => return eye::record(args),
|
||||
Some("calibrate") => return eye::calibrate(args),
|
||||
Some(_) => {}
|
||||
None => return Err(USAGE.into()),
|
||||
}
|
||||
let dir = PathBuf::from(&args[1]);
|
||||
let (colour, clay, hero) = (dir.join("colour.png"), dir.join("clay.png"), dir.join("hero-colour.png"));
|
||||
for f in [&colour, &clay] {
|
||||
if !f.is_file() {
|
||||
return Err(format!("judge: no {} (make the sheets with raea render EDIT.tsx --review {})", f.display(), dir.display()));
|
||||
}
|
||||
}
|
||||
let brief = brief_of(flag(args, "--brief").as_deref())?;
|
||||
let target = flag(args, "--target").map(PathBuf::from);
|
||||
let dry = args.iter().any(|a| a == "--dry");
|
||||
let by = flag(args, "--by").unwrap_or_else(|| "clef".into());
|
||||
if by != "clef" {
|
||||
if dry {
|
||||
return Ok(agent::prompt(&dir, &brief, target.as_deref()));
|
||||
}
|
||||
let v = agent::ask(&by, &dir, &brief, target.as_deref())?;
|
||||
let (scores, defects, photo) = agent::read(&v);
|
||||
return finish(args, &dir, scores.clone(), scores, defects, photo, 0.0, &by, false, json!({"blind": v["blind"], "show_as_is": v["show_as_is"]}));
|
||||
}
|
||||
let mut calls = Vec::new();
|
||||
for (sheet, img) in [("colour", &colour), ("clay", &clay)] {
|
||||
let mut images = vec![img.clone()];
|
||||
if sheet == "colour" {
|
||||
images.extend(target.clone());
|
||||
}
|
||||
calls.push((sheet, rubric::state(sheet, &brief), rubric::questions(sheet), images));
|
||||
}
|
||||
if hero.is_file() {
|
||||
calls.push(("blind", "One frame. Judge only what is in the pixels.".into(), rubric::blind(), vec![hero.clone()]));
|
||||
}
|
||||
if dry {
|
||||
let shown: Vec<Value> = calls.iter().map(|(s, st, q, im)| json!({"sheet": s, "state": st, "questions": q, "images": im.iter().map(|p| p.display().to_string()).collect::<Vec<_>>()})).collect();
|
||||
return Ok(serde_json::to_string_pretty(&json!({"would_ask": shown})).unwrap_or_default());
|
||||
}
|
||||
let mut scores = serde_json::Map::new();
|
||||
let mut defects = Vec::new();
|
||||
let mut photo = Value::Null;
|
||||
let mut cost = 0.0;
|
||||
for (sheet, st, q, images) in &calls {
|
||||
let (answers, c) = clef::ask(st, q, images)?;
|
||||
cost += c;
|
||||
if *sheet == "blind" {
|
||||
photo = json!(answers["photo"]["noul"].as_f64().map(|p| (p * 1000.0).round() / 1000.0));
|
||||
continue;
|
||||
}
|
||||
let (s, d) = rubric::read(&answers);
|
||||
scores.extend(s);
|
||||
defects.extend(d.into_iter().map(|mut x| {
|
||||
x["sheet"] = json!(sheet);
|
||||
x
|
||||
}));
|
||||
}
|
||||
let raw = scores.clone();
|
||||
let cal = eye::calibration();
|
||||
if let Some(c) = &cal {
|
||||
eye::apply(c, &mut scores);
|
||||
}
|
||||
let gating = cal.as_ref().is_some_and(|c| c["gate"] == true);
|
||||
finish(args, &dir, scores, raw, defects, photo, cost, "clef", !gating, json!({"calibrated": cal.is_some()}))
|
||||
}
|
||||
|
||||
/// The defects a judge saw, as raea's one Finding (docs/direction.feature DR3): a blocking one an error and a detail a
|
||||
/// warn, each a level lower from a judge that only advises. A judge sees pictures, not parts: a finding names its
|
||||
/// sheet in its words and is about no entity.
|
||||
pub fn findings(defects: &[Value], by: &str, advice: bool) -> Vec<Finding> {
|
||||
let found = defects.iter().filter(|d| d["present"] == true).map(|d| {
|
||||
let blocking = d["level"] == "blocking";
|
||||
let level = match (blocking, advice) {
|
||||
(true, false) => Level::Error,
|
||||
(true, true) | (false, false) => Level::Warn,
|
||||
(false, true) => Level::Note,
|
||||
};
|
||||
let sheet = d["sheet"].as_str().unwrap_or("");
|
||||
let check = format!("judge.{}", if by == "clef" { d["defect"].as_str().unwrap_or("defect") } else { sheet });
|
||||
let mut f = Finding::new(&check, level, format!("{sheet} sheet: {}", d["asked"].as_str().unwrap_or("")), &format!("raea judge ({by})"));
|
||||
if let Some(p) = d["p"].as_f64() {
|
||||
f = f.measure("p", p, "", Some(0.5));
|
||||
}
|
||||
match d["fix"].as_str() {
|
||||
Some(x) if !x.is_empty() => f.fix(x),
|
||||
_ => f,
|
||||
}
|
||||
});
|
||||
finding::ranked(found.collect())
|
||||
}
|
||||
|
||||
/// The verdict decided in code, written (DIR/judge.json for clef, DIR/judge.BY.json for an agent; every round in the
|
||||
/// log), and said. `advice` marks a judge not yet trusted to gate (clef before calibration).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn finish(args: &[String], dir: &Path, scores: serde_json::Map<String, Value>, raw: serde_json::Map<String, Value>, defects: Vec<Value>, photo: Value, cost: f64, by: &str, advice: bool, extra: Value) -> Result<String, String> {
|
||||
let (pass, why) = rubric::pass(&scores, &defects);
|
||||
let vals: Vec<f64> = scores.values().filter_map(Value::as_f64).collect();
|
||||
let mean = if vals.is_empty() { 0.0 } else { (vals.iter().sum::<f64>() / vals.len() as f64 * 100.0).round() / 100.0 };
|
||||
let model = if by == "clef" { "@cf/cloudflare/clef-omni".to_string() } else { format!("{by} cli") };
|
||||
let found = findings(&defects, by, advice);
|
||||
let mut verdict = json!({"dir": dir.display().to_string(), "by": by, "scores": scores, "raw": raw, "mean": mean, "defects": defects, "photo": photo,
|
||||
"pass": pass, "why": why, "gating": !advice, "cost": cost, "model": model, "findings": found, "count": finding::count(&found)});
|
||||
if let (Some(v), Some(e)) = (verdict.as_object_mut(), extra.as_object()) {
|
||||
v.extend(e.clone());
|
||||
}
|
||||
let log = log_of(dir);
|
||||
let mut rounds: Vec<Value> = std::fs::read_to_string(&log).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).filter(|r: &Value| r["dir"] != verdict["dir"]).collect();
|
||||
rounds.push(verdict.clone());
|
||||
verdict["progress"] = progress(&rounds);
|
||||
let file = if by == "clef" { "judge.json".to_string() } else { format!("judge.{by}.json") };
|
||||
std::fs::write(dir.join(file), serde_json::to_string_pretty(&verdict).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
let lines: Vec<String> = rounds.iter().map(|r| serde_json::to_string(&json!({"dir": r["dir"], "pass": r["pass"], "mean": r["mean"], "defects": r["defects"]})).unwrap_or_default()).collect();
|
||||
std::fs::write(&log, lines.join("\n") + "\n").map_err(|e| e.to_string())?;
|
||||
if cost > 0.0 {
|
||||
let _ = std::process::Command::new("antsy").args(["spend", &format!("{cost:.6}"), "raea judge (clef-omni)"]).output();
|
||||
}
|
||||
if args.iter().any(|a| a == "--json") {
|
||||
return Ok(serde_json::to_string_pretty(&verdict).unwrap_or_default());
|
||||
}
|
||||
let who = if by == "clef" { String::new() } else { format!("({by}) ") };
|
||||
let mut t = vec![format!("{} {who}{}{}", if pass { "PASS" } else { "NOT YET" }, if advice { "(advice: the judge isn't calibrated against your eye yet) " } else { "" }, why.join("; "))];
|
||||
t.push(format!("scores: {}", scores.iter().map(|(k, v)| format!("{k} {v}")).collect::<Vec<_>>().join(", ")));
|
||||
for f in &found {
|
||||
let p = f.measure.as_ref().map(|m| format!(" (p {})", m.value)).unwrap_or_default();
|
||||
t.push(format!(" {}{p}", f.line()));
|
||||
}
|
||||
let p = &verdict["progress"];
|
||||
t.push(format!("round {}: {} passes in a row{}{}; ${cost:.4}", p["rounds"], p["passesInARow"], if p["done"] == true { ", done" } else { "" }, if p["stall"] == true { ", stalled: change the approach for the part, not the dose" } else { "" }));
|
||||
t.push(format!("raea judge: {}", finding::count(&found)));
|
||||
Ok(t.join("\n"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,133 @@
|
||||
//! The frozen rubric (the 11-06 prompt pack, section 3, in clef-omni's native question types): a 0-10 score per category
|
||||
//! as an ordered six-level rubric, and every named defect as a yes/no question, so a defect is a probability rather
|
||||
//! than prose. clef-omni answers questions, not essays; the defects it can name are the ones asked. Nothing here says
|
||||
//! where the pass line is (the loop decides, in code: `pass`).
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The six levels each category is scored on, lowest first (clef's `score`: the probability-weighted level), read as
|
||||
/// 0, 2, 4, 6, 8, 10.
|
||||
fn levels(what: &str) -> Value {
|
||||
json!([
|
||||
format!("0: no {what} to speak of; broken or missing"),
|
||||
format!("2: {what} is crude: primitives and placeholders"),
|
||||
format!("4: {what} is a rough draft, plainly unfinished"),
|
||||
format!("6: {what} is a believable draft"),
|
||||
format!("8: {what} is a production base an artist would accept"),
|
||||
format!("10: {what} is indistinguishable from the real thing"),
|
||||
])
|
||||
}
|
||||
|
||||
/// (id, the sheet it is judged on, the question)
|
||||
pub const SCORES: [(&str, &str, &str); 7] = [
|
||||
("composition", "colour", "Composition: the camera, framing and layout; every major object's position and scale against the brief's space."),
|
||||
("form", "clay", "Form, judged on these grey clay tiles: silhouettes read at a glance, parts have real thickness, nothing blobby or melted, no primitive standing in for a thing, repeated things vary."),
|
||||
("assembly", "clay", "Assembly, judged on these grey clay tiles: nothing floats, sinks, pokes through or rests on the wrong thing; joints touch; the low tile shows the feet resting."),
|
||||
("materials", "colour", "Materials: every surface reads as its real material with wear where use puts it; nothing a flat default colour; glass is glass."),
|
||||
("light", "colour", "Light: motivated by the place's own sources; exposure and contrast believable; no surface implausibly dark or bright."),
|
||||
("detail", "colour", "Detail: close surfaces hold real geometry or texture at that distance, not smooth stand-ins; printed matter reads."),
|
||||
("world", "colour", "World: one coherent real place matching the brief; nothing off-era, no real brands, nothing invented beyond the brief."),
|
||||
];
|
||||
|
||||
/// (id, sheet, the yes/no question, blocking when yes)
|
||||
pub const DEFECTS: [(&str, &str, &str, bool); 12] = [
|
||||
("floating", "clay", "Does any object float above the surface it should rest on, with a visible gap under it?", true),
|
||||
("intersecting", "clay", "Does any object pass through another object, a wall or the floor?", true),
|
||||
("blobby", "clay", "Is any object a blobby, melted or lumpy shape where the real thing has crisp form?", true),
|
||||
("stand_in", "clay", "Is any object just a plain box, ball or cylinder standing in for a more detailed real thing?", true),
|
||||
("clones", "clay", "Are several copies of one thing identical and evenly spaced in an obviously artificial way?", false),
|
||||
("flat_colour", "colour", "Is any large surface a flat, uniform default colour with no texture, variation or wear?", true),
|
||||
("plastic", "colour", "Do the surfaces look like shiny uniform plastic or CG rather than their real materials?", true),
|
||||
("garbled_text", "colour", "Is any visible text garbled, tiled or unreadable where it should read?", false),
|
||||
("too_dark", "colour", "Is the scene so dark that important objects are hard to see?", true),
|
||||
("too_bright", "colour", "Is the scene washed out, with large areas blown to white?", true),
|
||||
("brands", "colour", "Is a real brand name or logo visible?", true),
|
||||
("not_doing", "colour", "Does the scene show anything the brief says it must not contain?", true),
|
||||
];
|
||||
|
||||
/// The paragraph clef reads before the sheet: what it is looking at, and the brief's words (no code, no log, no line).
|
||||
pub fn state(sheet: &str, brief: &Value) -> String {
|
||||
let look = brief["look"].as_str().unwrap_or("");
|
||||
let logline = brief["logline"].as_str().unwrap_or("");
|
||||
let not: Vec<&str> = brief["notDoing"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
|
||||
let tiles = "six tiles of one 3D scene, left to right and top to bottom: hero (the shot's own camera), front, right, top, iso, and low (a camera 0.3 m off the floor)";
|
||||
let what = if sheet == "clay" { format!("The image is {tiles}, rendered in clay: every surface plain grey, so only form and assembly show.") } else { format!("The image is {tiles}, in full colour.") };
|
||||
let target = if sheet == "colour" { " A second image, when given, is the target picture the scene should read as." } else { "" };
|
||||
let mut s = format!("{what}{target} Judge only what is in the pixels, as the person who will use the scene would.");
|
||||
if !logline.is_empty() || !look.is_empty() {
|
||||
s.push_str(&format!(" The brief: {logline} Look: {look}."));
|
||||
}
|
||||
if !not.is_empty() {
|
||||
s.push_str(&format!(" The scene must not contain: {}.", not.join("; ")));
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
/// The questions for one sheet, by id.
|
||||
pub fn questions(sheet: &str) -> Value {
|
||||
let mut q = serde_json::Map::new();
|
||||
for (id, on, ask) in SCORES {
|
||||
if on == sheet {
|
||||
q.insert(format!("score_{id}"), json!({"type": "score", "instructions": ask, "criteria": levels(id)}));
|
||||
}
|
||||
}
|
||||
for (id, on, ask, _) in DEFECTS {
|
||||
if on == sheet {
|
||||
q.insert(format!("defect_{id}"), json!({"type": "noul", "instructions": ask}));
|
||||
}
|
||||
}
|
||||
Value::Object(q)
|
||||
}
|
||||
|
||||
/// The blind read on the hero tile alone: is this a photograph (reported, never gated, until calibrated).
|
||||
pub fn blind() -> Value {
|
||||
json!({"photo": {"type": "noul", "instructions": "Is this a photograph of a real place, rather than a computer render?"}})
|
||||
}
|
||||
|
||||
/// clef's answers read into scores (0-10) and defects (probability of yes, blocking ones flagged).
|
||||
pub fn read(answers: &Value) -> (serde_json::Map<String, Value>, Vec<Value>) {
|
||||
let mut scores = serde_json::Map::new();
|
||||
let mut defects = Vec::new();
|
||||
for (id, _, _) in SCORES {
|
||||
if let Some(a) = answers.get(format!("score_{id}")) {
|
||||
let level = a["score"].as_f64().unwrap_or(0.0);
|
||||
scores.insert(id.into(), json!((level * 2.0 * 100.0).round() / 100.0));
|
||||
}
|
||||
}
|
||||
for (id, _, ask, blocking) in DEFECTS {
|
||||
if let Some(a) = answers.get(format!("defect_{id}")) {
|
||||
let p = a["noul"].as_f64().unwrap_or(0.0);
|
||||
defects.push(json!({"defect": id, "p": (p * 1000.0).round() / 1000.0, "present": p >= 0.5, "level": if blocking { "blocking" } else { "detail" }, "asked": ask}));
|
||||
}
|
||||
}
|
||||
(scores, defects)
|
||||
}
|
||||
|
||||
/// The loop's pass, in code: no blocking defect present, the lowest score 6 or more and the mean 7 or more (raea's
|
||||
/// 0-10 scale; the prompt pack's line). Scores mapped by a calibration first, when there is one.
|
||||
pub fn pass(scores: &serde_json::Map<String, Value>, defects: &[Value]) -> (bool, Vec<String>) {
|
||||
let vals: Vec<f64> = scores.values().filter_map(Value::as_f64).collect();
|
||||
let mut why = Vec::new();
|
||||
let blocking = blocking(defects);
|
||||
if !blocking.is_empty() {
|
||||
why.push(format!("blocking: {}", blocking.join(", ")));
|
||||
}
|
||||
let min = vals.iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
let mean = if vals.is_empty() { 0.0 } else { vals.iter().sum::<f64>() / vals.len() as f64 };
|
||||
if vals.len() < SCORES.len() {
|
||||
why.push(format!("only {} of {} categories scored", vals.len(), SCORES.len()));
|
||||
}
|
||||
if min < 6.0 {
|
||||
let low: Vec<String> = scores.iter().filter(|(_, v)| v.as_f64().is_some_and(|x| x < 6.0)).map(|(k, _)| k.clone()).collect();
|
||||
why.push(format!("below a draft: {}", low.join(", ")));
|
||||
}
|
||||
if mean < 7.0 {
|
||||
why.push("the whole is under a production base".into());
|
||||
}
|
||||
(why.is_empty(), why)
|
||||
}
|
||||
|
||||
/// The blocking defects present, by name.
|
||||
pub fn blocking(defects: &[Value]) -> Vec<&str> {
|
||||
defects.iter().filter(|d| d["present"] == true && d["level"] == "blocking").filter_map(|d| d["defect"].as_str()).collect()
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
fn scores(v: f64) -> serde_json::Map<String, Value> {
|
||||
rubric::SCORES.iter().map(|s| (s.0.to_string(), json!(v))).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_pass_is_code_and_a_blocking_defect_holds_it() {
|
||||
assert!(rubric::pass(&scores(7.5), &[]).0);
|
||||
assert!(!rubric::pass(&scores(6.5), &[]).0, "mean under 7");
|
||||
let mut s = scores(8.0);
|
||||
s.insert("form".into(), json!(5.0));
|
||||
let (ok, why) = rubric::pass(&s, &[]);
|
||||
assert!(!ok && why.iter().any(|w| w.contains("form")));
|
||||
let d = vec![json!({"defect": "floating", "present": true, "level": "blocking"})];
|
||||
assert!(!rubric::pass(&scores(9.0), &d).0);
|
||||
// the questions hold no pass line
|
||||
let q = format!("{}{}", rubric::questions("colour"), rubric::questions("clay"));
|
||||
assert!(!q.contains("mean") && !q.contains(">= 6"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn answers_are_read_and_rounds_say_done_and_stall() {
|
||||
let a = json!({"score_form": {"score": 3.5}, "defect_floating": {"noul": 0.8}});
|
||||
let (s, d) = rubric::read(&a);
|
||||
assert_eq!(s["form"], 7.0);
|
||||
assert_eq!(d[0]["present"], true);
|
||||
let r = |p: bool, m: f64| json!({"pass": p, "mean": m, "defects": []});
|
||||
assert_eq!(progress(&[r(false, 5.0), r(true, 7.2), r(true, 7.4)])["done"], true);
|
||||
assert_eq!(progress(&[r(false, 5.0), r(false, 5.3), r(false, 5.6)])["stall"], true);
|
||||
assert_eq!(progress(&[r(false, 4.0), r(false, 5.3), r(false, 6.1)])["stall"], false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calibration_maps_a_lenient_judge_onto_the_eye() {
|
||||
// the judge says 8 to everything the eye gives 5, and 9 to what the eye gives 8
|
||||
let row = |j: f64, e: f64, p: bool| json!({"judge": scores(j), "eye": scores(e), "eye_pass": p, "defects": []});
|
||||
let rows: Vec<Value> = (0..12).map(|i| if i % 2 == 0 { row(8.0, 5.0, false) } else { row(9.0, 8.0, true) }).collect();
|
||||
let cal = eye::fit_rows(&rows);
|
||||
assert_eq!(cal["agreement"], 1.0);
|
||||
assert_eq!(cal["gate"], true);
|
||||
assert!((cal["maps"]["form"]["a"].as_f64().unwrap() - 3.0).abs() < 1e-6);
|
||||
let few = eye::fit_rows(&rows[..4]);
|
||||
assert_eq!(few["gate"], false, "too few rounds to gate");
|
||||
// an eye that failed everything agrees with a judge that fails everything, which proves nothing
|
||||
let fails: Vec<Value> = (0..12).map(|_| row(3.0, 2.0, false)).collect();
|
||||
let all_fail = eye::fit_rows(&fails);
|
||||
assert_eq!(all_fail["agreement"], 1.0);
|
||||
assert_eq!(all_fail["gate"], false, "no pass among the eye's rounds");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_agent_verdict_is_read_from_the_end_of_its_thinking() {
|
||||
// an agent thinks aloud, may draft the JSON twice, and ends with the one it means
|
||||
let text = r#"• Looking at the sheets... draft: {"scores": {"form": 1}} then the answer:
|
||||
{"blind": {"place": "office", "objects": [], "photo": "no", "tells": []},
|
||||
"scores": {"composition": 6, "form": 5.5, "assembly": 7, "materials": 4, "light": 6, "detail": 5, "world": 6, "vibes": 9},
|
||||
"defects": [{"tile": "iso", "where": "left", "wrong": "the desks are plain boxes", "real": "a desk has legs", "fix": "model legs", "level": "blocking"},
|
||||
{"tile": "low", "wrong": "", "level": "detail"}],
|
||||
"show_as_is": "no"}"#;
|
||||
let v = crate::agent::last_verdict(text).unwrap();
|
||||
let (scores, defects, photo) = crate::agent::read(&v);
|
||||
assert_eq!(scores.len(), 7, "only the seven categories, each 0-10");
|
||||
assert_eq!(scores["form"], serde_json::json!(5.5));
|
||||
assert_eq!(defects.len(), 1, "a defect with nothing wrong named is dropped");
|
||||
assert_eq!(defects[0]["level"], "blocking");
|
||||
assert_eq!(photo, serde_json::json!(0.0));
|
||||
let (pass, why) = crate::rubric::pass(&scores, &defects);
|
||||
assert!(!pass && why[0].starts_with("blocking"));
|
||||
assert!(crate::agent::last_verdict("no json here").is_none());
|
||||
// what it saw, as Findings (DR3): a gating judge's blocking defect is an error, an advising one's a warn
|
||||
let f = &crate::findings(&defects, "kimi", false)[0];
|
||||
assert_eq!((f.check.as_str(), f.level, f.fix.as_deref(), f.by.as_str()), ("judge.iso", raea_core_facts::Level::Error, Some("model legs"), "raea judge (kimi)"));
|
||||
assert!(f.says.starts_with("iso sheet: "), "{}", f.says);
|
||||
assert_eq!(crate::findings(&defects, "kimi", true)[0].level, raea_core_facts::Level::Warn);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
[package]
|
||||
name = "raea-app-lightbake"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea make bake light: bounce light baked into lightmaps on raea's own ray tracer, and the bar it is held to against Cycles (docs/bake.feature)"
|
||||
|
||||
[dependencies]
|
||||
# the frames' distance in stops, as raea light check measures it (LT1)
|
||||
raea-light = { path = "../../engine/light" }
|
||||
# the CLI's flag reader and result type
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
# raea's own files (the test set, the Blender library scripts) and the home folder
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
image = { version = "0.25", default-features = false, features = ["png"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
# wait4: a step's peak memory
|
||||
libc = "0.2"
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"about": "the bake's test set (docs/bake.feature BK0), for `raea make bake light --compare DIR`: each set's Cycles still (blender/look.py, given the composition's own sky, tone and lens) and Cycles bake (blender/lightbake.py), and raea's frames beside them",
|
||||
"sets": [
|
||||
{ "name": "table", "dir": "bench/bake", "file": "table.tsx", "composition": "table", "cycles": ["table-cycles.tsx", "table-cycles"], "bar": true, "texels": 128,
|
||||
"look": ["--hdri", "media/kloofendal_48d_partly_cloudy_puresky_1k.hdr", "--strength", "0.25", "--rotation", "0.6", "--tone", "agx", "--exposure", "-0.8", "--focus", "2.5", "--fstop", "2.8", "--size", "1280x720"] },
|
||||
{ "name": "cornell", "dir": "bench/bake", "file": "cornell.tsx", "composition": "cornell", "cycles": ["cornell-cycles.tsx", "cornell-cycles"], "texels": 128,
|
||||
"look": ["--tone", "agx", "--exposure", "0", "--size", "1280x720"] },
|
||||
{ "name": "window", "dir": "bench/bake", "file": "window.tsx", "composition": "window", "cycles": ["window-cycles.tsx", "window-cycles"], "texels": 64,
|
||||
"look": ["--hdri", "media/kloofendal_48d_partly_cloudy_puresky_1k.hdr", "--strength", "0.25", "--rotation", "0.6", "--tone", "agx", "--exposure", "1.5", "--size", "1280x720"] },
|
||||
{ "name": "atelier", "dir": "~/Studio/raea/projects/atelier", "file": "compositions/atelier.tsx", "composition": "set", "texels": 64, "reference": false,
|
||||
"why": "a test agent's project, still being built; its Manifold solids stop `raea blender open` (filed with raea bug), so its Blender bake runs through its own tools/bake.sh. It joins at BK5, with that bake as the comparison" }
|
||||
]
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
//! One set against Cycles (docs/bake.feature BK0): its Cycles still (blender/look.py) and Cycles bake
|
||||
//! (blender/lightbake.py), kept in DIR/NAME until the set or the samples change, then raea's frames beside them: the set
|
||||
//! unbaked, the set with Cycles' maps, and the set with raea's own bake. A frame is measured against the Cycles still by
|
||||
//! its RMSE (sRGB 0..1 over every pixel and channel, as docs/blender-research.md's table) and in stops (raea light
|
||||
//! check's distance); a lightmap against Cycles' in stops, texel by texel on the same UVs (map_stops).
|
||||
|
||||
use crate::{key, library, run, Ran, Set};
|
||||
use raea_runtime_bundle::R;
|
||||
use serde_json::{json, Value};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// The bar (BK0): the frame with raea's bake within this RMSE of the Cycles still on the table set (lightbake.py's gives
|
||||
/// 0.040), no mesh's map off by more than a third of a stop on average, in under a quarter of lightbake.py's time.
|
||||
pub const BAR_RMSE: f64 = 0.045;
|
||||
pub const BAR_STOPS: f64 = 1.0 / 3.0;
|
||||
pub const BAR_TIME: f64 = 0.25;
|
||||
|
||||
/// The set's Cycles references, made: the export, look.py's still at `samples` (OUT/cycles.png), lightbake.py's bake at
|
||||
/// `samples` into the set's media/baked/NAME/, which the set's `cycles` composition reads.
|
||||
fn reference(set: &Set, samples: u32, out: &Path, baked: &Path) -> R<Value> {
|
||||
let bl = out.join("bl");
|
||||
let _ = std::fs::remove_dir_all(&bl);
|
||||
let _ = std::fs::remove_dir_all(baked);
|
||||
let stem = Path::new(&set.file).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_default();
|
||||
let open = run(&set.dir, &["blender".into(), "open".into(), set.file.clone(), "--no-window".into(), "-o".into(), format!("{}", bl.display())], &out.join("open.log"))?;
|
||||
let (blend, look) = (bl.join(format!("{stem}.blend")), bl.join("look.blend"));
|
||||
let mut a = vec!["blender".into(), "run".into(), format!("{}", library("look.py")?.display()), format!("{}", blend.display()), format!("{}", look.display())];
|
||||
a.extend(set.look.iter().cloned());
|
||||
a.extend(["--engine".into(), "cycles".into(), "--samples".into(), samples.to_string(), "--still".into(), format!("{}", out.join("cycles.png").display())]);
|
||||
let still = run(&set.dir, &a, &out.join("look.log"))?;
|
||||
let a = vec!["blender".into(), "run".into(), format!("{}", library("lightbake.py")?.display()), format!("{}", look.display()), format!("{}", baked.join("set.glb").display()), "--samples".into(), samples.to_string(), "--texels".into(), set.texels.to_string()];
|
||||
let bake = run(&set.dir, &a, &out.join("lightbake.log"))?;
|
||||
Ok(json!({ "export": open.json(), "still": still.json(), "lightbake": bake.json() }))
|
||||
}
|
||||
|
||||
/// Frame 0 of `composition` in `file`, drawn by raea into OUT/LABEL/: the picture and what it cost.
|
||||
fn frame(set: &Set, file: &str, composition: &str, out: &Path, label: &str) -> R<(PathBuf, Ran)> {
|
||||
let dir = out.join(label);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?;
|
||||
let a = ["render", file, "--composition", composition, "--at", "0", "-o", &format!("{}/", dir.display())].map(String::from);
|
||||
let ran = run(&set.dir, &a, &out.join(format!("{label}.log")))?;
|
||||
Ok((dir.join("frame-00000.png"), ran))
|
||||
}
|
||||
|
||||
fn round(x: f64) -> f64 {
|
||||
(x * 10000.0).round() / 10000.0
|
||||
}
|
||||
|
||||
/// RMSE of two pictures the same size, sRGB 0..1 over every pixel and channel.
|
||||
pub fn rmse(a: &Path, b: &Path) -> R<f64> {
|
||||
let load = |p: &Path| image::open(p).map(|i| i.to_rgb8()).map_err(|e| format!("{}: {e}", p.display()));
|
||||
let (a, b) = (load(a)?, load(b)?);
|
||||
if a.dimensions() != b.dimensions() {
|
||||
return Err(format!("sizes differ: {:?} against {:?}", a.dimensions(), b.dimensions()));
|
||||
}
|
||||
let sum: f64 = a.as_raw().iter().zip(b.as_raw()).map(|(x, y)| ((*x as f64 - *y as f64) / 255.0).powi(2)).sum();
|
||||
Ok((sum / a.as_raw().len().max(1) as f64).sqrt())
|
||||
}
|
||||
|
||||
/// A raea frame against the Cycles still: RMSE, and the mean and worst tile in stops.
|
||||
fn measure(got: &(PathBuf, Ran), cycles: &Path) -> R<Value> {
|
||||
let d = raea_light::metric::distance(&raea_light::metric::load(&got.0)?, &raea_light::metric::load(cycles)?)?;
|
||||
Ok(json!({ "rmse": round(rmse(&got.0, cycles)?), "mean_stops": round(d.mean as f64), "worst_stops": round(d.worst as f64), "render": got.1.json() }))
|
||||
}
|
||||
|
||||
/// A lightmap against another on the same UVs, each scaled by its lightmap_exposure: over the texels both cover, the
|
||||
/// mean distance in stops, the mean signed (brighter is positive), and the worst 8 x 8 tile's mean distance.
|
||||
pub fn map_stops(a: &Path, a_exposure: f64, b: &Path, b_exposure: f64) -> R<Value> {
|
||||
let lum = |p: &Path, k: f64| -> R<(u32, u32, Vec<f64>)> {
|
||||
let i = image::open(p).map_err(|e| format!("{}: {e}", p.display()))?.to_rgb32f();
|
||||
Ok((i.width(), i.height(), i.pixels().map(|q| k * (0.2126 * q[0] as f64 + 0.7152 * q[1] as f64 + 0.0722 * q[2] as f64)).collect()))
|
||||
};
|
||||
let ((w, h, a), (bw, bh, b)) = (lum(a, a_exposure)?, lum(b, b_exposure)?);
|
||||
if (w, h) != (bw, bh) {
|
||||
return Err(format!("map sizes differ: {w}x{h} against {bw}x{bh}"));
|
||||
}
|
||||
let (mut sum, mut signed, mut n) = (0.0, 0.0, 0usize);
|
||||
let mut tiles = vec![(0.0, 0usize); w.div_ceil(8) as usize * h.div_ceil(8) as usize];
|
||||
for (i, (x, y)) in a.iter().zip(&b).enumerate() {
|
||||
if *x <= 0.0 || *y <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
let st = (x / y).log2();
|
||||
(sum, signed, n) = (sum + st.abs(), signed + st, n + 1);
|
||||
let t = &mut tiles[(i / w as usize / 8) * w.div_ceil(8) as usize + (i % w as usize) / 8];
|
||||
*t = (t.0 + st.abs(), t.1 + 1);
|
||||
}
|
||||
let worst = tiles.iter().filter(|t| t.1 >= 32).map(|t| t.0 / t.1 as f64).fold(0.0, f64::max);
|
||||
let k = n.max(1) as f64;
|
||||
Ok(json!({ "texels": n, "mean_stops": round(sum / k), "bias_stops": round(signed / k), "worst_tile_stops": round(worst) }))
|
||||
}
|
||||
|
||||
/// Whether a set's numbers meet the bar, and why not.
|
||||
fn bar(r: &Value) -> Value {
|
||||
let f = &r["frames"]["raea-bake"];
|
||||
if f["made"] == json!(false) {
|
||||
return json!({ "met": false, "why": f["why"] });
|
||||
}
|
||||
let rmse = f["rmse"].as_f64().is_some_and(|x| x <= BAR_RMSE);
|
||||
let meshes = r["meshes"].as_array().is_some_and(|m| m.iter().all(|m| m["raea"]["mean_stops"].as_f64().is_some_and(|x| x <= BAR_STOPS)));
|
||||
let time = match (f["bake"]["seconds"].as_f64(), r["reference"]["lightbake"]["seconds"].as_f64()) {
|
||||
(Some(a), Some(b)) => a < b * BAR_TIME,
|
||||
_ => false,
|
||||
};
|
||||
json!({ "met": rmse && meshes && time, "rmse": rmse, "meshes": meshes, "time": time })
|
||||
}
|
||||
|
||||
pub fn set(set: &Set, samples: u32, out: &Path, fresh: bool) -> R<Value> {
|
||||
std::fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let mut r = json!({ "name": set.name, "samples": samples });
|
||||
if let Err(why) = &set.reference {
|
||||
r["reference"] = json!({ "made": false, "why": why });
|
||||
return Ok(r);
|
||||
}
|
||||
let (baked, cycles, made) = (set.dir.join("media/baked").join(&set.name), out.join("cycles.png"), out.join("made.json"));
|
||||
let key = key(set, samples);
|
||||
let kept = std::fs::read_to_string(&made).ok().and_then(|t| serde_json::from_str::<Value>(&t).ok());
|
||||
r["reference"] = match kept.filter(|k| !fresh && k["key"] == json!(key) && cycles.is_file() && baked.join("set.lightmaps.json").is_file()) {
|
||||
Some(k) => {
|
||||
let mut v = k["reference"].clone();
|
||||
v["kept"] = json!(true);
|
||||
v
|
||||
}
|
||||
None => {
|
||||
let v = reference(set, samples, out, &baked)?;
|
||||
std::fs::write(&made, json!({ "key": key, "reference": v }).to_string()).map_err(|e| e.to_string())?;
|
||||
v
|
||||
}
|
||||
};
|
||||
r["frames"]["raea"] = measure(&frame(set, &set.file, &set.composition, out, "raea")?, &cycles)?;
|
||||
if let Some((file, comp)) = &set.cycles {
|
||||
r["frames"]["cycles-bake"] = measure(&frame(set, file, comp, out, "cycles-bake")?, &cycles)?;
|
||||
}
|
||||
// rask: BK5 raea's own bake of the set (<LightBake>): its frame against the Cycles still, its time and memory, and each mesh's map against Cycles' by map_stops on lightbake.py's UVs
|
||||
r["frames"]["raea-bake"] = json!({ "made": false, "why": "raea's bake isn't built yet (BK1-BK5)" });
|
||||
let maps: Value = std::fs::read_to_string(baked.join("set.lightmaps.json")).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default();
|
||||
r["meshes"] = json!(maps["meshes"].as_array().into_iter().flatten().map(|m| json!({ "mesh": m["mesh"], "size": m["size"], "cycles_exposure": m["lightmap_exposure"] })).collect::<Vec<_>>());
|
||||
if set.bar {
|
||||
r["bar"] = bar(&r);
|
||||
}
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
/// The table a person reads: a line a set and frame, then the Cycles bake's cost and the bar.
|
||||
pub fn table(reports: &[Value]) -> String {
|
||||
let mut t = format!("{:<10} {:<12} {:>7} {:>7} {:>7}\n", "set", "frame", "rmse", "stops", "worst");
|
||||
for r in reports {
|
||||
let name = r["name"].as_str().unwrap_or("");
|
||||
if r["reference"]["made"] == json!(false) {
|
||||
t += &format!("{name:<10} (no reference: {})\n", r["reference"]["why"].as_str().unwrap_or(""));
|
||||
continue;
|
||||
}
|
||||
for (label, f) in r["frames"].as_object().into_iter().flatten() {
|
||||
let n = |k: &str| match f[k].as_f64() {
|
||||
Some(x) => format!("{x:.4}"),
|
||||
None => "-".into(),
|
||||
};
|
||||
let why = f["why"].as_str().map(|w| format!(" ({w})")).unwrap_or_default();
|
||||
t += &format!("{name:<10} {label:<12} {:>7} {:>7} {:>7}{why}\n", n("rmse"), n("mean_stops"), n("worst_stops"));
|
||||
}
|
||||
let (lb, st) = (&r["reference"]["lightbake"], &r["reference"]["still"]);
|
||||
t += &format!("{name:<10} Cycles at {} samples: lightbake.py {}s (peak {} MB) for {} meshes, the still {}s\n", r["samples"], lb["seconds"], lb["peak_mb"], r["meshes"].as_array().map_or(0, Vec::len), st["seconds"]);
|
||||
if let Some(b) = r.get("bar") {
|
||||
t += &format!("{name:<10} bar: {}\n", if b["met"] == json!(true) { "met".to_string() } else { format!("not met: {}", b["why"].as_str().unwrap_or("see report.json")) });
|
||||
}
|
||||
}
|
||||
t
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn png16(path: &Path, w: u32, h: u32, v: u16) {
|
||||
image::ImageBuffer::<image::Rgb<u16>, _>::from_pixel(w, h, image::Rgb([v, v, v])).save(path).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_map_twice_as_bright_is_one_stop_off_and_its_exposure_brings_it_back() {
|
||||
let d = std::env::temp_dir().join(format!("raea-lightbake-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
let (a, b) = (d.join("a.png"), d.join("b.png"));
|
||||
png16(&a, 16, 16, 40000);
|
||||
png16(&b, 16, 16, 20000);
|
||||
let off = map_stops(&a, 1.0, &b, 1.0).unwrap();
|
||||
assert_eq!((off["mean_stops"].as_f64(), off["bias_stops"].as_f64(), off["texels"].as_u64()), (Some(1.0), Some(1.0), Some(256)));
|
||||
assert_eq!(map_stops(&a, 1.0, &b, 2.0).unwrap()["mean_stops"].as_f64(), Some(0.0));
|
||||
assert!(rmse(&a, &b).unwrap() > 0.3 && rmse(&a, &a).unwrap() == 0.0);
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_bar_is_unmet_until_raeas_bake_exists() {
|
||||
let r = json!({ "frames": { "raea-bake": { "made": false, "why": "not yet" } } });
|
||||
assert_eq!(bar(&r)["met"], json!(false));
|
||||
let r = json!({ "frames": { "raea-bake": { "rmse": 0.04, "bake": { "seconds": 4.0 } } }, "meshes": [{ "raea": { "mean_stops": 0.2 } }], "reference": { "lightbake": { "seconds": 20.0 } } });
|
||||
assert_eq!(bar(&r)["met"], json!(true));
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
//! `raea make bake light EDIT.tsx [--composition ID] [--samples N] [--compare DIR]` (docs/bake.feature): raea's own bake of a
|
||||
//! composition's static parts (BK1-BK5), and the bar it is held to (BK0). `--compare DIR` runs the test set (sets.json)
|
||||
//! through Cycles (blender/look.py's still and blender/lightbake.py's bake, both at --samples, 1024 by default) and
|
||||
//! through raea, then writes DIR/report.json and a table: each frame's RMSE and stops against the Cycles still, each
|
||||
//! mesh's lightmap against Cycles', and each bake's time and peak memory.
|
||||
//!
|
||||
//! A set in sets.json: { "name", "dir" (under raea's home, or ~/...), "file", "composition", "cycles": [file,
|
||||
//! composition] (the set drawn with lightbake.py's maps), "look": [look.py's flags, the composition's own values],
|
||||
//! "texels" (lightbake.py's texels a metre), "bar": true (the set the bar is read on), "reference": false and "why" (a
|
||||
//! set whose references can't be made yet) }.
|
||||
|
||||
pub mod compare;
|
||||
|
||||
use raea_runtime_bundle::{flag, R};
|
||||
use serde_json::{json, Value};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub const USAGE: &str = "raea make bake light EDIT.tsx [--composition ID] [--samples N] | raea make bake light --compare DIR [--sets FILE] [--set NAME] [--samples N] [--fresh] (bounce light baked into lightmaps on raea's ray tracer; --compare measures the test set against Cycles' bake and still, docs/bake.feature)";
|
||||
|
||||
/// One set of the test set, as sets.json lists it.
|
||||
pub struct Set {
|
||||
pub name: String,
|
||||
pub dir: PathBuf,
|
||||
pub file: String,
|
||||
pub composition: String,
|
||||
pub cycles: Option<(String, String)>,
|
||||
pub look: Vec<String>,
|
||||
pub texels: u32,
|
||||
pub bar: bool,
|
||||
pub reference: Result<(), String>,
|
||||
}
|
||||
|
||||
fn home_path(p: &str) -> PathBuf {
|
||||
match (p.strip_prefix("~/"), raea_io_home::user_home()) {
|
||||
(Some(rest), Some(h)) => h.join(rest),
|
||||
_ if Path::new(p).is_absolute() => PathBuf::from(p),
|
||||
_ => raea_io_home::home().join(p),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sets(path: &Path) -> R<Vec<Set>> {
|
||||
let text = std::fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
let v: Value = serde_json::from_str(&text).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
let list = v["sets"].as_array().ok_or(format!("{}: no \"sets\" list", path.display()))?;
|
||||
let strs = |x: &Value| x.as_array().map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect::<Vec<_>>()).unwrap_or_default();
|
||||
list.iter()
|
||||
.map(|s| {
|
||||
let text = |k: &str| match &s[k] {
|
||||
Value::String(v) => Ok(v.clone()),
|
||||
_ => Err(format!("{}: a set without \"{k}\"", path.display())),
|
||||
};
|
||||
let cycles = match strs(&s["cycles"]).as_slice() {
|
||||
[file, comp] => Some((file.clone(), comp.clone())),
|
||||
_ => None,
|
||||
};
|
||||
let reference = if s["reference"] == json!(false) { Err(s["why"].as_str().unwrap_or("not yet").to_string()) } else { Ok(()) };
|
||||
Ok(Set { name: text("name")?, dir: home_path(&text("dir")?), file: text("file")?, composition: text("composition")?, cycles, look: strs(&s["look"]), texels: s["texels"].as_u64().unwrap_or(128) as u32, bar: s["bar"] == json!(true), reference })
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// What a step cost: its seconds, and its peak memory in MB where the OS reports it (a child's and its children's).
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Ran {
|
||||
pub seconds: f64,
|
||||
pub peak_mb: Option<u64>,
|
||||
}
|
||||
|
||||
impl Ran {
|
||||
pub fn json(&self) -> Value {
|
||||
json!({ "seconds": (self.seconds * 10.0).round() / 10.0, "peak_mb": self.peak_mb })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn wait(child: std::process::Child) -> R<(bool, Option<u64>)> {
|
||||
let (mut status, pid) = (0, child.id() as libc::pid_t);
|
||||
// SAFETY: rusage is plain data, zeroed is a valid value; wait4 reaps the child std spawned and never waited on
|
||||
let mut ru: libc::rusage = unsafe { std::mem::zeroed() };
|
||||
if unsafe { libc::wait4(pid, &mut status, 0, &mut ru) } < 0 {
|
||||
return Err(format!("waiting for {pid}: {}", std::io::Error::last_os_error()));
|
||||
}
|
||||
// ru_maxrss is bytes on macOS, kilobytes elsewhere
|
||||
let kb = if cfg!(target_os = "macos") { ru.ru_maxrss as u64 / 1024 } else { ru.ru_maxrss as u64 };
|
||||
Ok((libc::WIFEXITED(status) && libc::WEXITSTATUS(status) == 0, Some(kb / 1024)))
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn wait(mut child: std::process::Child) -> R<(bool, Option<u64>)> {
|
||||
Ok((child.wait().map_err(|e| e.to_string())?.success(), None))
|
||||
}
|
||||
|
||||
/// This raea with `args` in `dir`, its output into `log`: what it cost, or the log's last lines.
|
||||
pub fn run(dir: &Path, args: &[String], log: &Path) -> R<Ran> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::fs::File::create(log).map_err(|e| format!("{}: {e}", log.display()))?;
|
||||
let err = out.try_clone().map_err(|e| e.to_string())?;
|
||||
let t = std::time::Instant::now();
|
||||
let child = std::process::Command::new(exe).current_dir(dir).args(args).stdout(out).stderr(err).spawn().map_err(|e| e.to_string())?;
|
||||
let (ok, peak_mb) = wait(child)?;
|
||||
let ran = Ran { seconds: t.elapsed().as_secs_f64(), peak_mb };
|
||||
if ok {
|
||||
return Ok(ran);
|
||||
}
|
||||
let text = std::fs::read_to_string(log).unwrap_or_default();
|
||||
let last: Vec<&str> = text.lines().filter(|l| !l.starts_with("Fra:") && l.chars().any(|c| !c.is_whitespace())).rev().take(4).collect();
|
||||
Err(format!("raea {} failed ({}): {}", args.first().map_or("", String::as_str), log.display(), last.into_iter().rev().collect::<Vec<_>>().join(" | ")))
|
||||
}
|
||||
|
||||
/// A set's identity for its kept references: every .tsx in its folder and its parts/, the flags look.py and lightbake.py
|
||||
/// get, and the samples.
|
||||
pub fn key(s: &Set, samples: u32) -> String {
|
||||
let mut h = Sha256::new();
|
||||
for d in [s.dir.clone(), s.dir.join("parts")] {
|
||||
let mut fs: Vec<PathBuf> = std::fs::read_dir(&d).into_iter().flatten().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "tsx")).collect();
|
||||
fs.sort();
|
||||
for f in fs {
|
||||
h.update(f.file_name().unwrap_or_default().as_encoded_bytes());
|
||||
h.update(std::fs::read(&f).unwrap_or_default());
|
||||
}
|
||||
}
|
||||
h.update(format!("{:?} {} {samples}", s.look, s.texels));
|
||||
h.finalize().iter().map(|b| format!("{b:02x}")).collect()
|
||||
}
|
||||
|
||||
/// Where the Blender library scripts are (sdk/guides/craft/bevy/blender), with `name` there, or why not.
|
||||
pub fn library(name: &str) -> R<PathBuf> {
|
||||
let p = raea_io_home::home().join("sdk/guides/craft/bevy/blender").join(name);
|
||||
if p.is_file() { Ok(p) } else { Err(format!("no {} (the Blender library script the Cycles reference is made with)", p.display())) }
|
||||
}
|
||||
|
||||
pub fn cli(args: &[String]) -> R<String> {
|
||||
if args.get(1).map(String::as_str) != Some("light") {
|
||||
return Err(format!("usage: {USAGE}"));
|
||||
}
|
||||
let samples: u32 = flag(args, "--samples").map(|v| v.parse().map_err(|_| format!("--samples {v}: a count of samples a texel"))).transpose()?.unwrap_or(1024);
|
||||
let Some(out) = flag(args, "--compare").map(PathBuf::from) else {
|
||||
// rask: BK5 `raea make bake light EDIT.tsx` bakes a composition's <LightBake> ahead of a render and says what it baked
|
||||
return Err("raea's own bake isn't built yet (docs/bake.feature BK1-BK5); `raea make bake light --compare DIR` measures the test set against Cycles".into());
|
||||
};
|
||||
let list = sets(&flag(args, "--sets").map_or_else(|| raea_io_home::home().join("apps/lightbake/sets.json"), PathBuf::from))?;
|
||||
let only = flag(args, "--set");
|
||||
let fresh = args.iter().any(|a| a == "--fresh");
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let mut reports = Vec::new();
|
||||
for s in list.iter().filter(|s| only.is_none() || only.as_deref() == Some(s.name.as_str())) {
|
||||
eprintln!("raea make bake light: {} ...", s.name);
|
||||
reports.push(compare::set(s, samples, &out.join(&s.name), fresh)?);
|
||||
}
|
||||
if reports.is_empty() {
|
||||
return Err(format!("no set named {}", only.unwrap_or_default()));
|
||||
}
|
||||
let report = json!({ "samples": samples, "sets": reports });
|
||||
let path = out.join("report.json");
|
||||
std::fs::write(&path, serde_json::to_string_pretty(&report).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
Ok(format!("{}raea make bake light: wrote {}", compare::table(&reports), path.display()))
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
[package]
|
||||
name = "raea-app-make"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea make's Rust: a scene, kit or shot goal's asset steps (docs/goal.feature)"
|
||||
|
||||
[dependencies]
|
||||
# the plan: `make` on brief.ts
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# the folder a project lives in
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# a lens's field of view (MK15's lens chart), as the review sheets work it out
|
||||
raea-core-review = { path = "../../core/review" }
|
||||
# the contact sheets: tiles composited, labels drawn in the system's fonts
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
|
||||
resvg = { version = "=0.48.1", default-features = false, features = ["text", "system-fonts"] }
|
||||
dunce = "1"
|
||||
serde_json = "1"
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
//! The plan stop (docs/goal.feature MK18, from AnyScene's endpoint/floorplan.py, MIT): before anything is generated,
|
||||
//! the plan drawn so a person can approve it. A floor plan from above (every object's footprint at its `at`, turned by
|
||||
//! its `rot`, labelled; invented ones dashed, so what came from the reference and what was added are told apart), a
|
||||
//! grey-box blockout of the same plan rendered from the entrance and through `raea render --review`, and the
|
||||
//! reference beside the blockout on one comparison sheet.
|
||||
//!
|
||||
//! raea make blockout [DIR] -> review/plan/floor-plan.png, blockout.tsx, blockout.png, comparison.png, colour/clay sheets
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::goal::{Goal, Object, Origin};
|
||||
|
||||
use crate::sheet::{Tile, esc, sheet, svg_png};
|
||||
use crate::shots::raea;
|
||||
|
||||
/// An object's footprint, metres: [width, depth] (its box, else a square about as wide as it's tall).
|
||||
pub fn footprint(o: &Object) -> [f64; 2] {
|
||||
if let Some([w, d, _]) = o.dims {
|
||||
return [w, d];
|
||||
}
|
||||
let s = o.max.unwrap_or_else(|| o.h.unwrap_or(0.5) * 0.6).max(0.05);
|
||||
[s, s]
|
||||
}
|
||||
|
||||
fn height(o: &Object) -> f64 {
|
||||
o.dims.map(|d| d[2]).or(o.h).unwrap_or(0.05).max(0.01)
|
||||
}
|
||||
|
||||
/// The placed objects and the floor they span: (objects with an `at`, [x0, z0, x1, z1] with half a metre around).
|
||||
pub fn extent(m: &Goal) -> (Vec<&Object>, [f64; 4]) {
|
||||
let placed: Vec<&Object> = m.objects.iter().filter(|o| o.at.is_some()).collect();
|
||||
let mut b = [0.0f64, 0.0, 1.0, 1.0];
|
||||
for o in &placed {
|
||||
let at = o.at.unwrap();
|
||||
let [w, d] = footprint(o);
|
||||
let r = 0.5 * (w * w + d * d).sqrt();
|
||||
b = [b[0].min(at[0] - r), b[1].min(at[2] - r), b[2].max(at[0] + r), b[3].max(at[2] + r)];
|
||||
}
|
||||
(placed, [b[0] - 0.5, b[1] - 0.5, b[2] + 0.5, b[3] + 0.5])
|
||||
}
|
||||
|
||||
/// The floor plan as SVG: the entrance (z = 0) at the bottom, a metre grid, each footprint turned and labelled.
|
||||
pub fn floor_svg(m: &Goal) -> Result<String, String> {
|
||||
let (placed, [x0, z0, x1, z1]) = extent(m);
|
||||
if placed.is_empty() {
|
||||
return Err("raea make blockout: no object has an `at` (where it stands, in metres: x right, z away from the entrance)".into());
|
||||
}
|
||||
let px = (1400.0 / (x1 - x0).max(z1 - z0)).min(260.0);
|
||||
let (w, h) = (((x1 - x0) * px).ceil() as u32 + 40, ((z1 - z0) * px).ceil() as u32 + 130);
|
||||
// text sized to the plan, so it still reads once the plan is a third of a comparison sheet
|
||||
let t = (w as f64 * 0.02).max(16.0);
|
||||
// plan x right, z away from the entrance: up the page
|
||||
let sx = |x: f64| (x - x0).mul_add(px, 20.0);
|
||||
let sy = |z: f64| 70.0 + (z1 - z) * px;
|
||||
let mut s = format!("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{w}\" height=\"{h}\"><rect width=\"100%\" height=\"100%\" fill=\"#f4f2ee\"/>");
|
||||
s += &format!("<text x=\"20\" y=\"{:.0}\" font-size=\"{:.0}\" font-weight=\"bold\" fill=\"#222\">Floor plan: {} objects (solid: from the reference; dashed: invented)</text>", t * 1.6, t * 1.1, placed.len());
|
||||
let mut g = x0.ceil();
|
||||
while g <= x1 {
|
||||
s += &format!("<line x1=\"{0:.1}\" y1=\"{1:.1}\" x2=\"{0:.1}\" y2=\"{2:.1}\" stroke=\"#dedad2\" stroke-width=\"1\"/>", sx(g), sy(z1), sy(z0));
|
||||
g += 1.0;
|
||||
}
|
||||
let mut g = z0.ceil();
|
||||
while g <= z1 {
|
||||
s += &format!("<line x1=\"{1:.1}\" y1=\"{0:.1}\" x2=\"{2:.1}\" y2=\"{0:.1}\" stroke=\"#dedad2\" stroke-width=\"1\"/>", sy(g), sx(x0), sx(x1));
|
||||
g += 1.0;
|
||||
}
|
||||
// the entrance: the front edge, and where the camera looks in from
|
||||
s += &format!("<line x1=\"{0:.1}\" y1=\"{1:.1}\" x2=\"{2:.1}\" y2=\"{1:.1}\" stroke=\"#3a7bd5\" stroke-width=\"4\"/>", sx(x0), sy(z0), sx(x1));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#3a7bd5\" text-anchor=\"middle\">entrance: the camera looks in from here</text>", (sx(x0) + sx(x1)) / 2.0, sy(z0) + t * 1.3, t * 0.9);
|
||||
for o in &placed {
|
||||
let at = o.at.unwrap();
|
||||
let [fw, fd] = footprint(o);
|
||||
let invented = o.source == Some(Origin::Invented);
|
||||
let dash = if invented { " stroke-dasharray=\"8 5\"" } else { "" };
|
||||
let fill = if o.hero == Some(true) { "#f2c46d" } else if invented { "#ece8f4" } else { "#d9e4d2" };
|
||||
s += &format!(
|
||||
"<g transform=\"translate({:.1} {:.1}) rotate({:.1})\"><rect x=\"{:.1}\" y=\"{:.1}\" width=\"{:.1}\" height=\"{:.1}\" fill=\"{fill}\" stroke=\"#333\" stroke-width=\"2\"{dash}/><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"{:.1}\" stroke=\"#333\" stroke-width=\"2\"/></g>",
|
||||
sx(at[0]),
|
||||
sy(at[2]),
|
||||
-o.rot.unwrap_or(0.0),
|
||||
-fw * px / 2.0,
|
||||
-fd * px / 2.0,
|
||||
fw * px,
|
||||
fd * px,
|
||||
fd * px / 2.0
|
||||
);
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#111\" text-anchor=\"middle\">{}</text>", sx(at[0]), sy(at[2]) - t * 0.25, t, esc(&o.label));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m{}</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o), o.lod.map(|l| format!(", LOD {l}")).unwrap_or_default());
|
||||
}
|
||||
s += &format!("<line x1=\"20\" y1=\"{0}\" x2=\"{1:.1}\" y2=\"{0}\" stroke=\"#111\" stroke-width=\"5\"/><text x=\"20\" y=\"{2:.0}\" font-size=\"{3:.0}\" fill=\"#111\">1 m</text>", h - 18, 20.0 + px, h as f64 - 26.0, t * 0.9);
|
||||
s += "</svg>";
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
/// The blockout: a grey box for each placed object at its place and turn on a floor, seen from the entrance.
|
||||
pub fn blockout_tsx(m: &Goal) -> String {
|
||||
let (placed, [x0, z0, x1, z1]) = extent(m);
|
||||
let mut boxes = String::new();
|
||||
for o in &placed {
|
||||
let at = o.at.unwrap();
|
||||
let [w, d] = footprint(o);
|
||||
let h = height(o);
|
||||
let colour = if o.source == Some(Origin::Invented) { "#b4b0bd" } else { "#bdbdb8" };
|
||||
let a = -o.rot.unwrap_or(0.0).to_radians() / 2.0;
|
||||
let lod = o.lod.map(|l| format!(" lod={{{l}}}")).unwrap_or_default();
|
||||
boxes += &format!(
|
||||
" <Mesh3d name=\"{}\"{lod} transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",
|
||||
o.id,
|
||||
at[0],
|
||||
at[1] + h / 2.0,
|
||||
at[2],
|
||||
a.sin(),
|
||||
a.cos(),
|
||||
w / 2.0,
|
||||
h / 2.0,
|
||||
d / 2.0
|
||||
);
|
||||
}
|
||||
let (cx, cz) = ((x0 + x1) / 2.0, (z0 + z1) / 2.0);
|
||||
let (fw, fd) = ((x1 - x0) / 2.0, (z1 - z0) / 2.0);
|
||||
format!(
|
||||
"// written by raea make blockout: the plan as grey boxes, seen from the entrance (approve it before anything is made)\nimport {{ AbsoluteFill, Composition, registerRoot }} from \"raea\";\nimport {{ StandardMaterial }} from \"raea/pbr\";\nimport {{ Cuboid, Mesh3d }} from \"raea/mesh\";\nimport {{ AmbientLight, DirectionalLight }} from \"raea/light\";\nimport {{ Transform }} from \"raea/transform\";\nimport {{ Camera3d }} from \"raea/camera\";\n\nfunction Blockout() {{\n return (\n <AbsoluteFill style={{{{ background: \"#cfd3d6\" }}}}>\n <Camera3d transform={{Transform.fromXyz({cx:.3}, 1.6, {ez:.3}).lookingAt([{cx:.3}, 0.9, {cz:.3}])}} projection={{{{ Perspective: {{ fov: (50 * Math.PI) / 180 }} }}}} />\n <AmbientLight brightness={{350}} />\n <DirectionalLight transform={{Transform.fromXyz({lx:.3}, 6, -2).lookingAt([{cx:.3}, 0, {cz:.3}])}} illuminance={{8000}} shadow_maps_enabled />\n <Mesh3d transform={{Transform.fromXyz({cx:.3}, -0.01, {cz:.3})}}>\n <Cuboid half_size={{[{fw:.3}, 0.01, {fd:.3}]}} />\n <StandardMaterial base_color=\"#e6e3dc\" perceptual_roughness={{0.95}} />\n </Mesh3d>\n{boxes} </AbsoluteFill>\n );\n}}\n\nregisterRoot(() => <Composition id=\"blockout\" component={{Blockout}} width={{1280}} height={{720}} fps={{30}} durationInFrames={{1}} />);\n",
|
||||
ez = z0 - 0.4,
|
||||
lx = cx + 2.0,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn plan_dir(dir: &Path) -> PathBuf {
|
||||
dir.join("review/plan")
|
||||
}
|
||||
|
||||
/// The plan stop's pictures: floor plan, blockout (and its review sheets), and the comparison with reference 0.
|
||||
pub fn draw_plan(dir: &Path, m: &Goal, review: bool) -> Result<String, String> {
|
||||
let out = plan_dir(dir);
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let floor = out.join("floor-plan.png");
|
||||
svg_png(&floor_svg(m)?)?.save(&floor).map_err(|e| format!("{}: {e}", floor.display()))?;
|
||||
let tsx = out.join("blockout.tsx");
|
||||
std::fs::write(&tsx, blockout_tsx(m)).map_err(|e| format!("{}: {e}", tsx.display()))?;
|
||||
let shot = out.join("blockout.png");
|
||||
raea(&["render".into(), tsx.display().to_string(), "-o".into(), shot.display().to_string(), "--frame".into(), "0".into()], &[])?;
|
||||
let mut said = vec![format!("wrote {}", floor.display()), format!("wrote {}", shot.display())];
|
||||
if review {
|
||||
raea(&["render".into(), tsx.display().to_string(), "--review".into(), out.display().to_string()], &[])?;
|
||||
said.push(format!("review sheets of the blockout in {}", out.display()));
|
||||
}
|
||||
let mut row = Vec::new();
|
||||
if let Some(r) = m.references.first() {
|
||||
row.push(Tile { img: dir.join(r), label: "reference".into() });
|
||||
}
|
||||
row.push(Tile { img: shot, label: "blockout from the entrance".into() });
|
||||
row.push(Tile { img: floor, label: "floor plan".into() });
|
||||
let cmp = out.join("comparison.png");
|
||||
sheet("Plan: the reference, the blockout from the entrance, the floor plan", &[row], 640, &cmp)?;
|
||||
said.push(format!("wrote {}: approve the plan (positions, sizes, what's invented) before any generation", cmp.display()));
|
||||
Ok(said.join("\n"))
|
||||
}
|
||||
@@ -1,300 +0,0 @@
|
||||
//! A kit's steps (docs/goal.feature MK10-MK12, from AnyKit): every object's reference made in one style from the
|
||||
//! style images, checked on one sheet before any 3D; each reference to both generators (Tripo H3.1 and Meshy, on fal)
|
||||
//! and the pick made on clay renders (kitout.rs draws the pick sheets); the pick fitted to its real size with a
|
||||
//! quarter-triangle LOD beside it, each with a sidecar saying how it was made.
|
||||
//!
|
||||
//! raea make refs [DIR] [--only ID,...] [--model M] [--dry]
|
||||
//! raea make sheet refs [DIR]
|
||||
//! raea make gen [DIR] [--only ID,...] [--tripo M] [--meshy M] [--dry]
|
||||
//! raea make pick ID GENERATOR "why"
|
||||
//! raea make prep [DIR] [--only ID,...]
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::goal::{Goal, Object};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::sheet::{Tile, sheet};
|
||||
use crate::shots::raea;
|
||||
|
||||
/// What every reference prompt ends with: one object, whole, on a plain ground, in even light (the scan template).
|
||||
pub const SCAN: &str = "One object only, whole and centred, on a plain light grey background, soft even studio light, a three-quarter view from slightly above. Its own printed labels only, from the one maker named; no real brands, no text overlays.";
|
||||
/// The two generators every reference goes to (MK11).
|
||||
pub const TRIPO: &str = "tripo:H3.1";
|
||||
pub const MESHY: &str = "fal:meshy/v7.1/image-to-3d";
|
||||
/// Face limits: a hero, a small prop.
|
||||
const HERO_FACES: u32 = 150_000;
|
||||
const PROP_FACES: u32 = 60_000;
|
||||
|
||||
/// The objects named in `--only` (all when it's empty).
|
||||
pub fn objects<'a>(m: &'a Goal, only: &[String]) -> Vec<&'a Object> {
|
||||
crate::only(&m.objects, only, |o| o.id.as_str())
|
||||
}
|
||||
|
||||
/// The prompt a reference is made from: the plan's style paragraph, the object's own words, the scan template.
|
||||
pub fn ref_prompt(m: &Goal, o: &Object) -> String {
|
||||
let style = m.style.as_deref().unwrap_or("").trim().trim_end_matches('.');
|
||||
let what = o.prompt.as_deref().unwrap_or(&o.label).trim().trim_end_matches('.');
|
||||
format!("{style}. {what}. {SCAN}")
|
||||
}
|
||||
|
||||
/// `--h`, `--dims` or nothing: how gen check fits an object to its real size.
|
||||
pub fn size_args(o: &Object) -> Vec<String> {
|
||||
if let Some([w, d, h]) = o.dims {
|
||||
return vec!["--dims".into(), format!("{w},{d},{h}")];
|
||||
}
|
||||
if let Some(h) = o.h {
|
||||
return vec!["--h".into(), h.to_string()];
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// How `raea gen check -o` fits one generator's model to the object's size: its height (`--h`, which is what scales;
|
||||
/// a boxy object's is the third of its dims) and, for a boxy one, a quarter turn when the model's long side lies
|
||||
/// across (x) where the plan's lies front to back (z), or the other way: generators don't agree on which way is front.
|
||||
/// `measured` is the raw model's [w, h, d] (`raea gen check --json`'s measured.size).
|
||||
pub fn fit_args(o: &Object, measured: Option<[f64; 3]>) -> Vec<String> {
|
||||
let mut a = size_args(o);
|
||||
if let Some([w, d, h]) = o.dims {
|
||||
a.extend(["--h".into(), h.to_string()]);
|
||||
if let Some([mw, _, md]) = measured {
|
||||
let long = |x: f64, z: f64| if x > z * 1.2 { Some(true) } else if z > x * 1.2 { Some(false) } else { None };
|
||||
if let (Some(want), Some(got)) = (long(w, d), long(mw, md)) {
|
||||
if want != got {
|
||||
a.extend(["--turn".into(), "90".into()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
/// The raw model's size [w, h, d], measured by `raea gen check --json`.
|
||||
pub fn measured_size(model: &Path) -> Option<[f64; 3]> {
|
||||
let out = raea(&["gen".into(), "check".into(), model.display().to_string(), "--json".into()], &[]).ok()?;
|
||||
let v = json_of(&out)?;
|
||||
let s = v["measured"]["size"].as_array()?;
|
||||
Some([s.first()?.as_f64()?, s.get(1)?.as_f64()?, s.get(2)?.as_f64()?])
|
||||
}
|
||||
|
||||
/// The file a single-shot `raea gen` wrote: its JSON's `out.out`, a path or the first of a list.
|
||||
pub fn gen_file(out: &str) -> Option<PathBuf> {
|
||||
let v: Value = serde_json::from_str(out.trim()).ok()?;
|
||||
let o = &v["out"]["out"];
|
||||
o.as_str().or_else(|| o.as_array()?.first()?.as_str()).map(PathBuf::from)
|
||||
}
|
||||
|
||||
fn cents(out: &str) -> f64 {
|
||||
json_of(out).and_then(|v| v["cents"].as_f64()).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
/// raea gen's JSON from its output (anything printed before it skipped).
|
||||
fn json_of(out: &str) -> Option<Value> {
|
||||
serde_json::from_str(out[out.find('{')?..].trim()).ok()
|
||||
}
|
||||
|
||||
/// A `--plan` or `gen plan` quote in a line: what each paid step runs on, and the total.
|
||||
pub fn quote(out: &str) -> String {
|
||||
let Some(v) = json_of(out) else { return out.split_whitespace().collect::<Vec<_>>().join(" ") };
|
||||
let on: Vec<&str> = v["steps"].as_array().into_iter().flatten().filter_map(|s| s["runs_on"].as_str()).filter(|r| *r != "load").collect();
|
||||
format!("{} (about {}¢)", if on.is_empty() { "nothing paid".to_string() } else { on.join(" + ") }, v["cents"].as_f64().unwrap_or(0.0))
|
||||
}
|
||||
|
||||
pub fn refs_dir(dir: &Path) -> PathBuf {
|
||||
dir.join("out/kit/refs")
|
||||
}
|
||||
|
||||
/// Every object's reference, made from the style images (`references`) in the plan's style; then the sheet.
|
||||
pub fn refs(dir: &Path, m: &Goal, only: &[String], model: Option<&str>, dry: bool) -> Result<String, String> {
|
||||
if m.references.is_empty() {
|
||||
return Err("raea make refs: the plan has no `references` (the style images every reference is made from)".into());
|
||||
}
|
||||
let mut said = Vec::new();
|
||||
let mut spent = 0.0;
|
||||
for o in objects(m, only) {
|
||||
let work = refs_dir(dir).join("gen").join(&o.id);
|
||||
let mut args: Vec<String> = vec!["gen".into(), "image".into(), ref_prompt(m, o)];
|
||||
for r in &m.references {
|
||||
args.extend(["--image".into(), dir.join(r).display().to_string()]);
|
||||
}
|
||||
args.extend(["--aspect".into(), "1:1".into(), "-o".into(), work.display().to_string()]);
|
||||
if let Some(md) = model {
|
||||
args.extend(["--model".into(), md.to_string()]);
|
||||
}
|
||||
if dry {
|
||||
args.push("--plan".into());
|
||||
let out = raea(&args, &[])?;
|
||||
spent += cents(&out);
|
||||
said.push(format!("{}: {}", o.id, quote(&out)));
|
||||
continue;
|
||||
}
|
||||
eprintln!("raea make refs: {}", o.id);
|
||||
let out = raea(&args, &[])?;
|
||||
spent += cents(&out);
|
||||
let made = gen_file(&out).ok_or_else(|| format!("{}: raea gen image wrote no file: {}", o.id, out.trim()))?;
|
||||
let to = refs_dir(dir).join(format!("{}.png", o.id));
|
||||
std::fs::copy(&made, &to).map_err(|e| format!("{}: {e}", to.display()))?;
|
||||
said.push(format!("{}: {}", o.id, to.display()));
|
||||
}
|
||||
if dry {
|
||||
return Ok(format!("would make {} reference{} for about ${:.2} (nothing spent):\n{}", said.len(), if said.len() == 1 { "" } else { "s" }, spent / 100.0, said.join("\n")));
|
||||
}
|
||||
let sheet = sheet_refs(dir, m)?;
|
||||
Ok(format!("{}\n{sheet}\nspent about ${:.2}", said.join("\n"), spent / 100.0))
|
||||
}
|
||||
|
||||
/// The reference sheet: the style images first, then every object's reference, labelled with its id and size.
|
||||
pub fn sheet_refs(dir: &Path, m: &Goal) -> Result<String, String> {
|
||||
let style: Vec<Tile> = m.references.iter().enumerate().map(|(i, r)| Tile { img: dir.join(r), label: format!("style {}", i + 1) }).collect();
|
||||
let refs: Vec<Tile> = m
|
||||
.objects
|
||||
.iter()
|
||||
.map(|o| {
|
||||
let size = o.h.map(|h| format!("{h} m tall")).or(o.dims.map(|d| format!("{} x {} x {} m", d[0], d[1], d[2]))).or(o.max.map(|x| format!("{x} m long"))).unwrap_or_default();
|
||||
Tile { img: refs_dir(dir).join(format!("{}.png", o.id)), label: format!("{} {size}", o.id) }
|
||||
})
|
||||
.collect();
|
||||
let mut rows = vec![style];
|
||||
rows.extend(refs.chunks(4).map(|c| c.iter().map(|t| Tile { img: t.img.clone(), label: t.label.clone() }).collect()));
|
||||
let file = dir.join("review/refs.png");
|
||||
sheet("Reference sheet: the style, then every object's reference", &rows, 320, &file)?;
|
||||
Ok(format!("wrote {}: regenerate an outlier before any 3D (raea make refs --only ID)", file.display()))
|
||||
}
|
||||
|
||||
/// The flow that sends one reference to both generators, each at its face limit.
|
||||
pub fn gen_flow(m: &Goal, o: &Object, reference: &Path, tripo: &str, meshy: &str) -> Value {
|
||||
let faces = if o.hero == Some(true) { HERO_FACES } else { PROP_FACES };
|
||||
let prompt = o.prompt.clone().unwrap_or_else(|| o.label.clone());
|
||||
let _ = m;
|
||||
json!({"flow": 1, "steps": {
|
||||
"ref": {"op": "media.load", "in": {"path": reference.display().to_string()}},
|
||||
"tripo": {"op": "mesh.generate", "model": tripo, "in": {"prompt": prompt, "image": "@ref", "x_face_limit": faces}},
|
||||
"meshy": {"op": "mesh.generate", "model": meshy, "in": {"prompt": prompt, "image": "@ref"}}
|
||||
}, "out": ["tripo", "meshy"]})
|
||||
}
|
||||
|
||||
pub fn gen_dir(dir: &Path, id: &str) -> PathBuf {
|
||||
dir.join("out/kit/gen").join(id)
|
||||
}
|
||||
|
||||
/// Every reference to both generators: out/kit/gen/ID/tripo.glb and meshy.glb.
|
||||
pub fn generate(dir: &Path, m: &Goal, only: &[String], tripo: &str, meshy: &str, dry: bool) -> Result<String, String> {
|
||||
let mut said = Vec::new();
|
||||
let mut spent = 0.0;
|
||||
for o in objects(m, only) {
|
||||
let reference = refs_dir(dir).join(format!("{}.png", o.id));
|
||||
if !reference.is_file() {
|
||||
return Err(format!("raea make gen: no reference for {} ({}): raea make refs --only {}", o.id, reference.display(), o.id));
|
||||
}
|
||||
let to = gen_dir(dir, &o.id);
|
||||
// both models already there: a rerun (after a stop, or for the pieces still missing) doesn't pay twice
|
||||
if !dry && to.join("tripo.glb").is_file() && to.join("meshy.glb").is_file() {
|
||||
said.push(format!("{}: already made ({})", o.id, to.display()));
|
||||
continue;
|
||||
}
|
||||
std::fs::create_dir_all(&to).map_err(|e| format!("{}: {e}", to.display()))?;
|
||||
if !dry {
|
||||
eprintln!("raea make gen: {} on {tripo} and {meshy} (a few minutes each)", o.id);
|
||||
}
|
||||
let flow = to.join("flow.json");
|
||||
std::fs::write(&flow, serde_json::to_string_pretty(&gen_flow(m, o, &reference, tripo, meshy)).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
// quoted first: the run is capped at its own quote (a little over, for rounding), never gen's default cap
|
||||
let plan = raea(&["gen".into(), "plan".into(), flow.display().to_string()], &[])?;
|
||||
let out = if dry {
|
||||
plan
|
||||
} else {
|
||||
let cap = (cents(&plan) * 1.1).ceil().max(1.0) as u64;
|
||||
raea(&["gen".into(), "run".into(), flow.display().to_string(), "-o".into(), to.display().to_string(), "--max-cents".into(), cap.to_string()], &[])?
|
||||
};
|
||||
spent += cents(&out);
|
||||
said.push(if dry { format!("{}: {}", o.id, quote(&out)) } else { format!("{}: {}", o.id, to.display()) });
|
||||
}
|
||||
let tail = if dry { format!("about ${:.2} in all; nothing spent", spent / 100.0) } else { format!("spent about ${:.2}; next: raea make pick-sheet", spent / 100.0) };
|
||||
Ok(format!("{}\n{tail}", said.join("\n")))
|
||||
}
|
||||
|
||||
/// The model a pick's generator ran (from its flow.json), for the sidecar.
|
||||
fn pick_model(dir: &Path, id: &str, generator: &str) -> String {
|
||||
let flow: Option<Value> = std::fs::read_to_string(gen_dir(dir, id).join("flow.json")).ok().and_then(|t| serde_json::from_str(&t).ok());
|
||||
flow.and_then(|f| f["steps"][generator]["model"].as_str().map(String::from)).unwrap_or_else(|| generator.to_string())
|
||||
}
|
||||
|
||||
pub fn picks_file(dir: &Path) -> PathBuf {
|
||||
dir.join("out/kit/picks.json")
|
||||
}
|
||||
|
||||
/// The picks so far, by object id: {generator, why}.
|
||||
pub fn picks(dir: &Path) -> serde_json::Map<String, Value> {
|
||||
std::fs::read_to_string(picks_file(dir)).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// One object's pick and why, recorded (MK11).
|
||||
pub fn choose(dir: &Path, m: &Goal, id: &str, generator: &str, why: &str) -> Result<String, String> {
|
||||
if !m.objects.iter().any(|o| o.id == id) {
|
||||
return Err(format!("raea make pick: no object `{id}` in the plan"));
|
||||
}
|
||||
let glb = gen_dir(dir, id).join(format!("{generator}.glb"));
|
||||
if !glb.is_file() {
|
||||
return Err(format!("raea make pick: no {} (the generators are tripo and meshy: raea make gen --only {id})", glb.display()));
|
||||
}
|
||||
if why.trim().is_empty() {
|
||||
return Err("raea make pick: say why in one line (\"sharper dial numerals; Tripo fused the handset to the cradle\")".into());
|
||||
}
|
||||
let mut p = picks(dir);
|
||||
p.insert(id.into(), json!({"generator": generator, "why": why.trim()}));
|
||||
let f = picks_file(dir);
|
||||
std::fs::write(&f, serde_json::to_string_pretty(&p).unwrap_or_default()).map_err(|e| format!("{}: {e}", f.display()))?;
|
||||
Ok(format!("picked {generator} for {id}: {}", why.trim()))
|
||||
}
|
||||
|
||||
/// The triangles gen check measured.
|
||||
fn triangles(glb: &Path) -> Result<u64, String> {
|
||||
let out = raea(&["gen".into(), "check".into(), glb.display().to_string(), "--json".into()], &[]).or_else(|e| if e.contains('{') { Ok(e) } else { Err(e) })?;
|
||||
let v: Value = serde_json::from_str(out.trim()).map_err(|e| format!("gen check {}: {e}", glb.display()))?;
|
||||
v["measured"]["triangles"].as_u64().ok_or_else(|| format!("gen check couldn't read {}", glb.display()))
|
||||
}
|
||||
|
||||
/// Each pick fitted to its real size (front -Y, bottom-centre, metres) and a quarter-triangle LOD1 beside it, each
|
||||
/// with a sidecar saying how it was made (MK12).
|
||||
pub fn prep(dir: &Path, m: &Goal, only: &[String]) -> Result<String, String> {
|
||||
let p = picks(dir);
|
||||
let mut said = Vec::new();
|
||||
for o in objects(m, only) {
|
||||
let Some(pick) = p.get(&o.id) else {
|
||||
said.push(format!("{}: no pick yet (raea make pick {} tripo|meshy \"why\")", o.id, o.id));
|
||||
continue;
|
||||
};
|
||||
let generator = pick["generator"].as_str().unwrap_or("tripo");
|
||||
let src = gen_dir(dir, &o.id).join(format!("{generator}.glb"));
|
||||
let to = dir.join("out/kit").join(&o.id);
|
||||
std::fs::create_dir_all(&to).map_err(|e| format!("{}: {e}", to.display()))?;
|
||||
let full = to.join(format!("{}.glb", o.id));
|
||||
let mut args = vec!["gen".into(), "check".into(), src.display().to_string()];
|
||||
args.extend(fit_args(o, measured_size(&src)));
|
||||
args.extend(["-o".into(), full.display().to_string()]);
|
||||
// gen check exits non-zero on a finding it can't fix; the fitted copy is still written, and its findings said
|
||||
let _ = raea(&args, &[]);
|
||||
if !full.is_file() {
|
||||
return Err(format!("{}: gen check wrote no fitted copy of {}", o.id, src.display()));
|
||||
}
|
||||
let tris = triangles(&full)?;
|
||||
let lod = to.join(format!("{}_lod1.glb", o.id));
|
||||
let quarter = (tris / 4).max(500);
|
||||
let model = pick_model(dir, &o.id, generator);
|
||||
// the sidecar the Blender scripts carry along (source, licence, credit) and how it was made: ours, generated
|
||||
let made = |what: &str, tris: u64| {
|
||||
json!({"source": format!("generated by raea make: {model} from out/kit/refs/{}.png", o.id), "license": "ours (generated for this project)", "credit": "",
|
||||
"made": {"by": "raea make (docs/goal.feature)", "route": "gen", "generator": generator, "model": model, "why": pick["why"], "prompt": o.prompt, "reference": format!("out/kit/refs/{}.png", o.id),
|
||||
"style": m.style, "what": what, "triangles": tris, "source": if o.source.is_some() { json!(o.source) } else { Value::Null }}})
|
||||
};
|
||||
std::fs::write(full.with_extension("glb.json"), serde_json::to_string_pretty(&made("fitted to its real size", tris)).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
raea(&["blender".into(), "run".into(), "blender/decimate.py".into(), full.display().to_string(), lod.display().to_string(), quarter.to_string()], &[])?;
|
||||
// decimate.py wrote the LOD's sidecar from the model's, with its step; it says what it is, over the copy
|
||||
let side = lod.with_extension("glb.json");
|
||||
let mut v: Value = std::fs::read_to_string(&side).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_else(|| made("", 0));
|
||||
v["made"] = made("LOD1: a quarter of the fitted model's triangles", quarter)["made"].clone();
|
||||
std::fs::write(&side, serde_json::to_string_pretty(&v).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
said.push(format!("{}: {} ({tris} triangles) and its LOD1 ({quarter})", o.id, full.display()));
|
||||
}
|
||||
Ok(said.join("\n"))
|
||||
}
|
||||
Loaded 100 of 3040 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user