My architecture diagrams showed what talks to what. A commenter asked what each connection is allowed to do, and they couldn't answer. So I mapped two of my projects. worklore runs on AWS Lambda with DynamoDB and lives in three repos: the backend and site, the agent skill, and the MCP registry entry. AimYear runs on Google Cloud Run with Firestore: a phone app, an MCP server, and an old chat backend with no repo. In both, the repo that checks a pass doesn't decide where it's kept: worklore's skill puts the agent's pass in a shell profile, and AimYear's Mac scripts read theirs from a file.
Both times I started with a table of every pass: who gets it, what it can do, how long it lives, how to end it early, and where it travels. Then every machine identity, including the ones nobody draws. Then a diagram with that on every arrow, and yes or no questions for the cloud's permission checker.
On worklore, "sign out" didn't end a pass, and three background jobs could write a session row, the admin's included: 12 of 13 "must not" questions came back allowed. On AimYear, the old chat backend had no chat calls in four months but was still public, ran as the default account with Editor on the whole Google project, and kept three AI provider keys in plain settings. The Mac scripts and the minute scheduler sent my never-expiring token in the URL, and Cloud Run logs every URL: about 2,000 log lines a month. A Firebase admin key on my laptop could act as any account. The cleanest arrow on either map crossed clouds: Cloud Run sends email through AWS with no stored key, as one domain only.
The clouds differed in two places. AWS's policy simulator answers right away; Google's Policy Troubleshooter needs its API switched on, so I expanded each role into its permissions instead, read-only. And after I rotated the token, an old Cloud Run copy still took the old one: its traffic was pinned to an older revision, so my update created a revision with no traffic.
I drew the maps with Archify. It checks every cited line at a pinned commit, but it pins one repository per diagram and puts no code references on arrows. So the evidence sits on the box that enforces each rule, and boxes from the other repos carry none.

Check if this applies to you
Applies if: your backend runs on AWS or Google Cloud, and more than one service, function or scheduled job runs there under a cloud identity (an IAM role or a service account).
On Google Cloud, all read-only:
- List which account each Cloud Run service runs as:
gcloud run services list --project <project> --format='value(metadata.name,region,spec.template.spec.serviceAccountName)'. - List downloadable keys:
gcloud iam service-accounts keys list --iam-account <account> --managed-by=userfor each account ingcloud iam service-accounts list --project <project>. - Search the request log for passes in URLs:
gcloud logging read 'resource.type="cloud_run_revision" AND httpRequest.requestUrl=~"/[A-Za-z0-9_-]{32,}"' --project <project> --freshness=30d --limit=20 --format='value(httpRequest.requestUrl)'. Long random path parts that are tokens, not ids, count.
On AWS, for each role of a function that should never issue passes, if your passes are rows in DynamoDB:
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::<account>:role/<role> \
--action-names dynamodb:PutItem dynamodb:UpdateItem \
--resource-arns arn:aws:dynamodb:<region>:<account>:table/<table> \
--context-entries ContextKeyName=dynamodb:LeadingKeys,ContextKeyValues=<pass-key-prefix>x,ContextKeyType=stringList
Use the real key prefix of your pass rows (mine is tok#).
Has the problem: any of these. A service runs as <number>-compute@developer.gserviceaccount.com (the default account, which has Editor unless someone removed it). An account that holds Editor, Owner or Service Account Token Creator has a user-managed key. A request URL in the log carries a pass. The simulator answers allowed for a role that should never write a pass. Doesn't have it: every service has its own account, those accounts have no downloadable keys, no logged URL carries a pass, and every such role gets implicitDeny or explicitDeny.
Reproduce this
Prerequisites: one or more projects in one or more repositories, deployed on AWS (roles in SAM, CloudFormation or Terraform) or Google Cloud; read access to the cloud account (iam:SimulatePrincipalPolicy and cloudformation:DescribeStackResources on AWS; resourcemanager.projects.getIamPolicy, run.services.list, iam.serviceAccountKeys.list and logging.logEntries.list on Google Cloud); ideally a staging copy for request checks.
Your agent will need from you: the list of repositories and which one deploys each backend; the cloud profiles, stacks or project ids; which services are still in use, if you know; and which risks you accept as they are. I accepted three: worklore's API reads every secret, including one social account's password; AimYear's MCP server account can read and write every Firestore document, because Firestore has no per-document cloud permissions and the code decides whose data it touches; and a Google Play publishing key stays committed in a private repo. Without that last answer, your agent will decide for you.
Steps:
- Give every repository one role: issues passes, holds them, enforces them, or only describes them. Grep each for where a token is created, stored, checked, sent and deleted. Note each repo's commit SHA, since the map is true only at those commits.
- Make the pass table from the code, not from memory: pass, who gets it, what it can do, lifetime, where it is enforced (file and line), how to end it early, and where it travels (a header, a URL path or query, a file on disk, a plain setting). An empty "end it early" cell is a finding. "URL" is a finding on any host that logs request URLs, and Cloud Run does by default.
- Add every machine identity: each AWS role in the template, or each Google service account with its project roles (
gcloud projects get-iam-policy) and the services that run as it. Include services nobody remembers: for each one, check the last request that wasn't a scanner. For a table that also holds passes, ask what each role can write, not only read. - Draw it. Each arrow's label says which pass or right crosses it, what it can do, how long it lives and how to end it early ("session pass: every write, 90 d, sign out").
- Tool: check your agent's skills for
archify. If it's missing, download https://github.com/tt-a1i/archify and runnode archify/bin/archify.mjs(I used 3.2.0 in November and 3.3.4 in December). - Several repos: it pins one repository per diagram (
meta.repository.revision). Pin the repo that enforces, draw the others as boxes, and name their files in a card. Archify's docs also offer one diagram per repo linked withhref; I didn't try that. - Layout: if its full check rejects a wide map for readability, try
"layout": {"mode": "auto"}. For a before and after pair, take the auto positions of the after map from the exported SVG and pin them in both, so the two pictures match. If it still refuses,renderandexport-svgkeep checking the code references. - Without Archify, any diagram tool works; the labels are the point.
- Fix what the map shows.
- AWS: one condition per role.
dynamodb:LeadingKeyslimits a role to its own row prefix,dynamodb:Attributesto its own fields. For SES, name the one identity a function may send as instead ofidentity/*. - Google Cloud: delete services nobody uses. Give each service its own account. Delete keys of accounts that can act as other accounts. Move tokens from URLs into the
Authorizationheader and into Secret Manager. Let Cloud Scheduler sign its calls with an account that has no roles (--oidc-service-account-email, audience the target URL), and have the server accept only that account. - Then rotate any token that was ever in a URL. If a service's traffic is pinned to an old revision,
gcloud run services updatecreates a revision with 0% traffic from the latest template's image. Deploy the pinned image with the new setting (--image <pinned image> --no-traffic), then move the traffic to it, and check that the old token gets 401.
- Write the labels down as questions: what each identity must still be able to do, and what it must not. On AWS, ask the policy simulator against the deployed stack. On Google Cloud,
gcloud policy-intelligence troubleshoot-policy iamneedspolicytroubleshooter.googleapis.comenabled. Without enabling it, expand each bound role withgcloud iam roles describe <role>and look for the permission; this covers project-level bindings without conditions only. Add a log search for URLs that carry a pass since the fix. - Redraw the map from the new commits.
archify compare architecture before.json after.json out.htmlbuilds one page with Before, Delta and After.
Verify: every "must not" question is denied and every "must" question is allowed, against what is deployed now. The old token gets 401 on every copy of the service, the new one works. No request URL logged since the fix carries a pass. No service runs as the default compute account. On staging, every protected route refuses a request with no pass, with the wrong kind of pass, and, for admin routes, with an ordinary user's pass, while your usual user flows still pass. Each label on the after diagram matches the code and the cloud settings at the pinned commit.