our owh git system
  • C 89.1%
  • Rust 5.1%
  • JavaScript 3%
  • CSS 0.7%
  • HTML 0.6%
  • Other 1.4%
Find a file
mik-tf e6d17e3bcb
All checks were successful
Build and Test / build (push) Successful in 3m30s
chore(hero_foundry): D-10 sweep — service.toml + herolib_core::base on 4 binaries, consolidate nested workspace, dep audit, cascade absorb
# What

- Wrote 4 service.toml (all-binaries-in-each canonical, kind = cli|server|admin|cmdline).
  - hero_foundry (cli) — lifecycle manager that registers server+admin with hero_proc.
  - hero_foundry_server (server, rpc.sock) — OpenRPC + WebDAV daemon.
  - hero_foundry_admin (admin, admin.sock) — Axum HTTP admin dashboard.
  - hero_foundry_web (cmdline) — Dioxus WASM dev-preview binary, not a hero_proc service.

- Wired herolib_core::base on 4 main.rs:
  - service_base!() macro at module level (auto-generates SERVICE_TOML + BUILD_NR).
  - validate_service_toml(SERVICE_TOML) + handle_info_flag(SERVICE_TOML) at main() entry.
  - Daemons (server + admin) also: print_startup_banner + prepare_sockets.
  - CLI and Dioxus shell: no banner / no sockets.

- Consolidated nested standalone Cargo workspace into outer:
  - crates/hero_foundry_web/hero_foundry_ui/ — package renamed hero_foundry_web -> hero_foundry_admin to avoid collision with outer crate's package name.
  - Binary name [[bin]] hero_foundry_admin unchanged (no on-disk binary rename, so s104 lesson #11 caution doesn't apply).
  - Deleted nested [workspace] declaration; added 'crates/hero_foundry_web/hero_foundry_ui' to outer [workspace.members]. Lab now discovers all 4 binaries via single 'lab build --workspace'.
  - Updated 2 `use hero_foundry_web::{language,templates}` -> `use hero_foundry_admin::{language,templates}` in nested main.rs.

- Outer Cargo.toml [workspace.members] fixed: deduped 'crates/hero_foundry_web' (was listed twice), added 'crates/hero_foundry_web/hero_foundry_ui'.

- cargo update absorbs 2026-05-17 cascade:
  - herolib_core/derive/os/ai 3ff281d8 -> 30a0b34e (PATH_VAR/BUILD/CODE derive from PATH_ROOT).
  - hero_proc_sdk 7fcea44 -> ceaea08 (banner-before-tracing-init).
  - hero_rpc_* f17dcd71 -> 071e67e0 (manual socket resolution -> herolib_core::base).

- Conservative dep audit: 2 zero-match deps stripped.
  - hero_foundry_server: hero_service (now provided transitively by herolib_core).
  - hero_foundry_web/hero_foundry_ui: askama_axum (askama 0.12 covers axum IntoResponse via #[derive(Template)]).
  - hero_foundry_server gains herolib_core (for service_base!()); hero_foundry CLI + hero_foundry_web gain herolib_core too.

# Why

Closes hero_foundry slice of lhumina_code/hero_proc#102 D-10 (T2 #6 of 14). Unblocks re-adding [[dependencies]] hero_foundry to hero_office service.toml (s105 dropped because installed binary lacked --info — now present).

# D-10 acceptance

1. lab infocheck clean: 4 crate(s) clean, 0 finding(s) total.
2. lab service hero_foundry_server + hero_foundry_admin start: smoke 6/6 (server 4 + admin 2).
3. cargo update applied, cascade absorbed.
4. Conservative dep audit completed (2 strips workspace-wide).
5. cargo test --workspace --release passes except hero_foundry_server::two_servers_sync_in_both_directions (pre-existing on origin/development @ 8272eec — verified via stash-and-rerun, panics with 'PATH_ROOT is not set' in test setup; out of D-10 scope; latent follow-up for the maintainer of two_server_sync_tests).

# Side findings (latent, not blocking)

- `[[env]] PATH_ROOT` mandatory in service.toml now: hero_lib 30a0b34e changed the contract — PATH_ROOT must be set in the spawned env or the binary panics at paths.rs:38. The s106 prompt claimed 30a0b34e *supersedes* the s105 HERO_SOCKET_DIR workaround, but the actual semantics are: HERO_SOCKET_DIR no longer works; PATH_ROOT is required instead. All 4 service.toml carry [[env]] PATH_ROOT default="~/hero" so hero_proc-supervised children get it injected at action-spawn time.

- hero_foundry_server::tests/two_server_sync_tests pre-existing PATH_ROOT panic in test setup. Same on origin/development. Not D-10 scope.

- Outer crate hero_foundry_web has [lib] crate-type = ["cdylib", "rlib"] AND [[bin]] — Dioxus dev-preview shell pattern (matches s104 hero_collab_app). Both kinds build; canonical-base wired only on the bin path.

Refs: lhumina_code/hero_proc#102

Signed-off-by: mik-tf
2026-05-17 10:30:08 -04:00
.forgejo/workflows ci: drop missing build_lib.sh; install rust 1.95; inline cargo 2026-05-13 00:04:19 +02:00
crates chore(hero_foundry): D-10 sweep — service.toml + herolib_core::base on 4 binaries, consolidate nested workspace, dep audit, cascade absorb 2026-05-17 10:30:08 -04:00
docs Auto-sync: local changes 2026-05-02 22:04:32 +02:00
fossil-c rename files to herofossil 2026-02-19 07:47:43 +01:00
rhai_examples feat(foundry)!: rename fossil to foundry, per-repo layout, multi-repo + dashboard UI 2026-05-02 09:16:30 +02:00
specs feat(foundry)!: rename fossil to foundry, per-repo layout, multi-repo + dashboard UI 2026-05-02 09:16:30 +02:00
.gitignore webdav working 2025-12-19 10:58:05 +01:00
Cargo.toml chore(hero_foundry): D-10 sweep — service.toml + herolib_core::base on 4 binaries, consolidate nested workspace, dep audit, cascade absorb 2026-05-17 10:30:08 -04:00
license init 2025-12-17 03:49:32 +01:00
PURPOSE.md refactor: rename hero_foundry_ui -> hero_foundry_web (ui.sock -> web.sock) (#30) 2026-05-08 02:06:10 +00:00
README.md refactor: rename hero_foundry_ui -> hero_foundry_web (ui.sock -> web.sock) (#30) 2026-05-08 02:06:10 +00:00

hero_foundry

hero_foundry is the core database library for HeroFoundry, providing a complete API for interacting with Fossil SCM repositories programmatically, without requiring the Fossil CLI to be installed. It supports both reading from existing repositories and creating new ones from scratch.

Running as a Hero OS Service

The recommended way to start hero_foundry on a Hero OS node is via nushell:

service foundry start --update --reset
service foundry stop
service foundry status

This registers hero_foundry_server (RPC, rpc.sock) and hero_foundry_web (web dashboard, web.sock) with hero_proc and keeps them running under the standard Hero service lifecycle.

Quick Start

Option 1: Test Server (Easiest)

The fastest way to get started - creates a test repository, runs tests, and starts a WebDAV server:

./build.sh --test-server

This will:

  1. Build with WebDAV support
  2. Create a test repository
  3. Run automated tests
  4. Start server on port 18080

Option 2: Interactive REPL

Start the interactive shell with tab completion, syntax highlighting, and command history:

# Build
cargo build --release

# Start interactive REPL
./target/release/hero_foundry --ui

Option 3: WebDAV Server Mode

Mount a repository as a network drive:

# Build with WebDAV support
cargo build --release --features webdav

# Start WebDAV server (default port: 8080)
./target/release/hero_foundry --server

# Start on custom port
./target/release/hero_foundry --server --port 18080

Connect to WebDAV Server

Command Line:

curl http://localhost:18080/
cadaver http://localhost:18080/

macOS Finder:

  1. Finder → Go → Connect to Server (⌘K)
  2. Enter: http://localhost:18080/
  3. Click Connect

Windows Explorer:

  1. Right-click "This PC" → "Map network drive"
  2. Enter: http://localhost:18080/

Linux (Nautilus/Files):

  1. Other Locations → Connect to Server
  2. Enter: dav://localhost:18080/

Supported WebDAV Operations

Operation Description
GET Download files
PUT Upload/update files
DELETE Remove files
MKCOL Create directories
COPY Copy files/directories
MOVE Move/rename files
PROPFIND List directories, get file properties
PROPPATCH Modify file properties
LOCK/UNLOCK File locking for concurrent editing

Features

Read Operations

  • Open and read existing Fossil repositories
  • Browse repository history and check-ins
  • List and read files at any check-in
  • Find files using glob patterns
  • Navigate directory structures
  • Access branch and tag information

Write Operations

  • Create new repositories from scratch
  • Commit files with full manifest generation
  • Create and manage branches
  • Add tags to check-ins
  • Manage users and permissions

Filesystem Operations

  • Copy, move, rename files and directories
  • Delete files and directories
  • Change permissions (chmod)
  • Create symbolic links
  • Advanced find with ignore patterns

WebDAV Server

  • Mount repositories as network drives
  • Edit files with any application
  • Automatic staging and commit
  • File locking for concurrent access

Synchronization

  • QUIC sync - Modern UDP-based protocol with TLS 1.3 (requires sync-quic feature)

Rhai Scripting

  • Interactive REPL with tab completion and syntax highlighting
  • Socket-based daemon for fast script execution
  • Full API access from Rhai scripts

Installation

Add hero_foundry to your project:

cargo add hero_foundry

Or add to your Cargo.toml:

[dependencies]
hero_foundry = "0.2.2"

Feature Flags

Feature Description Dependencies
webdav WebDAV server for repository access dav-server, hyper, tokio
rhai Rhai scripting support (default) rhai, tokio, rustyline
sync-quic QUIC protocol sync quinn, rustls, tokio
git-import Import git repositories herolib-os

Example with multiple features:

[dependencies]
hero_foundry = { version = "0.2.2", features = ["webdav", "sync-quic"] }

CLI Usage

The hero_foundry binary provides both an interactive REPL and daemon mode for script execution.

Interactive REPL

# Start interactive shell (default)
hero_foundry

# Or explicitly with --ui flag
hero_foundry --ui

The REPL provides:

  • Tab completion for all functions
  • Syntax highlighting
  • Command history
  • Multi-line input support

Running Scripts

# Run a script file
hero_foundry myscript.rhai

# Execute inline script
hero_foundry -e 'let repo = repo_open("project/db.foundry"); print(branches_list(repo));'

# Read script from stdin
echo 'print(version())' | hero_foundry -i

# Run locally without daemon
hero_foundry --local -e 'print("Hello!")'

Daemon Mode

# Start daemon in background
hero_foundry start -bg

# Check daemon status
hero_foundry status

# Stop daemon
hero_foundry stop

REPL Commands

Command Description
/help Show help
/functions List all available functions
/repo Show repository functions
/fs Show filesystem functions
/files Show file functions
/branches Show branch/tag functions
/modify Show modify builder functions
/find Show find builder functions
/utils Show utility functions
/scope Show current scope variables
/load <file> Load and execute a .rhai script
/clear Clear screen
/quit Exit REPL

Rust API Quick Start

Reading from an Existing Repository

use hero_foundry_core::Repository;

fn main() -> hero_foundry_core::Result<()> {
    // Open a Fossil repository
    let repo = Repository::open("project/db.foundry")?;

    // Get the latest check-in on trunk
    let tip = repo.history().trunk_tip()?;
    println!("Latest: {} by {}", tip.hash, tip.user);
    println!("Comment: {}", tip.comment);

    // List all files on trunk
    let files = repo.files().on_trunk().list()?;
    for file in &files {
        println!("  {}", file.name);
    }

    // Read a specific file from trunk
    let content = repo.files().on_trunk().read("README.md")?;
    println!("README:\n{}", String::from_utf8_lossy(&content));

    Ok(())
}

Creating a New Repository

use hero_foundry_core::Repository;

fn main() -> hero_foundry_core::Result<()> {
    // Create a new repository
    let repo = Repository::init("new_project/db.foundry")?;

    // Create initial check-in
    let init_hash = repo.commit_builder()
        .message("initial empty check-in")
        .author("admin")
        .initial()
        .execute()?;

    // Add some files in a new commit
    let commit_hash = repo.commit_builder()
        .message("Initial project structure")
        .author("developer")
        .parent(&init_hash)
        .file("README.md", b"# My Project\n")
        .file("src/main.rs", b"fn main() { println!(\"Hello!\"); }\n")
        .execute()?;

    // Tag the release
    repo.tags()
        .create("v1.0.0")
        .at_commit(&commit_hash)
        .author("developer")
        .execute()?;

    // Create a feature branch
    repo.branches()
        .create("feature-x")
        .from_commit(&commit_hash)
        .author("developer")
        .execute()?;

    Ok(())
}

Using the Rhai API

// Open a repository
let repo = repo_open("project/db.foundry");

// List branches
let branches = branches_list(repo);
for b in branches {
    print("Branch: " + b);
}

// List files
let files = files_list(repo);
for f in files {
    print("  " + f.name() + " (" + f.size() + " bytes)");
}

// Read a file
let content = files_read(repo, "README.md");
print("Content:\n" + content);

// Use the filesystem interface for modifications
let repo_rw = repo_open_rw("project/db.foundry");
let fs = fs_new(repo_rw, "developer@example.com");
fs_write(fs, "newfile.txt", "Hello, World!");
fs_commit(fs);

Finding Files with Glob Patterns

use hero_foundry_core::Repository;

fn main() -> hero_foundry_core::Result<()> {
    let repo = Repository::open("project/db.foundry")?;

    // Find all Rust files on trunk
    let rust_files = repo.files().on_trunk().find("**/*.rs")?;
    for file in rust_files {
        println!("Found: {}", file.name);
    }

    // Find files in a specific directory on a branch
    let src_files = repo.files().on_branch("feature-x").find("src/**/*")?;
    
    // Find files at a specific tag
    let tagged_files = repo.files().at_tag("v1.0.0").find("*.md")?;
    
    Ok(())
}

Browsing History

use hero_foundry_core::Repository;

fn main() -> hero_foundry_core::Result<()> {
    let repo = Repository::open("project/db.foundry")?;

    // Get recent check-ins
    let history = repo.history().recent(10)?;
    for checkin in history {
        println!("{} | {} | {}", 
            &checkin.hash[..12], 
            checkin.user, 
            checkin.comment
        );
    }

    // List all branches
    let branches = repo.branches().list()?;
    for branch in branches {
        println!("Branch: {}", branch);
    }

    // List all tags
    let tags = repo.tags().list()?;
    for tag in tags {
        println!("Tag: {}", tag);
    }

    // Get the tip of a specific branch
    let feature_tip = repo.history().branch_tip("feature-x")?;
    println!("Feature branch tip: {}", feature_tip.hash);

    Ok(())
}

Filesystem Operations

use hero_foundry_core::Repository;

fn main() -> hero_foundry_core::Result<()> {
    let repo = Repository::open_rw("project/db.foundry")?;

    // Copy, move, delete files atomically
    let hash = repo.fs().modify()
        .message("Reorganize project")
        .author("developer")
        .copy_file("README.md", "docs/README.md")
        .move_dir("scripts", "tools")
        .delete_file("old_config.txt")
        .make_executable("tools/build.sh")
        .symlink("build", "tools/build.sh")
        .execute()?;

    // Advanced find with ignore patterns
    let files = repo.fs().find()
        .pattern("**/*.rs")
        .ignore("target/**")
        .ignore_hidden()
        .max_depth(3)
        .paths()?;
    
    // Utility functions
    println!("Exists: {}", repo.fs().exists("README.md")?);
    println!("Is dir: {}", repo.fs().is_dir("src")?);
    println!("Total size: {} bytes", repo.fs().du("**/*.rs")?);

    Ok(())
}

Builder API Overview

The library uses a fluent builder pattern for all operations:

Builder Entry Point Purpose
FilesBuilder repo.files() Read files, list directories, find with glob patterns
CommitBuilder repo.commit_builder() Create new check-ins with files
BranchesBuilder repo.branches() List and create branches
TagsBuilder repo.tags() List, create, and resolve tags
HistoryBuilder repo.history() Browse commits and history
UsersBuilder repo.users() Manage repository users
SyncBuilder repo.sync() Synchronize with remote repositories (QUIC)
FsOpsBuilder repo.fs() Filesystem operations (copy, move, delete, chmod, find, symlinks)

Rhai API Functions

Repository

Function Return Description
repo_open(path) Repository Open repository read-only
repo_open_rw(path) Repository Open repository read-write
repo_init(path) Repository Create new repository
repo_project_name(repo) string Get project name

Filesystem

Function Return Description
fs_new(repo, author) FsHandle Create filesystem interface
fs_read(fs, path) string Read file as string
fs_write(fs, path, content) void Write file
fs_delete(fs, path) void Delete file
fs_exists(fs, path) bool Check if file exists
fs_list(fs, dir) array List directory
fs_commit(fs) string Commit changes

Files

Function Return Description
files_list(repo) array List files on trunk
files_read(repo, path) string Read file from trunk
files_find(repo, pattern) array Find files by pattern

Branches/Tags

Function Return Description
branches_list(repo) array List all branches
branches_create(repo, name, parent) string Create branch
tags_list(repo) array List all tags
tags_create(repo, name, target) string Create tag

Utilities

Function Return Description
version() string Get hero_foundry version
uuid() string Generate UUID
timestamp() i64 Get Unix timestamp
sleep(ms) void Sleep for milliseconds
env(name) string Get environment variable
cwd() string Current directory
home() string Home directory

Examples

The repository includes many examples demonstrating various features:

# Basic repository reading
cargo run --example read_repo

# Find files with glob patterns
cargo run --example find_and_read

# Branches and tags demonstration
cargo run --example branch_tag_test

# Comprehensive API demo
cargo run --example comprehensive_test

# Filesystem operations (copy, move, delete, chmod, symlinks)
cargo run --example fs_operations

# Advanced find with ignore patterns
cargo run --example fs_find

# QUIC sync (requires sync-quic feature)
cargo run --example quic_incremental_sync_test --features sync-quic

Documentation

Full API documentation is available at docs.rs/hero_foundry.

Generate local documentation with:

cargo doc --open --all-features

Architecture

A Fossil repository is a SQLite database containing:

  • Blobs: Compressed file contents and manifests (zlib)
  • Manifests: Check-in metadata with file lists, timestamps, comments
  • Tags: Branch names, version tags, and other labels
  • Events: Timeline of repository activity
  • Delta encoding: Efficient storage of similar content

Acknowledgments

Based on the Fossil SCM project.