Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

ci(web): build two specta exporters with the schema binaries (#9883)

teo5fd6521cf508
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.yml
index f6df1691a3..d9e6de8945 100644
--- a/.github/workflows/web-app-check-main.yml
+++ b/.github/workflows/web-app-check-main.yml
@@ -496,7 +496,8 @@ jobs:
run: |
set -euo pipefail
read -ra openapi_bins <<< "$(cd apps/web && bun scripts/generate-api-schema.ts --print-cargo-bins)"
- SQLX_OFFLINE=true cargo build "${openapi_bins[@]}" --bin gen_tool_schemas
+ SQLX_OFFLINE=true cargo build "${openapi_bins[@]}" --bin gen_tool_schemas \
+ --bin agent_fold_types --bin export_review_types
- name: Generate API Types
run: bun run gen-api -- --check
working-directory: apps/web
@@ -535,6 +536,8 @@ jobs:
echo "Generated specta types are stale. Run 'just gen-agent-fold-types', 'just gen-database-sql-types', 'just gen-dynamic-ui-types' and 'just gen-agent-review-types' in apps/web and commit the result."
exit 1
fi
+ env:
+ SPECTA_BIN_DIR: ${{ github.workspace }}/target/debug
working-directory: apps/web
- name: show sccache stats
if: always()
diff --git a/apps/web/justfile b/apps/web/justfile
index 2e26c2a03c..57429a0ac4 100644
--- a/apps/web/justfile
+++ b/apps/web/justfile
@@ -468,7 +468,7 @@ ensure-ai-engine-wasm:
# that, every regeneration would be a diff-format mismatch even with no real
# change.
gen-agent-fold-types:
- cargo run -p agent_fold --bin export_types
+ if [ -n "${SPECTA_BIN_DIR:-}" ]; then "$SPECTA_BIN_DIR/agent_fold_types"; else cargo run -p agent_fold --bin agent_fold_types; fi
bunx biome format --write {{justfile_directory()}}/src/lib/service-clients/service-agent-fold/generated/types.ts
# Regenerate src/lib/service-clients/service-agent-reviews/generated/types.ts
@@ -478,7 +478,7 @@ gen-agent-fold-types:
# their responses, the import report); biome reformats specta's output for the
# same reason as gen-agent-fold-types.
gen-agent-review-types:
- SQLX_OFFLINE=true cargo run -p agent_code_mode --bin export_review_types
+ if [ -n "${SPECTA_BIN_DIR:-}" ]; then "$SPECTA_BIN_DIR/export_review_types"; else SQLX_OFFLINE=true cargo run -p agent_code_mode --bin export_review_types; fi
bunx biome format --write {{justfile_directory()}}/src/lib/service-clients/service-agent-reviews/generated/types.ts
# Regenerate the dynamic-UI view types (src/features/dynamic-ui/generated/types.ts
diff --git a/crates/database_sql/Cargo.toml b/crates/database_sql/Cargo.toml
index 4a7b37dbb9..55363f2c69 100644
--- a/crates/database_sql/Cargo.toml
+++ b/crates/database_sql/Cargo.toml
@@ -19,7 +19,7 @@ cli = ["dep:specta-serde", "dep:specta-typescript"]
schema = ["dep:schemars", "models_databases/schema"]
# Needs the exporter and a filesystem to write to, which the library does not.
-# Not `export_types`, which `agent_fold` already builds into the same target.
+# Not `export_types`, which `agent_runtime_protocol` already builds into the same target.
[[bin]]
name = "database_sql_types"
required-features = ["cli"]
diff --git a/crates/folds/agent_fold/AGENTS.md b/crates/folds/agent_fold/AGENTS.md
index b68b4b2c35..86f6d53a25 100644
--- a/crates/folds/agent_fold/AGENTS.md
+++ b/crates/folds/agent_fold/AGENTS.md
@@ -59,7 +59,7 @@ to the browser via `inbound/wasm`.
- Add a new message/event kind: `src/domain/log.rs` (raw shape) →
`src/domain/fold.rs` (fold logic) → `src/domain/model.rs` (renderable type)
→ `src/inbound/wire.rs` if the browser needs it → `cargo run -p agent_fold
- --bin export_types` to regenerate the TypeScript contract.
+ --bin agent_fold_types` to regenerate the TypeScript contract.
- Debug a fold against a recorded session: `cargo run -p agent_fold --bin
fold_jsonl -- <path>.jsonl`.
@@ -96,7 +96,7 @@ session projection carries that state to list rows without loading transcripts.
- `cargo test -p agent_fold`.
- After changing `inbound/wire.rs` or exported `domain/model.rs` types:
- `cargo run -p agent_fold --bin export_types` and commit the regenerated
+ `cargo run -p agent_fold --bin agent_fold_types` and commit the regenerated
TypeScript: the web client's copy and the SDK's
`packages/sdk/generated/agent-fold/`, which types
`AgentSession.foldedLog()`.
diff --git a/crates/folds/agent_fold/Cargo.toml b/crates/folds/agent_fold/Cargo.toml
index 9ecac0fb07..62508dd591 100644
--- a/crates/folds/agent_fold/Cargo.toml
+++ b/crates/folds/agent_fold/Cargo.toml
@@ -10,10 +10,10 @@ crate-type = ["cdylib", "rlib"]
[features]
default = ["cli"]
-# The `fold_jsonl` viewer and the `export_types` codegen binary - native
+# The `fold_jsonl` viewer and the `agent_fold_types` codegen binary - native
# developer tooling, neither of which the wasm build needs. `fold_jsonl` needs
# `tokio`, which pulls in `mio`, which does not build for wasm32;
-# `export_types` needs `std::fs` to write its output, which is pointless on a
+# `agent_fold_types` needs `std::fs` to write its output, which is pointless on a
# target with no filesystem. The library itself uses neither - the fold is
# sync, the ports are plain futures, and the browser only wants the schema.
cli = ["dep:clap", "dep:tokio"]
@@ -31,8 +31,11 @@ name = "fold_jsonl"
required-features = ["cli"]
# Needs a filesystem to write to, which the library does not.
+# Not `export_types`, which agent_runtime_protocol also has: CI builds this one
+# in the same cargo invocation as the schema binaries.
[[bin]]
-name = "export_types"
+name = "agent_fold_types"
+path = "src/bin/export_types.rs"
required-features = ["cli"]
[dependencies]
diff --git a/crates/folds/agent_fold/src/bin/export_types.rs b/crates/folds/agent_fold/src/bin/export_types.rs
index 81c89f5d28..1ad019e451 100644
--- a/crates/folds/agent_fold/src/bin/export_types.rs
+++ b/crates/folds/agent_fold/src/bin/export_types.rs
@@ -3,7 +3,7 @@
//! Run with:
//!
//! ```text
-//! cargo run -p agent_fold --bin export_types
+//! cargo run -p agent_fold --bin agent_fold_types
//! ```
use agent_fold::domain::model::SessionMetadata;
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
index 5346bf3379..efffd0ca3e 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main.rs
@@ -412,7 +412,8 @@ fn build_schema_binaries() -> Step<Run> {
Step::new("Build schema binaries").run(indoc::indoc! {r#"
set -euo pipefail
read -ra openapi_bins <<< "$(cd apps/web && bun scripts/generate-api-schema.ts --print-cargo-bins)"
- SQLX_OFFLINE=true cargo build "${openapi_bins[@]}" --bin gen_tool_schemas
+ SQLX_OFFLINE=true cargo build "${openapi_bins[@]}" --bin gen_tool_schemas \
+ --bin agent_fold_types --bin export_review_types
"#})
}
@@ -438,6 +439,12 @@ fn check_specta_types() -> Step<Run> {
fi
"#})
.working_directory(xtask_paths::repo_dir!("apps/web"))
+ // Two of the four exporters come from the build step, built with the same
+ // feature resolution as the schema binaries. `cargo run -p` resolves the
+ // features of one package's dependencies, which recompiled 101 and 131
+ // crates for them. The other two need a `cli` feature that would change
+ // the libraries every schema binary links, so they keep `cargo run -p`.
+ .add_env(("SPECTA_BIN_DIR", "${{ github.workspace }}/target/debug"))
}
/// The tail of `just update-generated` in `packages/sdk`: its first line reruns