Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ogma-core: Spec2Copilot backend does not perform variable substitution in top-level property names #120

Closed
ivanperez-keera opened this issue Jan 22, 2024 · 6 comments
Assignees
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Bug Admin only: Change request pertaining to error detected
Milestone

Comments

@ivanperez-keera
Copy link
Member

ivanperez-keera commented Jan 22, 2024

Description

When using property names as arguments to trigger, the Spec2Copilot backend does not apply the same variable/name substitution that was applied in their definition, thus referring in the call to trigger to an undefined argument.

Type

  • Bug: code produced by backend does not compile.

Additional context

None.

Requester

  • Ivan Perez

Method to check presence of bug

Running the backend with one of the examples available in ogma produces code that does not compile.

$ ogma fret-component-spec --fret-file-name ogma-core/tests/fret_good.json  > Example.hs
$ runhaskell Example.hs
Example.hs:58:35: error:
    Variable not in scope: behnazOne :: Stream Bool
   |
58 |   trigger "handlerbehnazOne" (not behnazOne) []

Expected result

When executed, the code produced by the Spec2Copilot backend does not report to an error due to a trigger stream identifier being undefined.

Desired result

When executed, the code produced by the Spec2Copilot backend does not report to an error due to a trigger stream identifier being undefined.

Proposed solution

Modify the definition of Spec2Copilot backend to apply the name substitution function to trigger argument names.

Further notes

None.

@ivanperez-keera ivanperez-keera added CR:Status:Initiated Admin only: Change request that has been initiated CR:Type:Bug Admin only: Change request pertaining to error detected labels Jan 24, 2024
@ivanperez-keera
Copy link
Member Author

Change Manager: Confirmed that the issue exists.

@ivanperez-keera ivanperez-keera added CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager and removed CR:Status:Initiated Admin only: Change request that has been initiated labels Jan 24, 2024
@ivanperez-keera
Copy link
Member Author

Technical Lead: Confirmed that the issue should be addressed.

@ivanperez-keera ivanperez-keera added CR:Status:Accepted Admin only: Change request accepted by technical lead and removed CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager labels Jan 24, 2024
@ivanperez-keera
Copy link
Member Author

Technical Lead: Issue scheduled for fixing in Ogma 1.3.

Fix assigned to: @ivanperez-keera.

@ivanperez-keera ivanperez-keera added CR:Status:Scheduled Admin only: Change requested scheduled and removed CR:Status:Accepted Admin only: Change request accepted by technical lead labels Jan 24, 2024
@ivanperez-keera ivanperez-keera added this to the 1.3.0 milestone Jan 24, 2024
@ivanperez-keera ivanperez-keera self-assigned this Jan 24, 2024
@ivanperez-keera ivanperez-keera added CR:Status:Implementation Admin only: Change request that is currently being implemented and removed CR:Status:Scheduled Admin only: Change requested scheduled labels Jan 24, 2024
ivanperez-keera added a commit that referenced this issue Jan 24, 2024
When using property names as arguments to trigger, the Spec2Copilot
backend does not apply the same variable/name substitution that was
applied in their definition, thus referring in the call to trigger to an
undefined argument.

This commit modifies the generation of trigger names in Copilot to be
able to apply the same name subsitution map, so that the stream name is
resolved.
@ivanperez-keera
Copy link
Member Author

Implementor: Solution implemented, review requested.

@ivanperez-keera ivanperez-keera added CR:Status:Verification Admin only: Change request that is currently being verified and removed CR:Status:Implementation Admin only: Change request that is currently being implemented labels Jan 24, 2024
@ivanperez-keera
Copy link
Member Author

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles passes the tests. Details:
      Docker image:

      FROM ubuntu:trusty
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy
      RUN apt-get install --yes git
      
      # We install the application first and then test it, in case any tests need to
      # run the tool.
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/ogma-cli/ $NAME/ogma-core/ --enable-tests --constraint "ogma-language-fret-reqs -test" && \
          cabal v1-install $NAME/ogma-cli/ $NAME/ogma-core/ --enable-tests --constraint "ogma-language-fret-reqs -test" --run-tests -j1

      Command:

      $ docker run -e "REPO=https://github.com/nasa/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=448465b5d5bdbb4d62f051d7a27a475e1bdbc417" -it ogma-test
    • The solution proposed fixes the issues described. Details:
      The following Dockerfile checks that the given given backend produces a Copilot spec that compiles, in which case it prints the message "Success".

      --- Dockerfile
      FROM ubuntu:trusty
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy
      RUN apt-get install --yes git
      
      ADD sample.json /tmp/
      
      RUN cabal v1-install BNFC copilot-3.18.1
      
      # We install the application first and then test it, in case any tests need to
      # run the tool.
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/$PAT**/ && \
          ogma fret-component-spec --fret-file-name /tmp/sample.json > sample.hs && \
          cabal v1-exec -- runhaskell sample.hs && \
          echo "Success"
      
      -- sample.json
      {
        "RTSASpec": {
          "Internal_variables": [],
          "Other_variables": [
            {"name":"param", "type":"bool"}
          ],
          "Requirements": [
            {
              "name": "one",
              "CoCoSpecCode": "true",
              "ptLTL": "((H (param) ))",
              "fretish": "Meaning not specified"
            }
          ]
        }
      }

      Command:

      $ docker run -e "REPO=https://github.com/nasa/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=448465b5d5bdbb4d62f051d7a27a475e1bdbc417" -it ogma-verify-120
      
  • Implementation is documented. Details:
    No changes needed.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No examples affected.
  • Required version bumps are evaluated. Details:
    Bump not needed (bug fix to comply with intended API).

@ivanperez-keera
Copy link
Member Author

Change Manager: Implementation ready to be merged.

@ivanperez-keera ivanperez-keera added CR:Status:Closed Admin only: Change request that has been completed and removed CR:Status:Verification Admin only: Change request that is currently being verified labels Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Bug Admin only: Change request pertaining to error detected
Projects
None yet
Development

No branches or pull requests

1 participant