# Google Workspace Automation Architect deployment

## Preview and upload

Serve the DiscoveryVIP root from a local HTTP server for development. For example, run `python3 -m http.server 8766 --bind 127.0.0.1` from the site root and open `http://127.0.0.1:8766/workspace-automation-architect/`. Use your PHP server when checking the surrounding site directories.

Back up the existing live site. Extract the academy upload ZIP into the existing DiscoveryVIP document root, preserving the folders. The archive contains the complete academy folder and updated `data/guides.json`, `data/learning-topics.json` and `sitemap.xml`. Merge any newer live catalog edits before uploading these three files. Confirm that your host serves `.mjs` with a JavaScript MIME type and permits the academy’s sandboxed iframe and blob worker. Existing DiscoveryVIP PHP templates and the consent-gated analytics script provide site navigation and analytics.

Open the academy on staging. Run the first mission, inspect the generated Doc, export the script, run the sample workflow with and without approval, and reload to check the local save. Check the Apps Script learning path and Interactive Guides for the new listing.

## First mission in real Apps Script

1. Import [Requests.csv](downloads/Requests.csv) into a test spreadsheet and name the tab `Requests`. Keep the displayed column order.
2. Open Extensions → Apps Script from the spreadsheet. Paste [SheetsToDocs.gs](downloads/SheetsToDocs.gs) into the editor. The workbench’s Export button also downloads the current editor contents.
3. Select `main` and run it manually. Review and grant the permissions for the test spreadsheet and Docs.
4. In Drive, open the new **Open customer requests** document. Expect two unique open requests, one for Aster Books and one for Maple Arts. The closed Cedar & Co request is excluded.
5. Add an open request and rerun. This starter creates a separate Doc on each run. Before scheduling, introduce a stable job key, locking where needed, and reconciliation for partial output.

For a standalone or scheduled production script, configure a real workbook ID and use `SpreadsheetApp.openById()` where an active workbook is unavailable. Replace simulated resource IDs with authorized test IDs. Apps Script’s V8 runtime, service permissions, ownership and quotas control real execution.

## Supported simulation

| Area | Working subset |
|---|---|
| Sheets | Active workbook and fixture ID, named tabs, insert tab, data ranges, A1 and numeric ranges, read/write matrices, append rows, SUM/AVERAGE/COUNT on same-sheet rectangles |
| Docs | Create and open by fixture ID, append and inspect paragraphs, save and close |
| Gmail | Search synthetic inbox by subject or label, read messages and create virtual drafts |
| Drive | Folder tree, list files in a folder, look up a file and move it |
| Calendar | Resolve a fixture calendar and create bounded events |
| Forms | Inspect fixture forms, submit synthetic intake events and read item responses |
| Helpers | UTC date format, simulated sleep, script properties, per-run cache, simulated script lock, fixture URL responses, HTML output with title and content |
| Triggers | Record and replay sheet edits, workbook opens, Sheets-style form submissions and manual clock events |
| Workflow | Add and connect nodes using the node panel. Validate one start, reachable nodes, terminal paths and no cycles. The loop node iterates rows. Branches, approvals and error paths generate executable code. |
| Observatory | Return values, bounded service call log, arguments and read/write labels, simulated quotas, logs, state diffs and eight in-session checkpoints |

The editor executes JavaScript in a disposable worker inside an opaque-origin iframe. The frame restricts network access. A three-second limit or Stop discards an incomplete run. A completed run that reports a service error can retain partial mutations so learners can reconcile them. Restore the pre-run checkpoint before retesting a repair. Workspace records, progress, graph and up to five named snapshots live in IndexedDB. JSON backup can move the portfolio between browsers.

The academy models a subset of Workspace. Cache and locks do not emulate real parallel workers. Simple trigger authorization, installed scheduling, OAuth consent, and deployed web-app identity must be verified in Apps Script. Workflow export is graph-to-code. Edited code does not reconstruct a graph. API completion inserts documented snippets from the supported list.

For event-based workflow exports, install the corresponding trigger on the generated handler after testing manually with a fixture. Set `workflow-approved=yes` only after a reviewer approves the operation. Time-driven workflows require an explicit trigger and workbook configuration. The simulator’s clock records events for manual replay.

Google references: [simple triggers](https://developers.google.com/apps-script/guides/triggers), [installable triggers](https://developers.google.com/apps-script/guides/triggers/installable), [Apps Script authorization](https://developers.google.com/apps-script/guides/services/authorization).

## Optional Gemini integration

The browser lessons use synthetic API responses. [GeminiReview.gs](downloads/GeminiReview.gs) is a separate optional server-side Apps Script template for extraction, summarization, classification and document drafts. It requires explicit approval before a transfer, validates the returned schema and produces a proposal for human review. It performs no email or Workspace write.

In a private test project, set `GEMINI_API_KEY` and `GEMINI_MODEL` in Script Properties. Choose a model that supports structured JSON outputs and keep access to the script project restricted. Review the approved synthetic text and call `requestGeminiProposal(text, 'extract', true)` from a manually run test function. Handle throttling or incomplete output by holding the job for review. Use a production secret store and reviewed data policy if deploying for multiple operators.

The template was verified with mock responses. Live model access and Apps Script deployment require your Google configuration. [Gemini API documentation](https://ai.google.dev/api/generate-content).

## Verification

From the site root, run:

```sh
node --test workspace-automation-architect/tests/*.test.mjs
python3 scripts/test_seo.py
```

Tests exercise all 120 lesson references, 30 project references and 50 initial failures plus their repairs. The first mission is checked against the initial queue, a new open request and an empty queue. Other tests cover workflow approval and recovery paths, rejection of graph cycles, backup validation, draft-only mail, edit events and the Gemini template’s approval and validation behavior. The local browser check covered real isolated execution, generated Docs, both workflow approval outcomes, IndexedDB restoration, script download, failure and repair, and the phone layout.
