Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions CLOUD_BROWSER_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Cloud-Hosted Ontology Browser - Executive Summary

## Question
> Could ont-run.com host the browser? Does the Go backend post enough information to be able to pull that off? That way the Go code contains no front end stuff.

## Answer: YES ✅

The Go backend **already sends sufficient data** to ont-run.com to support a cloud-hosted browser. This is now the **recommended approach**.

---

## Current State

### Data Already Sent (via Cloud Registration)
✅ Complete ontology snapshot
✅ Function names, descriptions, access rules
✅ Input/output JSON schemas
✅ Field references, user context flags
✅ Ontology hash

### What's Missing (Easy to Add)
- Previous ontology version from ont.lock
- Diff computation results
- Approval callback mechanism

### Business Logic & Code
❌ Resolver implementations → **NEVER sent to cloud**
❌ Environment configs → **NEVER sent to cloud**
❌ Auth functions → **NEVER sent to cloud**
❌ Actual user data → **NEVER sent to cloud**

---

## Recommended Solution

### Cloud-Hosted Browser at ont-run.com

**Achieves the Goal**: Zero frontend code in Go backend ✅

**User Flow**:
```
1. Dev changes ontology in Go code
2. Go server detects changes, sends to ont-run.com
3. Browser opens to: https://ont-run.com/review/{uuid}
4. User reviews and approves/rejects changes
5. Cloud service notifies local server via webhook
6. Local server updates ont.lock file
7. Server continues running
```

**Pros**:
- Pure Go backend, no UI dependencies
- Smaller binary (no embedded assets)
- No Node.js build steps
- Consistent across all backend languages
- Automatic UI updates for all users
- Foundation for team features (coming soon)

**Cons**:
- Requires internet connection
- Ontology metadata sent to cloud (already happens)
- CLI fallback needed for offline scenarios

---

## Implementation

### Effort: 4-5 Days Total
- **Go Backend**: 2 days (webhook, enhanced registration)
- **Cloud Service**: 2-3 days (UI hosting, review API, callbacks)

### Go Backend Changes
```go
// Enhanced cloud registration
type ReviewRequest struct {
UUID string
CurrentOntology OntologySnapshot
PreviousOntology *OntologySnapshot // from ont.lock
Diff *DiffData
CallbackURL string // local webhook
ReviewToken string // for authentication
}

// Webhook endpoint for approval callback
func (s *Server) handleReviewCallback(w http.ResponseWriter, r *http.Request) {
// Authenticate using review token
// Update ont.lock file
// Continue server startup
}
```

### Cloud Service Changes
- Add `/review/{uuid}` route to host browser UI
- Add review storage (temporary, 1-hour TTL)
- Add approval/rejection API endpoints
- Implement webhook callback system with retries

---

## Security

**Review Token System**:
- Generated by Go backend (32-byte random)
- Sent with review request to cloud
- Used to authenticate webhook callbacks
- Expires after 1 hour
- Stored in memory, not persisted

**Privacy**:
- Only ontology structure sent (function signatures, schemas, access rules)
- Same data already sent during cloud registration
- No business logic or implementation details
- No environment configs or secrets
- No actual user data

---

## Alternatives

### Option 2: Embedded Browser (Fallback)
If cloud-hosted is not suitable:
- Embed TypeScript browser in Go binary
- Serve locally at localhost:8081
- Fully offline capable
- Adds 5-10MB to binary
- Requires Node.js build step
- Implementation: 3-4 days

---

## Comparison

| Aspect | Cloud-Hosted | Embedded |
|--------|-------------|----------|
| **Go frontend code** | ✅ Zero | ❌ Assets embedded |
| **Binary size** | Small | Large (+5-10MB) |
| **Build complexity** | Low | Medium (Node.js) |
| **Internet required** | Yes | No |
| **Updates** | Automatic | Manual rebuild |
| **Privacy** | Metadata to cloud | Fully local |
| **Implementation** | 4-5 days | 3-4 days |

---

## Recommendation

**Start with cloud-hosted browser (Option 1)** because:

1. ✅ Achieves stated goal: no frontend in Go
2. ✅ Leverages existing infrastructure
3. ✅ Maintains consistency across backends
4. ✅ Enables future team features
5. ✅ Simpler Go codebase

**Add embedded browser later (Option 2)** as fallback for:
- Offline environments
- Air-gapped deployments
- Organizations with strict data policies

---

## Next Steps

1. **Decision**: Approve cloud-hosted approach
2. **Planning**: Budget ont-run.com infrastructure work
3. **Implementation**: Follow roadmap in ONTOLOGY_BROWSER_ANALYSIS.md
4. **Documentation**: Update README with browser usage
5. **Testing**: Verify both online and offline scenarios

---

## Related Documentation

- **Full Analysis**: `ONTOLOGY_BROWSER_ANALYSIS.md` (663 lines)
- 5 options evaluated
- Detailed implementation roadmaps
- Code examples and diagrams
- Security considerations

- **Cloud Integration Code**:
- `pkg/cloud/client.go` - Cloud client
- `pkg/cloud/registration.go` - Registration logic
- `pkg/ontology/lock.go` - Lockfile and diff

- **TypeScript Reference**:
- `src/browser/` - Existing browser implementation
- `src/cloud/` - TypeScript cloud integration
Loading