You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a4439ab
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/API.md
+47-7Lines changed: 47 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,23 @@ is initiated only by user interaction. The browser then talks directly to
20
20
GitHub for viewer state and mutations; the service never receives the user's
21
21
GitHub token after exchange and provides no general user-token proxy.
22
22
23
+
## Permissions
24
+
25
+
| Principal | Permission used | Operation |
26
+
| --- | --- | --- |
27
+
| GitHub App installation | Discussions read | Find discussions, read threads, reactions, polls, labels, and author data |
28
+
| GitHub App installation | Discussions write | Create a discussion after a signed creation grant |
29
+
| Signed-in GitHub user | Discussions read/write on the target repository | Read viewer state; vote, react, comment, reply, edit, delete, and mark answers where GitHub permits |
30
+
| Browser on an allowed site origin | Service read routes | Read public counters and threads without signing in |
31
+
| Browser with OAuth state and PKCE verifier | Service OAuth routes | Exchange a code for a user token and creation grant |
32
+
33
+
The example requests only the target repository's Discussions permission through
34
+
the GitHub App. GitHub still enforces repository roles for edits, deletion, and
35
+
answer selection. A creation grant does not grant those GitHub privileges.
36
+
Origin checks enforce browser CORS policy; non-browser callers can forge an
37
+
`Origin` header, so public reads rely on bounded batches, short-lived caching,
38
+
and GitHub request concurrency limits rather than origin as authentication.
39
+
23
40
## Configuration and intents
24
41
25
42
Every site declares `mode`, `intents`, one or more categories, and a default
@@ -37,7 +54,7 @@ in different categories should use category-qualified keys.
37
54
|`reactions`| Main-post reaction groups selected by `reaction_counters`|
38
55
|`discussion`| Authoritative thread read and discussion creation |
39
56
|`comments`| Comments and replies |
40
-
|`answers`|Accepted-answer state |
57
+
|`answers`|Selected-answer state (`isAnswer`); GitHub GraphQL does not expose the verified-answer badge|
41
58
|`polls`| Poll question, options, and totals |
42
59
|`authors`| Author identity and `authorAssociation`|
43
60
|`moderation`| Moderation reason for visible comments; minimized comments are always excluded |
@@ -62,6 +79,20 @@ All JSON responses contain `v: 1`. Errors are
62
79
|`POST`|`/v1/sites/{site}/discussions/ensure`| Find or create a thread for a validated resource and grant |
63
80
|`GET`|`/v1/sites/{site}/discussion?keys=a,b`| Fetch up to ten authoritative configured threads in one GitHub `nodes` query |
64
81
82
+
`OPTIONS` is registered explicitly for the reaction and POST routes. It checks
83
+
the site origin and returns the allowed method and headers. `HEAD` is disabled
84
+
because a nominally cheap metadata request could otherwise trigger a GitHub read.
85
+
86
+
The route map lives in `src/feedback/api/routes.py`. Handlers in
87
+
`src/feedback/api/endpoints/` handle HTTP validation and responses; shared site
88
+
authorization is in `src/feedback/api/context.py`. Counter shaping and GitHub
89
+
operations live under `src/feedback/service/` and `src/feedback/protocol/`.
90
+
91
+
The service registers only these API paths. `/` and documentation/schema paths
92
+
return 404. The production reverse proxy rejects all other paths before they
93
+
reach the service. It offers Brotli for eligible JSON responses when the client
94
+
sends `Accept-Encoding: br`; small responses are left uncompressed.
95
+
65
96
A minimal counter response is:
66
97
67
98
```json
@@ -72,6 +103,8 @@ A minimal counter response is:
72
103
`reaction_counters` is non-empty. Cache age and server internals are not exposed.
73
104
Unknown resources have `id: null` and zero counts. Counter responses revalidate
74
105
with an ETag. Discussion and OAuth responses are `no-store`.
106
+
Thread reads currently include the first 25 top-level comments and the first
107
+
25 replies under each; pagination is not exposed by this API.
75
108
76
109
## Browser API
77
110
@@ -87,6 +120,12 @@ viewer-reaction state. A discussion UI can compose these
87
120
without routing user actions through the service. Authentication tokens are held
88
121
in session storage; counter/viewer snapshots contain no token.
89
122
123
+
The example offers a simple textarea or local Markdown formatting tools. GitHub
124
+
renders submitted Markdown. Successful mutations update the visible count from
125
+
GitHub's response. Mutations are not aborted after dispatch because cancelling
126
+
the network request cannot establish whether GitHub applied the change. After an
127
+
uncertain failure, refresh viewer state before retrying.
128
+
90
129
## GitHub request audit and abuse boundaries
91
130
92
131
The server can contact GitHub only in these places:
@@ -101,16 +140,17 @@ The server can contact GitHub only in these places:
101
140
4. Discussion discovery/creation. Work is serialized per site/resource; exact
102
141
repository and category matches are required, and the resulting ID is stored.
103
142
5. Discussion reads. Up to ten threads are grouped in one `nodes(ids:)` request.
104
-
Identical simultaneous batches share only the in-flight request. Responses
0 commit comments