Skip to content

feat(platform): sync Forgejo, GitHub pull requests and security alerts - #4997

Merged
yannickmonney merged 12 commits into
mainfrom
feat/issue-sync-forgejo-pulls-security
Oct 15, 2026
Merged

yannickmonney merged 12 commits into
mainfrom
feat/issue-sync-forgejo-pulls-security

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

task.sync_issues (the one-step issue sync from #4988) reads four kinds of source instead of two, so the fleet's own Tale can run one intake automation per owner and source kind:

  • github gains type: issues | pulls (default issues) and author (a login, renovate[bot] for Renovate). An issue source without author keeps its position name and filter, so existing documents and their saved positions carry on unchanged.
  • github-security (new): a repository's code scanning, Dependabot and secret scanning alerts, one task per alert. alerts, minSeverity and tools narrow it. GitHub narrows each listing itself (code scanning per tool and severity, Dependabot by severity list with its after cursor, secret scanning with hide_secret=true). The reader then checks the tool and the level again. One scale covers both kinds of severity: a security severity, or error/warning/note read as high/medium/low; a secret counts as critical. States map open→open, fixed/revoked→resolved, dismissed/auto_dismissed/false positive→ignored, anything else→closed. The secret's value is never read or kept.
  • forgejo (new): a new per-credential Forgejo connector (/api/v1, Authorization: token, allowedHosts codeberg.org and git.tale.dev). Its actions: list_repos, list_issues/get_issue/create_issue/update_issue, list_issue_comments/create_issue_comment, list_pull_requests/get_pull_request, plus the natives list_import_issues/get_import_issue/refresh_import_issues. Paging follows Link rel="next", or a full page of 50 when there is no Link header. The source id is <instance origin>#<issue id>, so it stays stable across instances. Links are built from the connection's own origin, and a refresh reads the repository again by id (once per refresh). labels means an item needs every one of them, as on GitHub; Forgejo drops a label name the repository lacks without a word, so the reader checks each row's labels again.
  • glitchtip, as before.

Also:

  • taskLabels per source (up to 10): labels a task the source creates is given, e.g. source:glitchtip, repo:ops. A task the sync made before keeps its labels.
  • failOn: any on the step: fail as soon as one source failed (rate-limited sources still don't count). The default (all) keeps today's behaviour.
  • A repository's issues and pull requests keep separate positions, and each refreshes only its own tasks. The refresh query filters linked tasks by item kind through the snapshot URL (/pull(s)/<n>). A security source likewise refreshes only the alerts of the kinds it names (the kind in the snapshot id <repo id>/<kind>/<n>).
  • On a tracker whose connection names its instance (Forgejo, GlitchTip), a source that names a credential keeps a position of its own: one repository synced from two instances (a repository and its Codeberg mirror) keeps two passes. A source on the default connection keeps the position name it had.
  • One tracker registry (ISSUE_TRACKERS in @tale/shared/schemas/task-external-issue) replaces every hard-coded github | glitchtip. It records each tracker's scope field, case folding and whether it is per instance. The registry is used by issue-sync, platform-tasks, the task connector enums, task-store (scope/case rules), external-ref (lifecycle, scope, case), external-status (the source-status lane), mentions, the task source card and the status card.
  • Templates: github/sync-pull-requests, github/sync-security-alerts (hourly; floor high to start), and forgejo/sync-issues (issues or pull requests by a question). There is also a Forgejo brand mark (brand:forgejo).
  • REST contract 3.46.0: for externalSystem github-security and forgejo, the intake now treats tasks as tracker mirrors. externalState no longer moves the task, @names are kept, and PUT …/external-status refuses with TASK_EXTERNAL_REF_INVALID. No operation or schema changes.
  • Spec rules TASK-R62 to R66 in domains/tasks/spec.md (main took TASK-R61 while this was open); TASK-R54's heading now says "by default".

No migration. app.tasks.external_system has no CHECK constraint, and task_import_cursors accepts any kebab slug since 0211, which covers github-security.

Review fixes (second round)

The branch was rebased on main, which had taken TASK-R61, and CI's two unit failures are fixed: the domain-spec guard (rules renumbered R62 to R66) and the shipped-connector list (forgejo added). Then each review finding:

  1. Per-instance positions (issue-sync.ts positionKey). A Forgejo source's position and duplicate key were owner/repo plus filter, while its cursor belongs to its instance. Two instances shared one row and kept restarting each other's pass. Now, on trackers marked perInstance, a named credential is folded into the position digest and the duplicate key. GlitchTip had the same defect on main and gets the same fix. A GitHub source is unchanged, since GitHub is one instance. Test: two Forgejo sources on one owner/repo under two credentials are both accepted and each resumes its own pass over three runs (fails without the fix).
  2. Forgejo label filter (issue-import-forgejo.ts). Each row must now carry every label named, compared case-insensitively. Test: the instance ignores the filter and answers unlabelled and partly-labelled rows; only rows with every label are kept.
  3. Wording. "Any one of them" became "every one" in the Forgejo template question (en/de/fr), the step's and the Forgejo connector's descriptions, docs templates.md and triggers.md (en/de/fr), and the code comment.
  4. Alert-kind refresh isolation. LinkedIssueQuery.alertKinds filters on split_part(external_source_id, '/', 2). Tests: a unit test, and a real-Postgres case (NOT_RUN locally).
  5. Tool names. One exported securityToolName schema serves both the sync source and the native listing. It refuses only control characters, because laneUrl encodes the name, so &, # and ? now work. The step's and the action's JSON schemas carry the same pattern, so save-time validation refuses what a run would. Tests check that both layers agree, and that a name with reserved characters is sent encoded.

Data note: a GlitchTip source that already names a credential moves to a new position name, so its next run starts one new pass from the oldest issue. Writes go by source identity, so no task is duplicated, and the old position row is left unused. Sources on the default connection, and every Forgejo source (none stored before this PR), are unaffected.

Why

The fleet's Tale needs intake for GitHub issues, security alerts and Renovate PRs (until the Forgejo cutover), Forgejo issues and Renovate PRs, and GlitchTip issues. Before this change, the sync knew only GitHub issues and GlitchTip and dropped PRs. There was no Forgejo connector and no security-alert reader. tale holds 7,129 open code-scanning alerts (7,057 from Trivy), so the tool filter and severity floor are applied by GitHub itself. That keeps a high-signal sync cheap. Alerts are not grouped per rule: one task per alert keeps refresh simple, because each alert has its own state.

How tested

All runs were local, with bun 1.4.2.

  • tsc --noEmit: @tale/platform, @tale/shared, @tale/ui, @tale/ui-docs. Clean.
  • oxlint --type-aware on every changed TS file in platform, shared, ui and ui-docs. Clean.
  • knip: no unused exports.
  • Platform server unit tests for every touched area: lib/connectors lib/automations lib/engine lib/mcp scripts/openapi backend/domains/connectors backend/domains/tasks backend/core/tasks backend/core/connector_credentials tests/guards lib/i18n. 303 files and 6,088 tests pass. They include:
    • new issue-import-forgejo.test.ts and issue-import-alerts.test.ts (fake HTTP APIs, paging, cursors, filters, refresh, instance isolation, secret never kept)
    • GitHub pull request intake
    • sync adapters, positions, labels and failOn
    • list_external_issues
    • external-ref labels-on-create-only and tracker lifecycle
    • the pack suite (every sync template stays one step at 20 sources)
    • corpus snapshots, the MCP fingerprint and skill snapshot, the OpenAPI fingerprint, and the domain-spec guard
  • Platform UI tests: the task source card (PR, Forgejo and alert headings), connector settings and the automation run dialog. Pass.
  • @tale/shared (1,019 tests) and @tale/ui data-display and icons (494 tests). Pass.
  • @tale/docs tests (716), lint:links, lint:manual and check-guide on the touched suites. Pass.
  • Live API shape checks: the Forgejo swagger on codeberg.org (sort=oldest, created_by, type, Authorization: token), and GitHub issues?creator=renovate[bot], which returns 200 and the bot's items. The swagger's "any of these labels" is wrong: the review's live read of codeberg.org showed Forgejo requires every label and discards an unknown one, which the reader and every text now follow.

Second round (after the rebase): tsc --noEmit for platform is clean, oxlint --type-aware on the changed files is clean, knip is clean, and oxfmt --check passes. 185 platform unit test files (3,406 tests) pass across lib/connectors lib/shared/schemas tests/guards backend/domains/tasks backend/domains/connectors lib/automations, as do lib/engine and lib/i18n (2,845 tests), @tale/docs (716), lint:manual, lint:links and lint:conflicts. The two intermediate fix commits were typechecked and tested on their own.

Not done

  • backend:integration was not run locally (it needs a Postgres/Docker stack). Two cases in issue-sync.integration.ts cover item-kind refresh isolation with task labels on create only, and alert-kind refresh isolation for two security sources of one repository. The merge queue's Backend integration check runs them.
  • No live sync against a real GitHub security-alert API or a real Forgejo instance yet. The manual boxes AUTO-F241 to F245 and CONN-F23 cover that.
  • Out of scope, as briefed: write-back to trackers, webhooks.
  • The Forgejo mark is a generic branch glyph in Forgejo's orange, not the official Forgejo logo (that logo is CC BY-SA and would need attribution).

Draws the Forgejo connector's branch mark for brand:forgejo, in an
orange that keeps AA contrast on the light tile and a lighter orange of
the same hue on the dark muted tile, so a Forgejo template card shows
its product like the GitHub and GlitchTip ones.
task.sync_issues read GitHub issues and GlitchTip issues only. It now
reads four kinds of source:

- github: issues by default, or pull requests with type pulls; author
  narrows to one login (renovate[bot]). An issue source without author
  keeps the position it had, so existing documents carry on.
- github-security: a repository's code scanning, Dependabot and secret
  scanning alerts, one task per alert. GitHub narrows each listing by
  tool and severity floor (one scale over security severities and
  error/warning/note), the reader checks both again, and a secret's
  value is never read (hide_secret) or kept.
- forgejo: a new per-credential connector (Forgejo/Gitea /api/v1,
  Authorization: token) with repository, issue, comment and pull request
  actions plus the import natives. Identity is the instance origin and
  issue id, links are built from the connection's origin, and a refresh
  reads the repository again by id.
- glitchtip, as before.

Every source may name taskLabels for the tasks it creates, and the step
takes failOn: any to fail as soon as one source failed. A repository's
issues and pull requests keep positions and refreshes of their own.

The tracker list moves into one registry (@tale/shared
task-external-issue) that the task domain, the intake, mentions, the
source-status lane and the board read. For forgejo and github-security
the REST intake now treats tasks as tracker mirrors, so the contract
moves to 3.46.0. Spec rules TASK-R61 to TASK-R65.
Three catalog templates on the one task.sync_issues step:

- github/sync-pull-requests: a repository's open pull requests, all of
  them or one login's (renovate[bot]), beside Sync GitHub issues.
- github/sync-security-alerts: one kind of alert from a severity floor
  up (high to start with) and, for code scanning, the tools named, so a
  repository with thousands of scanner alerts syncs only the ones worth
  a task.
- forgejo/sync-issues: a Forgejo repository's open issues or pull
  requests, by a question, read through the connection that names the
  instance.

Each ships its own tests against the mocks; the pack suite proves every
sync template stays one step at twenty sources.
The templates page describes Sync GitHub pull requests, Sync GitHub
security alerts and Sync Forgejo issues in EN/DE/FR; the schedule page
tables the four kinds of source with their fields, the taskLabels of
each source and the step's failOn option. The automations suite gains
AUTO-F241 to AUTO-F245 for what a live GitHub and Forgejo must show,
and the automation register names the specs that now hold TASK-R53 to
TASK-R65.
The catalog test pins the connectors the image ships, so a Forgejo
connector without its slug in the list fails the catalog walk.
Main took TASK-R61 for a refused dispatch declaration, so the issue
sync's rules move one up (R62 to R66), with every test title, cross
reference and manual box that names them. The domain spec guard refuses
a rule stated twice.
A Forgejo or GlitchTip source's position was named after owner/repo (or
organization/project) and its filter alone, while each listing's cursor
belongs to its instance. Two automations syncing one repository from two
instances (a repository and its Codeberg mirror) shared one row: each run
found the other instance's cursor, restarted the pass and saved its own
first batch, so a repository larger than one batch never synced past it,
and one step listing both was refused as a duplicate.

On a tracker whose connection names its instance, a source that names a
connection now folds it into the position's digest and the duplicate
check. A source on the default connection keeps the name it had, and a
filter alone keeps the digest it had, so no stored position moves; a
GlitchTip source that names a connection starts one new pass.
Forgejo lists the items carrying every label it is asked for, as GitHub
does, but drops a name the repository has no label of without a word
(its API: "Non existent labels are discarded"). A misspelt or renamed
label therefore widened a source to every open issue or pull request,
100 tasks a run, and "bug,typo" quietly read as "bug".

The reader now keeps a row only when its labels carry every name the
source asks for, compared without regard to case, as it already did
for the kind and the author. Every text that said Forgejo reads labels
as alternatives (the template question in en/de/fr, the task and
Forgejo connector descriptions, the template and trigger docs) now says
an item needs every one of them.
A github-security source looked up its linked tasks by repository alone,
so it read again every alert task of the repository, whatever kinds it
names. With a code scanning source on one connection and a secret
scanning source on another, each refresh read the other's alerts; a
token without access answered 404, the task was marked unavailable, and
the next run through the right connection restored it, so the flag and
the receipts flipped from run to run.

The linked query now carries the source's alert kinds, matched on the
kind in the snapshot id (<repository id>/<kind>/<number>), as a code
host source already reads again only its issues or its pull requests.
The real-Postgres lane proves two security sources of one repository
read again only their own kinds.
The step and the template took any text as a code scanning tool name,
while github.list_import_alerts refused a control character, "&", "#"
and "?". A source saved with such a name passed at save time and failed
every scheduled run with INPUT_INVALID, three of which restarted its
pass.

One schema, securityToolName, now holds the rule for the sync's sources
and for the listing, and the step's and the action's input schemas
carry the same pattern, so the refusal comes where the source is
written. Only a control character is refused: the listing encodes the
name into its address, so "&", "#" and "?" are read as written.
The register row for the issue sync now names what its specs hold since
the review fixes: a position per connection on Forgejo and GlitchTip,
labels an item needs every one of (Forgejo's rows checked again), a
security source refreshing only its own kinds, and the tool name rule.
@yannickmonney
yannickmonney force-pushed the feat/issue-sync-forgejo-pulls-security branch from 7fe8180 to 79ca033 Compare October 15, 2026 13:34
@yannickmonney
yannickmonney marked this pull request as ready for review October 15, 2026 13:34
@yannickmonney
yannickmonney merged commit 8739747 into main Oct 15, 2026
@yannickmonney
yannickmonney deleted the feat/issue-sync-forgejo-pulls-security branch October 15, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant