[help wanted] The map lists a Swift `@main` type as a program entry (CONTRIBUTING slice 10b)

Open
#452 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
53/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, swift
Domain
cli, tooling

Research direction

Start with queries/swift/tags.scm and use ripwire --match on the provided fixture to confirm the Swift grammar nodes for @main. Read rustItemAttrRunAny in src/ingest_names.h and trace the inventory styles, predicates, and legend in src/mapinventory.h. Add the entry fact through an existing channel, define the attribute-marked type as the entry, and update test/mapinventorycheck.sh while retaining its unannotated App.main near miss. Done means the Swift positive control emits an entry with run among its callee rows and the stated acceptance gates pass.

Written by the indexing model from the issue text.

Description

enhancement help wanted

Claim it in this issue first. Size: S. Depends on: nothing. Language: Swift.

The problem, in user terms

The map's inventory names the program entries among the files it does not show, so an agent landing in a repository sees where execution starts. For C, C++, Rust, Go, Java, Python and the others it does; for a Swift package whose entry is an attribute (@main struct Tool { static func main() { … } }) it does not. Fixture: Sources/Tool.swift with that type, Sources/Util.swift defining helper(), and G1.swift to G6.swift each calling helper() (so the shown row is helper, not the entry), against the same shape in C (main.c with int main(void)):

ripwire . --no-cache --top-k=1          # the Swift package
<inv listed="1" unlisted="7">
<ls p="Sources" n="7" f="G1.swift,…,Tool.swift"/>          (no <entry> row)

ripwire . --no-cache --top-k=1          # the C project
<entry p="main.c" n="main" …>

(built from daf1ccba.) inventoryEntryStyle (src/mapinventory.h) has no Swift row, so Swift is style None: "no claim". The legend and the file header both say why: "entries declared … by an attribute (Swift @main) are not detected" because the index does not read an attribute as an entry declaration. (Swift's other entry, a top-level main.swift, is a different convention and not this slice.)

Files to touch

  • queries/swift/tags.scm: the @main attribute is on the type declaration (class_declaration, whose modifiers hold an attribute). Find the node shape with ripwire --match on your fixture before writing the pattern (the grammar's attribute and modifier node names are the part to verify, not guess). Capture the attribute so ingest records an entry-declaration fact on the type; follow how Rust reads an item attribute (rustItemAttrRunAny, src/ingest_names.h) or how a test attribute is read, so the fact rides an existing channel rather than a new walk.
  • src/mapinventory.h: inventoryEntryStyle / isInventoryEntryShape / kInventory*Langs: a fourth style for "an attribute marks the entry type": the type (class or struct) carrying the fact is the entry, main is its callee. Keep it a row of data (a Lang in a list plus a style), not a Lang::Swift compare.
  • src/mapinventory.h legend (kMapInventoryLegend) and the header comment: drop "Swift @main" from the not-detected list; regenerate docs if a generated legend changes.
  • test/mapinventorycheck.sh: arm (Q) currently asserts lib/App.swift (a class with a method named main, no attribute) is NOT an entry; keep that as the near miss and add the @main positive control.

Red-first fixture and gate arm

  • red on main: the Swift fixture prints no <entry>; after the change <entry p="Sources/Tool.swift" n="Tool" …> (or n="main", say which in the PR) with run among its callee rows.
  • near misses: class App { func main() {} } with no attribute (the existing arm: stays no entry); @main on an extension; @main in a test directory (the inventory already excludes test paths); two @main types in two targets; a type whose main is not static.

Acceptance

  • bash test/langidentitycheck.sh BASE HEAD --langs=swift,kt,java,cs,rs,go,cpp: other languages SAME; Swift DIFFs only on the map's <inv> block, waived by an --intended row naming test/mapinventorycheck.sh. Add one real Swift repository with --repo=swift:<your clone>.
  • ripwire . --quality-delta=origin/main..HEAD gates 0; CONTRIBUTING definition of done. The same attribute mechanism is what Kotlin @JvmStatic would use later; do not add it here.

Not in scope

Kotlin @JvmStatic, manifest-declared entries (Package.swift executable targets, and slice 10a for Cargo and package.json), and Swift main.swift top-level code.


If nobody has claimed this by the time our next integration train starts, we will pick it up ourselves. Claiming it only takes a comment here.

Dominant language
C++
Stars
2.5k
Forks
158
Avg merge
1d 12h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from redhat-et/ripwire

All issues in redhat-et/ripwire

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.