Upload 4 files
Browse files- docs/ARCHITECTURE.md +81 -0
- docs/NEXT_STEPS.md +40 -0
- docs/PUBLIC_PREVIEW.md +23 -0
- docs/SECURITY.md +25 -0
docs/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Architecture
|
| 2 |
+
|
| 3 |
+
Agentic Space Factory is a Hugging Face-native implementation of the local agent workflow described in the ZeroGPU Spaces article.
|
| 4 |
+
|
| 5 |
+
```text
|
| 6 |
+
User
|
| 7 |
+
β Gradio orchestrator Space with HF OAuth
|
| 8 |
+
β ephemeral HF Job
|
| 9 |
+
β Pi coding agent + HF Inference Providers model
|
| 10 |
+
β generated private target Space
|
| 11 |
+
β Storage Bucket run record
|
| 12 |
+
β live validation job when hardware is ready
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
## Components
|
| 16 |
+
|
| 17 |
+
### Orchestrator Space
|
| 18 |
+
|
| 19 |
+
The public UI has two workflows:
|
| 20 |
+
|
| 21 |
+
1. **Build from model card** β starts an HF Job that analyzes a model card and asks Pi to generate a private Gradio Space.
|
| 22 |
+
2. **Validate existing Space** β starts a separate HF Job that smoke-tests a generated Space after hardware has been configured, measures latency, and stores the output artifact.
|
| 23 |
+
|
| 24 |
+
The orchestrator never stores a global admin token. It uses the signed-in user's HF OAuth token.
|
| 25 |
+
|
| 26 |
+
### HF Jobs
|
| 27 |
+
|
| 28 |
+
Jobs do the long-running work: installing Pi, generating code, creating/uploading the target Space, checking runtime state, and running live validations.
|
| 29 |
+
|
| 30 |
+
The builder job is allowed to create a private Space and upload generated files. Hardware assignment is attempted on a best-effort basis only. If ZeroGPU or fixed-GPU assignment fails because of quota, billing, or OAuth limits, the run is marked as requiring manual hardware.
|
| 31 |
+
|
| 32 |
+
### Pi + coding model
|
| 33 |
+
|
| 34 |
+
Pi runs inside the Job and uses a model such as `Qwen/Qwen3-Coder-Next` through Hugging Face Inference Providers. It receives a strict goal:
|
| 35 |
+
|
| 36 |
+
- generate a Gradio app from the model card;
|
| 37 |
+
- keep the Space private;
|
| 38 |
+
- add `/health` and generation endpoints where possible;
|
| 39 |
+
- do not mark placeholders as full inference;
|
| 40 |
+
- write blockers if full inference is impossible.
|
| 41 |
+
|
| 42 |
+
### Storage Bucket
|
| 43 |
+
|
| 44 |
+
Every run writes to the configured Bucket:
|
| 45 |
+
|
| 46 |
+
```text
|
| 47 |
+
runs/<run_id>/state.json
|
| 48 |
+
runs/<run_id>/events.jsonl
|
| 49 |
+
runs/<run_id>/report.md
|
| 50 |
+
runs/<run_id>/generated/
|
| 51 |
+
runs/<run_id>/tests/
|
| 52 |
+
runs/<run_id>/artifacts/
|
| 53 |
+
runs/<run_id>/traces/
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
### Target Space
|
| 57 |
+
|
| 58 |
+
Generated Spaces are private by default. The builder attempts ZeroGPU first when selected, then an optional fixed-GPU fallback. If both fail, the Space can still be configured manually in Settings, then validated with the second workflow.
|
| 59 |
+
|
| 60 |
+
## Result lifecycle
|
| 61 |
+
|
| 62 |
+
```text
|
| 63 |
+
Build from model card
|
| 64 |
+
β generated private Space
|
| 65 |
+
β ZeroGPU/fixed GPU best-effort
|
| 66 |
+
β health/API gate
|
| 67 |
+
β manual_hardware_required or candidate status
|
| 68 |
+
|
| 69 |
+
Validate existing Space
|
| 70 |
+
β call /generate or configured endpoint
|
| 71 |
+
β verify output type
|
| 72 |
+
β measure latency
|
| 73 |
+
β save artifact
|
| 74 |
+
β full_inference_success when output is valid
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Known limits
|
| 78 |
+
|
| 79 |
+
- Automatic paid hardware assignment through OAuth may fail; manual hardware selection is supported.
|
| 80 |
+
- ZeroGPU may be unavailable because of quota or namespace limits.
|
| 81 |
+
- Multi-GPU, Docker-only, ComfyUI, custom CUDA/FlashAttention, external API keys, or gated models may require manual intervention or produce `technical_blocker`.
|
docs/NEXT_STEPS.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Next Steps
|
| 2 |
+
|
| 3 |
+
## Product follow-ups
|
| 4 |
+
|
| 5 |
+
1. Add a dedicated hardware diagnostic workflow that compares:
|
| 6 |
+
- `request_space_hardware()` after Space creation;
|
| 7 |
+
- `create_repo(..., space_hardware=...)` at creation time;
|
| 8 |
+
- OAuth token vs personal access token behavior.
|
| 9 |
+
|
| 10 |
+
2. Add optional live Pi progress streaming:
|
| 11 |
+
- periodic heartbeat during the Pi run;
|
| 12 |
+
- partial `pi_output.txt` tailing;
|
| 13 |
+
- intermediate trace syncing.
|
| 14 |
+
|
| 15 |
+
3. Add a repair workflow:
|
| 16 |
+
- read target Space build/runtime logs;
|
| 17 |
+
- ask Pi to patch generated files;
|
| 18 |
+
- upload patch;
|
| 19 |
+
- re-run validation.
|
| 20 |
+
|
| 21 |
+
4. Improve validation presets per task:
|
| 22 |
+
- text-to-image prompt β image output;
|
| 23 |
+
- text-generation prompt β text output;
|
| 24 |
+
- ASR audio sample β text output;
|
| 25 |
+
- image-to-image test image β image output.
|
| 26 |
+
|
| 27 |
+
5. Improve generated report UI:
|
| 28 |
+
- clearer final status badges;
|
| 29 |
+
- direct links to generated Space, Bucket files, and trace JSONL;
|
| 30 |
+
- explicit manual hardware checklist.
|
| 31 |
+
|
| 32 |
+
## Current product workflow
|
| 33 |
+
|
| 34 |
+
```text
|
| 35 |
+
Build from model card
|
| 36 |
+
β if hardware automatic assignment succeeds, validate directly
|
| 37 |
+
β if not, set hardware manually in target Space Settings
|
| 38 |
+
β Validate existing Space
|
| 39 |
+
β full_inference_success if output type and latency are validated
|
| 40 |
+
```
|
docs/PUBLIC_PREVIEW.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Public Preview
|
| 2 |
+
|
| 3 |
+
Agentic Space Factory is a public-preview tool for turning Hugging Face model cards into private, testable Gradio Spaces.
|
| 4 |
+
|
| 5 |
+
## What it does
|
| 6 |
+
|
| 7 |
+
- Creates private Spaces from model cards.
|
| 8 |
+
- Uses Pi and a coding model through Hugging Face Inference Providers.
|
| 9 |
+
- Attempts ZeroGPU first when selected, then a fixed-GPU fallback if enabled.
|
| 10 |
+
- Stores run state, generated files, traces, validation results, and reports in a Storage Bucket.
|
| 11 |
+
- Supports manual hardware selection when automatic hardware assignment is unavailable.
|
| 12 |
+
- Provides a separate live generation smoke test with latency measurement.
|
| 13 |
+
|
| 14 |
+
## What it does not promise
|
| 15 |
+
|
| 16 |
+
It does not guarantee that every model card becomes a fully working Space. Some models require multi-GPU systems, Docker, custom CUDA/FlashAttention, external services, accepted gated licenses, or hardware beyond what is available.
|
| 17 |
+
|
| 18 |
+
## Recommended demo path
|
| 19 |
+
|
| 20 |
+
1. Build a private Space from a model card.
|
| 21 |
+
2. If the run reports `manual_hardware_required`, open the generated Space Settings and set an appropriate GPU.
|
| 22 |
+
3. Run Validate existing Space with a small test input.
|
| 23 |
+
4. Confirm `full_inference_success`, saved output artifact, and latency.
|
docs/SECURITY.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Security Notes
|
| 2 |
+
|
| 3 |
+
## Token model
|
| 4 |
+
|
| 5 |
+
The orchestrator uses Hugging Face OAuth. Do not store a global admin `HF_TOKEN` in the Space.
|
| 6 |
+
|
| 7 |
+
The user OAuth token is passed to HF Jobs as a secret named `HF_TOKEN`. The worker must never write it to the Bucket, traces, reports, generated files, or logs.
|
| 8 |
+
|
| 9 |
+
## Resource ownership
|
| 10 |
+
|
| 11 |
+
Generated Spaces are constrained to the signed-in user's namespace and are private by default.
|
| 12 |
+
|
| 13 |
+
The validation workflow is also limited to Spaces under the signed-in user's namespace.
|
| 14 |
+
|
| 15 |
+
## Hardware
|
| 16 |
+
|
| 17 |
+
Hardware assignment is best-effort. GPU upgrades may involve billing and may fail through OAuth. The supported fallback is manual hardware selection by the user followed by a separate validation job.
|
| 18 |
+
|
| 19 |
+
## Traces
|
| 20 |
+
|
| 21 |
+
Pi traces can contain prompts, tool outputs, paths, generated code, and potentially sensitive information. Raw traces should remain private. Redaction is best-effort and should not be treated as a formal data-loss-prevention system.
|
| 22 |
+
|
| 23 |
+
## Publication
|
| 24 |
+
|
| 25 |
+
The app never publishes generated Spaces automatically. Users should review generated code, license requirements, and validation results before making any generated Space public.
|