Upload 3 files
Browse files- docs/ARCHITECTURE.md +47 -0
- docs/NEXT_STEPS.md +57 -0
- docs/SECURITY.md +40 -0
docs/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Architecture
|
| 2 |
+
|
| 3 |
+
## V2 foundation
|
| 4 |
+
|
| 5 |
+
This repository is the first safe foundation for a Hugging Face-native Agentic Space Factory.
|
| 6 |
+
|
| 7 |
+
```text
|
| 8 |
+
User
|
| 9 |
+
β
|
| 10 |
+
Gradio orchestrator Space with HF OAuth
|
| 11 |
+
β
|
| 12 |
+
HF Job launched with the user's OAuth token
|
| 13 |
+
β
|
| 14 |
+
Mounted private Storage Bucket at /output
|
| 15 |
+
β
|
| 16 |
+
Optional private target Space creation
|
| 17 |
+
β
|
| 18 |
+
Live Gradio API validation
|
| 19 |
+
β
|
| 20 |
+
Bucket report + state + events
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
## Current phases
|
| 24 |
+
|
| 25 |
+
### Phase 1 β Hello Job
|
| 26 |
+
|
| 27 |
+
Validates:
|
| 28 |
+
|
| 29 |
+
```text
|
| 30 |
+
OAuth β Jobs scope β HF Job β mounted Bucket β readback UI
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
### Phase 2 β Private target Space
|
| 34 |
+
|
| 35 |
+
Validates:
|
| 36 |
+
|
| 37 |
+
```text
|
| 38 |
+
OAuth β HF Job β create private Gradio Space β upload files β live API test β report
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
The target Space is private by default and must be created in the signed-in user's namespace.
|
| 42 |
+
|
| 43 |
+
## Why Phase 2 is intentionally simple
|
| 44 |
+
|
| 45 |
+
Before adding Pi, model-card analysis, or ZeroGPU, we need to prove that the system can safely create a target Space and validate it through the live API.
|
| 46 |
+
|
| 47 |
+
That live API validation gate will later remain the core success criterion.
|
docs/NEXT_STEPS.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Next steps
|
| 2 |
+
|
| 3 |
+
## Current milestone
|
| 4 |
+
|
| 5 |
+
V2 validates private Space creation and live Gradio API validation.
|
| 6 |
+
|
| 7 |
+
## Phase 3 β Pi inside the Job
|
| 8 |
+
|
| 9 |
+
Add Pi as the first agentic runtime:
|
| 10 |
+
|
| 11 |
+
```text
|
| 12 |
+
HF Job
|
| 13 |
+
β install Pi
|
| 14 |
+
β configure HF Inference Providers
|
| 15 |
+
β give Pi a simple goal
|
| 16 |
+
β let Pi modify the generated hello Space
|
| 17 |
+
β upload files
|
| 18 |
+
β validate live API
|
| 19 |
+
β collect Pi traces from ~/.pi/agent/sessions
|
| 20 |
+
β copy raw/private traces into the Bucket
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
The first Pi task should be deliberately small:
|
| 24 |
+
|
| 25 |
+
```text
|
| 26 |
+
Improve the title/description/examples of the generated Gradio app.
|
| 27 |
+
Do not change the function signature.
|
| 28 |
+
Do not mark success until the live Gradio API test passes.
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
## Phase 4 β Apply the gist recipe
|
| 32 |
+
|
| 33 |
+
Give Pi a goal close to the article:
|
| 34 |
+
|
| 35 |
+
```text
|
| 36 |
+
Read the HF Spaces Agent Quickstart gist.
|
| 37 |
+
The deployed Space is your AI lab.
|
| 38 |
+
Use hf CLI / Hub API.
|
| 39 |
+
Read logs before patching.
|
| 40 |
+
Verify through gradio_client.
|
| 41 |
+
Do not declare success until live API validation passes.
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Phase 5 β First model-card template
|
| 45 |
+
|
| 46 |
+
Add one narrow model family, ideally a simple Transformers pipeline or a standard Diffusers text-to-image model.
|
| 47 |
+
|
| 48 |
+
## Phase 6 β ZeroGPU
|
| 49 |
+
|
| 50 |
+
Add a ZeroGPU-specific Gradio template with `@spaces.GPU` only around inference.
|
| 51 |
+
|
| 52 |
+
## Phase 2.1 fix
|
| 53 |
+
|
| 54 |
+
This version fixes private Space validation with `gradio_client>=2.0.0`, whose
|
| 55 |
+
`Client` constructor uses `token=` instead of `hf_token=`. The worker now uses
|
| 56 |
+
signature introspection so older/newer versions can still work. Bucket events
|
| 57 |
+
are also printed to stdout so HF Job logs are readable while the worker runs.
|
docs/SECURITY.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Security notes
|
| 2 |
+
|
| 3 |
+
## OAuth token handling
|
| 4 |
+
|
| 5 |
+
The orchestrator uses Gradio + Hugging Face OAuth.
|
| 6 |
+
|
| 7 |
+
The OAuth token is used in two places:
|
| 8 |
+
|
| 9 |
+
1. `token=token` when launching/managing the Job.
|
| 10 |
+
2. `secrets={"HF_TOKEN": token}` so the Job can act on behalf of the user.
|
| 11 |
+
|
| 12 |
+
Workers must never print or persist the token.
|
| 13 |
+
|
| 14 |
+
## Scope notes
|
| 15 |
+
|
| 16 |
+
The Space metadata requests:
|
| 17 |
+
|
| 18 |
+
- `read-repos`
|
| 19 |
+
- `write-repos`
|
| 20 |
+
- `manage-repos`
|
| 21 |
+
- `gated-repos`
|
| 22 |
+
- `inference-api`
|
| 23 |
+
- `jobs`
|
| 24 |
+
|
| 25 |
+
`jobs` is required for launching HF Jobs. `manage-repos` is currently used for private Space creation. A later hardening pass should test whether a narrower scope can replace it.
|
| 26 |
+
|
| 27 |
+
## Private by default
|
| 28 |
+
|
| 29 |
+
- Bucket remains private.
|
| 30 |
+
- Target Spaces are created private.
|
| 31 |
+
- Existing target Spaces are not overwritten.
|
| 32 |
+
- Publishing must be added later as an explicit user action only.
|
| 33 |
+
|
| 34 |
+
## Trace privacy
|
| 35 |
+
|
| 36 |
+
Future Pi traces must be stored as raw/private first. A redacted copy may be generated later, but public sharing should require explicit user confirmation.
|
| 37 |
+
|
| 38 |
+
## Current limitations
|
| 39 |
+
|
| 40 |
+
The redaction helper is a basic first-pass scanner. It is not a full data-loss prevention system.
|